From a83297c52bd7835a9cc44f5a2c13d9bee16b604d Mon Sep 17 00:00:00 2001 From: Randall Date: Sun, 14 Aug 2022 19:13:50 -0400 Subject: [PATCH] Added Alpine packaging support, fixed packaging woes regarding a bad shebang --- bin/sshync.py | 2 +- bin/sshyp.py | 2 +- bin/sshypRemote.py | 2 +- package.sh | 54 +++++++++++++++++++++++++++++++++------------- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/bin/sshync.py b/bin/sshync.py index 1edf9d3..caae2b5 100755 --- a/bin/sshync.py +++ b/bin/sshync.py @@ -1,4 +1,4 @@ -#!/bin/python3 +#!/usr/bin/env python3 # external modules diff --git a/bin/sshyp.py b/bin/sshyp.py index 881b768..94f5735 100755 --- a/bin/sshyp.py +++ b/bin/sshyp.py @@ -1,4 +1,4 @@ -#!/bin/python3 +#!/usr/bin/env python3 # external modules diff --git a/bin/sshypRemote.py b/bin/sshypRemote.py index 7d1e928..f8440d3 100755 --- a/bin/sshypRemote.py +++ b/bin/sshypRemote.py @@ -1,4 +1,4 @@ -#!/bin/python3 +#!/usr/bin/env python3 # external modules diff --git a/package.sh b/package.sh index 8eac1f3..9fdcf5f 100755 --- a/package.sh +++ b/package.sh @@ -3,12 +3,13 @@ # This script packages sshyp (from source) for various UNIX(-like) environments. # Dependencies (Arch Linux): dpkg (packaging for Debian/Termux), freebsd-pkg (packaging for FreeBSD) # Dependencies (Fedora) (can only package for self): rpmdevtools +# Dependencies (Alpine): xz (not part of a basic installation, needed for generic package creation and unpacking for abuild), alpine-sdk (required to build the .apk file from the generated APKBUILD), bash # NOTE It is recommended to instead use the latest officially packaged and tagged release. echo -e '\nOptions (please enter the number only):' echo -e '\nPackage Formats:\n\n1. Haiku\n2. Debian&Ubuntu Linux\n3. Fedora Linux\n4. FreeBSD\n5. Termux\n6. Generic (used for PKGBUILD/APKBUILD)' -echo -e '\nBuild Scripts:\n\n7. Arch Linux (PKGBUILD)' -echo -e '\nOther:\n\n8. All (generates all distribution packages (excluding Haiku and Fedora, as these must be packaged on their respective distributions) and build scripts)\n' +echo -e '\nBuild Scripts:\n\n7. Arch Linux (PKGBUILD)\n8. Alpine Linux (APKBUILD)' +echo -e '\nOther:\n\n9. All (generates all distribution packages (excluding Haiku, Fedora, and Alpine, as these must be packaged on their respective distributions) and build scripts)\n' read -n 1 -r -p "Distribution: " distro echo -e '\n\nThe value entered in this field will only affect the version reported to the package manager. The latest source is used regardless.\n' @@ -17,7 +18,7 @@ read -r -p "Version number: " version echo -e '\nThe value entered in this field will only affect the revision number for build scripts.\n' read -r -p "Revision number: " revision -if [ "$distro" == "7" ] || [ "$distro" == "8" ]; then +if [ "$distro" == "7" ] || [ "$distro" == "8" ] || [ "$distro" == "9" ]; then echo -e '\nOptions (please enter the number only):' echo -e '\n1. GitHub Release Tag\n2. Local\n' read -r -p "Source (for build scripts): " source @@ -61,6 +62,9 @@ urls { } " > packages/haikutemp/.PackageInfo cp -r bin packages/haikutemp/ + sed -i '1 s/.*/#!\/bin\/env\ python3/' packages/haikutemp/bin/sshync.py + sed -i '1 s/.*/#!\/bin\/env\ python3/' packages/haikutemp/bin/sshyp.py + sed -i '1 s/.*/#!\/bin\/env\ python3/' packages/haikutemp/bin/sshypRemote.py ln -s /bin/sshyp.py packages/haikutemp/bin/sshyp cp -r share/doc/sshyp/ packages/haikutemp/documentation/packages/ cp -r share/licenses/sshyp/ packages/haikutemp/documentation/packages/ @@ -75,7 +79,7 @@ urls { echo -e "\nHaiku packaging complete.\n" fi -if [ "$distro" == "2" ] || [ "$distro" == "8" ]; then +if [ "$distro" == "2" ] || [ "$distro" == "9" ]; then echo -e '\nPackaging for Debian...\n' mkdir -p packages/debiantemp/sshyp_"$version"-"$revision"_all/{DEBIAN,usr/share/man/man1} echo "Package: sshyp @@ -99,7 +103,7 @@ Installed-Size: 185 echo -e "\nDebian packaging complete.\n" fi -if [ "$distro" == "5" ] || [ "$distro" == "8" ]; then +if [ "$distro" == "5" ] || [ "$distro" == "9" ]; then echo -e '\nPackaging for Termux...\n' mkdir -p packages/termuxtemp/sshyp_"$version"-"$revision"_all_termux/{data/data/com.termux/files/usr/share/man/man1,DEBIAN} echo "Package: sshyp @@ -123,7 +127,7 @@ Installed-Size: 185 echo -e "\nTermux packaging complete.\n" fi -if [ "$distro" == "3" ] || [ "$distro" == "4" ] || [ "$distro" == "6" ] || [ "$distro" == "7" ] || [ "$distro" == "8" ]; then +if [ "$distro" == "3" ] || [ "$distro" == "4" ] || [ "$distro" == "6" ] || [ "$distro" == "7" ] || [ "$distro" == "8" ] || [ "$distro" == "9" ]; then echo -e '\nPackaging as generic...\n' mkdir -p packages/generictemp/usr/share/man/man1 cp -r bin packages/generictemp/usr/ @@ -177,11 +181,10 @@ rm -rf ~/rpmbuild echo -e "\nFedora packaging complete.\n" fi -if [ "$distro" == "4" ] || [ "$distro" == "8" ]; then +if [ "$distro" == "4" ] || [ "$distro" == "9" ]; then echo -e '\nPackaging for FreeBSD...\n' mkdir -p packages/FreeBSDtemp/bin tar xf packages/sshyp-"$version".tar.xz -C packages/FreeBSDtemp - ln -s /usr/local/bin/python3 packages/FreeBSDtemp/bin/python3 echo "name: sshyp version: \""$version"\" abi = \"FreeBSD:13:*\"; @@ -207,8 +210,7 @@ prefix: / }, }, " > packages/FreeBSDtemp/+MANIFEST -echo "/bin/python3 -/usr/bin/sshync.py +echo "/usr/bin/sshync.py /usr/bin/sshyp /usr/bin/sshyp.py /usr/bin/sshypRemote.py @@ -221,10 +223,9 @@ rm -rf packages/FreeBSDtemp echo -e "\nFreeBSD packaging complete.\n" fi -if [ "$distro" == "7" ] || [ "$distro" == "8" ]; then +if [ "$distro" == "7" ] || [ "$distro" == "9" ]; then echo -e '\nGenerating PKGBUILD...' echo "# Maintainer: Randall Winkhart - pkgname=sshyp pkgver="$version" pkgrel="$revision" @@ -233,15 +234,38 @@ url='https://github.com/rwinkhart/sshyp' arch=('any') license=('GPL3') depends=(python gnupg openssh xclip wl-clipboard) - source=(\""$source"\") sha512sums=('"$sha512"') package() { - tar xf sshyp-"\"\$pkgver\"".tar.xz -C "\"\${pkgdir}\"" - } " > packages/PKGBUILD echo -e "\nPKGBUILD generated.\n" fi + +if [ "$distro" == "8" ] || [ "$distro" == "9" ]; then + echo -e '\nGenerating APKBUILD...' + echo "# Maintainer: Randall Winkhart +pkgname=sshyp +pkgver="$version" +pkgrel="$revision" +pkgdesc='A light-weight, self-hosted, synchronized password manager' +options=!check +url='https://github.com/rwinkhart/sshyp' +arch='noarch' +license='GPL-3.0-or-later' +depends='python3 gnupg openssh xclip wl-clipboard' +source=\""$source"\" + +package() { + mkdir -p "\"\$pkgdir\"" + cp -r "\"\$srcdir/usr/"\" "\"\$pkgdir\"" +} + +sha512sums=\" +"$sha512' 'sshyp-\"\$pkgver\".tar.xz" +\" +" > packages/APKBUILD + echo -e "\nAPKBUILD generated.\n" +fi