From 925e106c438fad61dc0ddba09b55f01a3192f4cc Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Sun, 10 Apr 2016 22:33:44 -0400 Subject: [PATCH 1/2] add ubuntu package scripts, lbry:// uri handler --- packaging/ubuntu/README.md | 5 ++ packaging/ubuntu/lbry-init.conf | 11 +++++ packaging/ubuntu/lbry-uri-handler | 20 ++++++++ packaging/ubuntu/lbry.desktop | 21 ++++++++ packaging/ubuntu/ubuntu_package_setup.sh | 61 ++++++++++++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 packaging/ubuntu/README.md create mode 100644 packaging/ubuntu/lbry-init.conf create mode 100755 packaging/ubuntu/lbry-uri-handler create mode 100644 packaging/ubuntu/lbry.desktop create mode 100755 packaging/ubuntu/ubuntu_package_setup.sh diff --git a/packaging/ubuntu/README.md b/packaging/ubuntu/README.md new file mode 100644 index 000000000..d1a3d81f8 --- /dev/null +++ b/packaging/ubuntu/README.md @@ -0,0 +1,5 @@ +# package scripts + +How to build LBRY packages. + +For best results, run on a fresh image. diff --git a/packaging/ubuntu/lbry-init.conf b/packaging/ubuntu/lbry-init.conf new file mode 100644 index 000000000..c1e192deb --- /dev/null +++ b/packaging/ubuntu/lbry-init.conf @@ -0,0 +1,11 @@ +description "LBRY Daemon" + +#start on (local-filesystems and net-device-up IFACE=eth0) +stop on runlevel [016] + +#expect fork + +respawn +respawn limit 5 20 + +exec /usr/share/python/lbrynet/bin/lbrynet-daemon diff --git a/packaging/ubuntu/lbry-uri-handler b/packaging/ubuntu/lbry-uri-handler new file mode 100755 index 000000000..17d7910ff --- /dev/null +++ b/packaging/ubuntu/lbry-uri-handler @@ -0,0 +1,20 @@ +#!/bin/bash + +set -euo pipefail + +urlencode() { + local LANG=C + local length="${#1}" + for (( i = 0; i < length; i++ )); do + local c="${1:i:1}" + case $c in + [a-zA-Z0-9.~_-]) printf "$c" ;; + *) printf '%%%02X' "'$c" ;; + esac + done +} + +ARG=${1:-} +NAME=$(urlencode "$(echo "$ARG" | cut -c 8-)") + +/usr/bin/xdg-open http://localhost:5279/view?name="$NAME" diff --git a/packaging/ubuntu/lbry.desktop b/packaging/ubuntu/lbry.desktop new file mode 100644 index 000000000..7e5363782 --- /dev/null +++ b/packaging/ubuntu/lbry.desktop @@ -0,0 +1,21 @@ +[Desktop Entry] +Version=1.0 +Name=LBRY +# Only KDE 4 seems to use GenericName, so we reuse the KDE strings. +# From Ubuntu's language-pack-kde-XX-base packages, version 9.04-20090413. +GenericName=Filesharing +# Gnome and KDE 3 uses Comment. +Comment=Stream. Share. Earn. +#Exec=/usr/bin/xdg-open http://localhost:5279/view?name=%U +Exec=/usr/share/python/lbrynet/bin/lbry-uri-handler %U +Terminal=false +Icon= +Type=Application +Categories=Network;Internet;Filesharing +MimeType=x-scheme-handler/lbry; +X-Ayatana-Desktop-Shortcuts=NewWindow + +[NewWindow Shortcut Group] +Name=New Window +Exec=/home/grin/lbryhandler/testlbry newwindow %U +TargetEnvironment=Unity diff --git a/packaging/ubuntu/ubuntu_package_setup.sh b/packaging/ubuntu/ubuntu_package_setup.sh new file mode 100755 index 000000000..27b13fd1b --- /dev/null +++ b/packaging/ubuntu/ubuntu_package_setup.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# Tested on fresh Ubuntu 14.04 install. + +# wget https://raw.githubusercontent.com/lbryio/lbry/master/packaging/ubuntu/ubuntu_package_setup.sh +# bash ubuntu_package_setup.sh master + +set -euo pipefail + +BRANCH=${1:-master} + +# get the required OS packages +sudo add-apt-repository -y ppa:spotify-jyrki/dh-virtualenv +sudo apt-get update +sudo apt-get install -y build-essential git python-dev libffi-dev libssl-dev libgmp3-dev dh-virtualenv debhelper + +# need a modern version of pip (more modern than ubuntu default) +wget https://bootstrap.pypa.io/get-pip.py +sudo python get-pip.py +rm get-pip.py +sudo pip install make-deb + +# check out LBRY +git clone https://github.com/lbryio/lbry.git --branch "$BRANCH" + +# build packages +( + cd lbry + make-deb + dpkg-buildpackage -us -uc +) + + +### insert our extra files + +# extract .deb +PACKAGE="$(ls | grep '.deb')" +ar vx "$PACKAGE" +mkdir control data +tar -xvzf control.tar.gz --directory control +tar -xvJf data.tar.xz --directory data + +# add files +function addfile() { + FILE="$1" + TARGET="$2" + mkdir -p "$(dirname "data/$TARGET")" + cp "$FILE" "data/$TARGET" + echo "$(md5sum "data/$TARGET" | cut -d' ' -f1) $TARGET" >> control/md5sums +} +PACKAGING_DIR='lbry/packaging/ubuntu' +addfile "$PACKAGING_DIR/lbry-uri-handler" usr/share/python/lbrynet/bin/lbry-uri-handler +addfile "$PACKAGING_DIR/lbry.desktop" usr/share/applications/lbry.desktop +#addfile lbry/packaging/ubuntu/lbry-init.conf etc/init/lbry.conf + +# repackage .deb +tar -cvzf control.tar.gz -C control . +tar -cvJf data.tar.xz -C data . +ar r "$PACKAGE" debian-binary control.tar.gz data.tar.xz + +# TODO: we can append to data.tar instead of extracting it all and recompressing From 2ac97736ce289ee3324149fb73477e95b28b6dfc Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Tue, 12 Apr 2016 18:50:47 -0400 Subject: [PATCH 2/2] bunch of changes, ready to roll --- packaging/ubuntu/lbry | 32 ++++++++++++++++++++++++ packaging/ubuntu/lbry-uri-handler | 20 --------------- packaging/ubuntu/lbry.desktop | 12 +++------ packaging/ubuntu/ubuntu_package_setup.sh | 8 +++++- 4 files changed, 42 insertions(+), 30 deletions(-) create mode 100755 packaging/ubuntu/lbry delete mode 100755 packaging/ubuntu/lbry-uri-handler diff --git a/packaging/ubuntu/lbry b/packaging/ubuntu/lbry new file mode 100755 index 000000000..4ad69c838 --- /dev/null +++ b/packaging/ubuntu/lbry @@ -0,0 +1,32 @@ +#!/bin/bash + +set -euo pipefail + +urlencode() { + local LANG=C + local length="${#1}" + for (( i = 0; i < length; i++ )); do + local c="${1:i:1}" + case $c in + [a-zA-Z0-9.~_-]) printf "$c" ;; + *) printf '%%%02X' "'$c" ;; + esac + done +} + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +if [ -z "$(pgrep lbrynet-daemon)" ]; then + echo "running lbrynet-daemon..." + $DIR/lbrynet-daemon 2>&1 >> "$HOME/.lbrynet/daemon.log" & + sleep 3 # let the daemon load before connecting +fi + +ARG=${1:-} + +if [ -z "$ARG" ]; then + URL="" +else + URL="view?name=$(urlencode "$(echo "$ARG" | cut -c 8-)")" +fi + +/usr/bin/xdg-open "http://localhost:5279/$URL" diff --git a/packaging/ubuntu/lbry-uri-handler b/packaging/ubuntu/lbry-uri-handler deleted file mode 100755 index 17d7910ff..000000000 --- a/packaging/ubuntu/lbry-uri-handler +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -urlencode() { - local LANG=C - local length="${#1}" - for (( i = 0; i < length; i++ )); do - local c="${1:i:1}" - case $c in - [a-zA-Z0-9.~_-]) printf "$c" ;; - *) printf '%%%02X' "'$c" ;; - esac - done -} - -ARG=${1:-} -NAME=$(urlencode "$(echo "$ARG" | cut -c 8-)") - -/usr/bin/xdg-open http://localhost:5279/view?name="$NAME" diff --git a/packaging/ubuntu/lbry.desktop b/packaging/ubuntu/lbry.desktop index 7e5363782..33d240950 100644 --- a/packaging/ubuntu/lbry.desktop +++ b/packaging/ubuntu/lbry.desktop @@ -1,5 +1,5 @@ [Desktop Entry] -Version=1.0 +Version=0.2 Name=LBRY # Only KDE 4 seems to use GenericName, so we reuse the KDE strings. # From Ubuntu's language-pack-kde-XX-base packages, version 9.04-20090413. @@ -7,15 +7,9 @@ GenericName=Filesharing # Gnome and KDE 3 uses Comment. Comment=Stream. Share. Earn. #Exec=/usr/bin/xdg-open http://localhost:5279/view?name=%U -Exec=/usr/share/python/lbrynet/bin/lbry-uri-handler %U +Exec=/usr/share/python/lbrynet/bin/lbry %U Terminal=false -Icon= +Icon=/usr/share/python/lbrynet/lbrynet/lbrynet_gui/lbry-dark-icon.ico Type=Application Categories=Network;Internet;Filesharing MimeType=x-scheme-handler/lbry; -X-Ayatana-Desktop-Shortcuts=NewWindow - -[NewWindow Shortcut Group] -Name=New Window -Exec=/home/grin/lbryhandler/testlbry newwindow %U -TargetEnvironment=Unity diff --git a/packaging/ubuntu/ubuntu_package_setup.sh b/packaging/ubuntu/ubuntu_package_setup.sh index 27b13fd1b..4be10c8a7 100755 --- a/packaging/ubuntu/ubuntu_package_setup.sh +++ b/packaging/ubuntu/ubuntu_package_setup.sh @@ -9,6 +9,10 @@ set -euo pipefail BRANCH=${1:-master} +BUILD_DIR="lbry-build-$(date +%Y%m%d-%H%M%S)" +mkdir "$BUILD_DIR" +cd "$BUILD_DIR" + # get the required OS packages sudo add-apt-repository -y ppa:spotify-jyrki/dh-virtualenv sudo apt-get update @@ -49,13 +53,15 @@ function addfile() { echo "$(md5sum "data/$TARGET" | cut -d' ' -f1) $TARGET" >> control/md5sums } PACKAGING_DIR='lbry/packaging/ubuntu' -addfile "$PACKAGING_DIR/lbry-uri-handler" usr/share/python/lbrynet/bin/lbry-uri-handler +addfile "$PACKAGING_DIR/lbry" usr/share/python/lbrynet/bin/lbry addfile "$PACKAGING_DIR/lbry.desktop" usr/share/applications/lbry.desktop #addfile lbry/packaging/ubuntu/lbry-init.conf etc/init/lbry.conf # repackage .deb +sudo chown -R root:root control data tar -cvzf control.tar.gz -C control . tar -cvJf data.tar.xz -C data . +sudo chown root:root debian-binary control.tar.gz data.tar.xz ar r "$PACKAGE" debian-binary control.tar.gz data.tar.xz # TODO: we can append to data.tar instead of extracting it all and recompressing