From d716f00fde22f4db67c99a95756fc513cc2e5cd9 Mon Sep 17 00:00:00 2001 From: RedProkofiev Date: Fri, 13 Oct 2023 15:54:15 +0000 Subject: [PATCH 01/11] FPM call structure --- scripts/ssm-build.sh | 106 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100755 scripts/ssm-build.sh diff --git a/scripts/ssm-build.sh b/scripts/ssm-build.sh new file mode 100755 index 00000000..40de62d1 --- /dev/null +++ b/scripts/ssm-build.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +# Apel-SSM Build Script 2.0: FPM edition +# Adapted from the Debian only build script, now with RPM! +# @Author: Nicholas Whyatt (RedProkofiev@github.com) + +set -e + +usage() { + echo "Usage: $0 (deb | rpm) [options]" + echo -e "Build script for Apel-SSM.\n" + echo " -h Displays help." + echo " -s Directory of source files. Defaults to /debbuild/source or SOME RPM DIR." + echo -e " -b Directory of build files. Defaults to /debbuild/build or SOME RPM DIR.\n" 1>&2; + exit 1; +} + +# cheap python hack! +# if ! python3 -c 'import sys; assert sys.version_info >= (3,6)' > /dev/null; then +# export PYTHON_VERSION=`python -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}".format(*version))' +# elif ! python2 -c 'import sys; assert sys.version_info >= (3,6)' > /dev/null; then + +SOURCE_ASSIGNED=0 +BUILD_ASSIGNED=0 + +# Configurable options +while getopts ":hs:b:" o; do + case "${o}" in + h) echo "SSM Help" + usage; + ;; + s) s=${OPTARG} + SOURCE_DIR=$s + SOURCE_ASSIGNED=1 + ;; + b) b=${OPTARG} + BUILD_DIR=$b + BUILD_ASSIGNED=1 + ;; + *) usage; + ;; + esac +done +shift $((OPTIND-1)) + +# Check how any arguments there are +if [ "$#" -ne 4 ]; then + echo "Expected 4 arguments, $# given." + usage; +fi + +PACK_TYPE=$1 +VERSION=$2 +ITERATION=$3 +PYTHON_ROOT_DIR=$4 # i.e. /usr/lib/python3.6 + +# TODO: Replace rpm directories with their sensible equivalents +# It ain't pretty, but it is readable and it gets the job done +# LIB_EXTENSION is the install dir for python lib files, and is system dependent +if [[ "$PACK_TYPE" = "deb" ]]; then + LIB_EXTENSION="/dist-packages" + if [[ "$SOURCE_ASSIGNED" = 0 ]]; then + SOURCE_DIR=~/debbuild/source + fi + if [[ "$BUILD_ASSIGNED" = 0 ]]; then + BUILD_DIR=~/debbuild/build + fi +elif [[ "$PACK_TYPE" = "rpm" ]]; then + LIB_EXTENSION="/site-packages" + if [[ "$SOURCE_ASSIGNED" = 0 ]]; then + SOURCE_DIR=~/something/rpm + fi + if [[ "$BUILD_ASSIGNED" = 0 ]]; then + BUILD_DIR=~/somethingalso/rpm + fi +else # If package type is neither deb nor rpm, show an error message and exit + echo "$0 currently only supports 'deb' and 'rpm' packages." + usage; +fi + +# Testing +echo $LIB_EXTENSION +echo $SOURCE_DIR +echo $BUILD_DIR + +# # Create SSM and DEB dir (if not present) +# mkdir -p $SOURCE_DIR +# mkdir -p $BUILD_DIR + +# # Clean up any previous build +# rm -rf $SOURCE_DIR/* +# rm -rf $BUILD_DIR/* + +# # Get and extract the source +# TAR_FILE=${VERSION}-${ITERATION}.tar.gz +# TAR_URL=https://github.com/apel/ssm/archive/$TAR_FILE +# wget --no-check-certificate $TAR_URL -O $TAR_FILE +# tar xvf $TAR_FILE -C $SOURCE_DIR +# rm -f $TAR_FILE + +# Get specific python version +# Main distinction is 2 vs 3 but also check for 3.5 or under or under 2.7 + +PY_VERSION=$(basename $PYTHON_ROOT_DIR) +PY_NUM=${PY_VERSION#python} +echo $PY_NUM From 1c12984c3c044c49cc91a410be9bc3a782f16ad0 Mon Sep 17 00:00:00 2001 From: RedProkofiev Date: Wed, 1 Nov 2023 15:42:05 +0000 Subject: [PATCH 02/11] Detecting versions Structuring --- scripts/ssm-build.sh | 71 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/scripts/ssm-build.sh b/scripts/ssm-build.sh index 40de62d1..c220e7bd 100755 --- a/scripts/ssm-build.sh +++ b/scripts/ssm-build.sh @@ -104,3 +104,74 @@ echo $BUILD_DIR PY_VERSION=$(basename $PYTHON_ROOT_DIR) PY_NUM=${PY_VERSION#python} echo $PY_NUM + +# One fpm call for python 2, one for python 3 +# Check for each based on minimum versioning +# May have to vary by debian and RPM too :/ +# add in commands? + +# Create two sections, tack them together, render with eval command +# Section 1: Python Version specific +# Section 2: RPM or DEB? +# Eval + +if (( ${PY_NUM:0:1} == 2 )) ; then + if (( ${PY_NUM:2:3} < 7 )) ; then # or version is later than 4.0.0 + echo "Python version is insufficient, you supplied $PY_NUM when you need 2.7. Python 2 will be removed in 4.0.0." + usage; + fi + # py2 FPM call CURRENTLY DEBIAN + # adapt for RPM and for generalism + # eval + + echo "Building $VERSION iteration $ITERATION for Python $PY_NUM as $PACK_TYPE." + + + fpm -s python -t deb \ + -n apel-ssm \ + -v $VERSION \ + --iteration $ITERATION \ + -m "Apel Administrators " \ + --description "Secure Stomp Messenger (SSM)." \ + --no-auto-depends \ + --depends python2.7 \ + --depends python-pip \ + --depends 'python-stomp < 5.0.0' \ + --depends python-ldap \ + --depends libssl-dev \ + --depends libsasl2-dev \ + --depends openssl \ + --deb-changelog $SOURCE_DIR/ssm-$TAG/CHANGELOG \ + --python-install-bin /usr/bin \ + --python-install-lib $PYTHON_INSTALL_LIB \ + --exclude *.pyc \ + --package $BUILD_DIR \ + $SOURCE_DIR/ssm-$TAG/setup.py + +elif (( ${PY_NUM:0:1} == 3 )) ; then + if (( ${PY_NUM:2:3} < 6 )) ; then + echo "Python version is insufficient, you supplied $PY_NUM when you need above 3.5." + usage; + fi + #py3 fpm call + echo "Building $VERSION iteration $ITERATION for Python $PY_NUM as $PACK_TYPE." + +fi + +# Create pleaserun command +# Section 1: RPM or DEB ? +# Don't need to eval, just change deb + +eval build_package + +fpm -s pleaserun -t $PACK_TYPE \ + -n apel-ssm-service \ + -v $VERSION \ + --iteration $ITERATION \ + -m "Apel Administrators " \ + --description "Secure Stomp Messenger (SSM) Service Daemon files." \ + --architecture all \ + --no-auto-depends \ + --depends apel-ssm \ + --package $BUILD_DIR \ + /usr/bin/ssmreceive From dd5de7908f37bab7a0637649cecaaa8b1522a7bc Mon Sep 17 00:00:00 2001 From: RedProkofiev Date: Thu, 2 Nov 2023 16:41:12 +0000 Subject: [PATCH 03/11] Workable structure --- scripts/ssm-build.sh | 107 ++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/scripts/ssm-build.sh b/scripts/ssm-build.sh index c220e7bd..0a42313b 100755 --- a/scripts/ssm-build.sh +++ b/scripts/ssm-build.sh @@ -98,80 +98,83 @@ echo $BUILD_DIR # tar xvf $TAR_FILE -C $SOURCE_DIR # rm -f $TAR_FILE -# Get specific python version -# Main distinction is 2 vs 3 but also check for 3.5 or under or under 2.7 - +# Get supplied Python version PY_VERSION=$(basename $PYTHON_ROOT_DIR) PY_NUM=${PY_VERSION#python} echo $PY_NUM -# One fpm call for python 2, one for python 3 -# Check for each based on minimum versioning -# May have to vary by debian and RPM too :/ -# add in commands? -# Create two sections, tack them together, render with eval command -# Section 1: Python Version specific -# Section 2: RPM or DEB? -# Eval +# Universal FPM Call +FPM_CORE="fpm -s python -t $PACK_TYPE \ + -n apel-ssm \ + -v $VERSION \ + --iteration $ITERATION \ + -m \"Apel Administrators \" \ + --description \"Secure Stomp Messenger (SSM).\" \ + --no-auto-depends \ " + +# Python Evaluation +# Python 2 if (( ${PY_NUM:0:1} == 2 )) ; then if (( ${PY_NUM:2:3} < 7 )) ; then # or version is later than 4.0.0 echo "Python version is insufficient, you supplied $PY_NUM when you need 2.7. Python 2 will be removed in 4.0.0." usage; fi - # py2 FPM call CURRENTLY DEBIAN - # adapt for RPM and for generalism - # eval - echo "Building $VERSION iteration $ITERATION for Python $PY_NUM as $PACK_TYPE." + FPM_PYTHON="--depends python2.7 \ + --depends python-pip \ + --depends 'python-stomp < 5.0.0' \ + --depends python-ldap \ + --depends libssl-dev \ + --depends libsasl2-dev \ + --depends openssl \ " - fpm -s python -t deb \ - -n apel-ssm \ - -v $VERSION \ - --iteration $ITERATION \ - -m "Apel Administrators " \ - --description "Secure Stomp Messenger (SSM)." \ - --no-auto-depends \ - --depends python2.7 \ - --depends python-pip \ - --depends 'python-stomp < 5.0.0' \ - --depends python-ldap \ - --depends libssl-dev \ - --depends libsasl2-dev \ - --depends openssl \ - --deb-changelog $SOURCE_DIR/ssm-$TAG/CHANGELOG \ - --python-install-bin /usr/bin \ - --python-install-lib $PYTHON_INSTALL_LIB \ - --exclude *.pyc \ - --package $BUILD_DIR \ - $SOURCE_DIR/ssm-$TAG/setup.py - +# Python 3 elif (( ${PY_NUM:0:1} == 3 )) ; then if (( ${PY_NUM:2:3} < 6 )) ; then echo "Python version is insufficient, you supplied $PY_NUM when you need above 3.5." usage; fi - #py3 fpm call echo "Building $VERSION iteration $ITERATION for Python $PY_NUM as $PACK_TYPE." -fi + # python-stomp < 5.0.0 to python-stomp + # everything else is chill + FPM_PYTHON="--depends python3.6 \ + --depends python-pip3 \ + --depends 'python-stomp' \ + --depends python-ldap \ + --depends libssl-dev \ + --depends libsasl2-dev \ + --depends openssl \ " -# Create pleaserun command -# Section 1: RPM or DEB ? -# Don't need to eval, just change deb +fi -eval build_package -fpm -s pleaserun -t $PACK_TYPE \ - -n apel-ssm-service \ - -v $VERSION \ - --iteration $ITERATION \ - -m "Apel Administrators " \ - --description "Secure Stomp Messenger (SSM) Service Daemon files." \ - --architecture all \ - --no-auto-depends \ - --depends apel-ssm \ +# FPM Version Specific End +# Change pythoninstall lib? +FPM_VERSION="--$PACK_TYPE-changelog $SOURCE_DIR/ssm-$VERSION-$ITERATION/CHANGELOG \ + --python-install-bin /usr/bin \ + --python-install-lib $PYTHON_ROOT_DIR$LIB_EXTENSION \ + --exclude *.pyc \ --package $BUILD_DIR \ - /usr/bin/ssmreceive + $SOURCE_DIR/ssm-$VERSION-$ITERATION/setup.py" + + +BUILD_PACKAGE=${FPM_CORE}${FPM_PYTHON}${FPM_VERSION} +# eval $BUILD_PACKAGE +echo $BUILD_PACKAGE + + +# fpm -s pleaserun -t $PACK_TYPE \ +# -n apel-ssm-service \ +# -v $VERSION \ +# --iteration $ITERATION \ +# -m "Apel Administrators " \ +# --description "Secure Stomp Messenger (SSM) Service Daemon files." \ +# --architecture all \ +# --no-auto-depends \ +# --depends apel-ssm \ +# --package $BUILD_DIR \ +# /usr/bin/ssmreceive From e3e1b4caafc1c42ed943b4b955dc1f4092cd31e2 Mon Sep 17 00:00:00 2001 From: RedProkofiev Date: Thu, 2 Nov 2023 17:38:00 +0000 Subject: [PATCH 04/11] Verbose flag added --- scripts/ssm-build.sh | 55 ++++++++++++++++++++++++-------------------- setup.py | 9 +++++--- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/scripts/ssm-build.sh b/scripts/ssm-build.sh index 0a42313b..fc4c233c 100755 --- a/scripts/ssm-build.sh +++ b/scripts/ssm-build.sh @@ -24,7 +24,7 @@ SOURCE_ASSIGNED=0 BUILD_ASSIGNED=0 # Configurable options -while getopts ":hs:b:" o; do +while getopts ":hs:b:v" o; do case "${o}" in h) echo "SSM Help" usage; @@ -37,6 +37,9 @@ while getopts ":hs:b:" o; do BUILD_DIR=$b BUILD_ASSIGNED=1 ;; + v) v=${OPTARG} + VERBOSE="--verbose " \ + ;; *) usage; ;; esac @@ -68,35 +71,32 @@ if [[ "$PACK_TYPE" = "deb" ]]; then elif [[ "$PACK_TYPE" = "rpm" ]]; then LIB_EXTENSION="/site-packages" if [[ "$SOURCE_ASSIGNED" = 0 ]]; then - SOURCE_DIR=~/something/rpm + SOURCE_DIR=~/rpmbuild/SOURCES fi if [[ "$BUILD_ASSIGNED" = 0 ]]; then - BUILD_DIR=~/somethingalso/rpm + BUILD_DIR=~/rpmbuild/BUILD fi else # If package type is neither deb nor rpm, show an error message and exit echo "$0 currently only supports 'deb' and 'rpm' packages." usage; fi -# Testing -echo $LIB_EXTENSION -echo $SOURCE_DIR -echo $BUILD_DIR -# # Create SSM and DEB dir (if not present) -# mkdir -p $SOURCE_DIR -# mkdir -p $BUILD_DIR +# Directory cleaning and repository management +# Create SSM and DEB dir (if not present) +mkdir -p $SOURCE_DIR +mkdir -p $BUILD_DIR -# # Clean up any previous build -# rm -rf $SOURCE_DIR/* -# rm -rf $BUILD_DIR/* +# Clean up any previous build +rm -rf $SOURCE_DIR/* +rm -rf $BUILD_DIR/* -# # Get and extract the source -# TAR_FILE=${VERSION}-${ITERATION}.tar.gz -# TAR_URL=https://github.com/apel/ssm/archive/$TAR_FILE -# wget --no-check-certificate $TAR_URL -O $TAR_FILE -# tar xvf $TAR_FILE -C $SOURCE_DIR -# rm -f $TAR_FILE +# Get and extract the source +TAR_FILE=${VERSION}-${ITERATION}.tar.gz +TAR_URL=https://github.com/apel/ssm/archive/$TAR_FILE +wget --no-check-certificate $TAR_URL -O $TAR_FILE +tar xvf $TAR_FILE -C $SOURCE_DIR +rm -f $TAR_FILE # Get supplied Python version PY_VERSION=$(basename $PYTHON_ROOT_DIR) @@ -111,10 +111,9 @@ FPM_CORE="fpm -s python -t $PACK_TYPE \ --iteration $ITERATION \ -m \"Apel Administrators \" \ --description \"Secure Stomp Messenger (SSM).\" \ - --no-auto-depends \ " + --no-auto-depends " \ -# Python Evaluation # Python 2 if (( ${PY_NUM:0:1} == 2 )) ; then if (( ${PY_NUM:2:3} < 7 )) ; then # or version is later than 4.0.0 @@ -129,7 +128,7 @@ if (( ${PY_NUM:0:1} == 2 )) ; then --depends python-ldap \ --depends libssl-dev \ --depends libsasl2-dev \ - --depends openssl \ " + --depends openssl " \ # Python 3 elif (( ${PY_NUM:0:1} == 3 )) ; then @@ -147,13 +146,17 @@ elif (( ${PY_NUM:0:1} == 3 )) ; then --depends python-ldap \ --depends libssl-dev \ --depends libsasl2-dev \ - --depends openssl \ " + --depends openssl " \ fi # FPM Version Specific End # Change pythoninstall lib? +# is it the darned changelog? Changelog source dir may be completely off.s +# Place changelog in specs. + + FPM_VERSION="--$PACK_TYPE-changelog $SOURCE_DIR/ssm-$VERSION-$ITERATION/CHANGELOG \ --python-install-bin /usr/bin \ --python-install-lib $PYTHON_ROOT_DIR$LIB_EXTENSION \ @@ -162,9 +165,11 @@ FPM_VERSION="--$PACK_TYPE-changelog $SOURCE_DIR/ssm-$VERSION-$ITERATION/CHANGELO $SOURCE_DIR/ssm-$VERSION-$ITERATION/setup.py" -BUILD_PACKAGE=${FPM_CORE}${FPM_PYTHON}${FPM_VERSION} -# eval $BUILD_PACKAGE +# Spaces betwixt verbose and FPM_VERSION for --rpm-changelog, space here command not found renders fpm_version as sep command +# probably bash string handling issue, add handled string +BUILD_PACKAGE=${FPM_CORE}${FPM_PYTHON}${VERBOSE}${FPM_VERSION} echo $BUILD_PACKAGE +eval $BUILD_PACKAGE # fpm -s pleaserun -t $PACK_TYPE \ diff --git a/setup.py b/setup.py index 8c5f84d1..d5cdd70e 100644 --- a/setup.py +++ b/setup.py @@ -51,11 +51,14 @@ def main(): download_url='https://github.com/apel/ssm/releases', license='Apache License, Version 2.0', install_requires=[ - 'stomp.py<5.0.0', 'python-ldap<3.4.0', 'setuptools', + 'stomp.py<5.0.0', + 'python-ldap<3.4.0', + 'setuptools', + 'PyOpenSSL', ], extras_require={ - 'AMS': ['argo-ams-library'], - 'daemon': ['python-daemon<=2.3.0'], + 'AMS': ['argo-ams-library', 'certifi<2020.4.5.2', ], + 'daemon': ['python-daemon<=2.3.0', ], 'dirq': ['dirq'], }, packages=find_packages(exclude=['bin', 'test']), From 8e2a3083891d78258ba18a7e3a84ce0ed53caf7b Mon Sep 17 00:00:00 2001 From: RedProkofiev Date: Fri, 17 Nov 2023 11:48:00 +0000 Subject: [PATCH 05/11] Change variable names --- scripts/ssm-build.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/ssm-build.sh b/scripts/ssm-build.sh index fc4c233c..a0309f54 100755 --- a/scripts/ssm-build.sh +++ b/scripts/ssm-build.sh @@ -93,7 +93,7 @@ rm -rf $BUILD_DIR/* # Get and extract the source TAR_FILE=${VERSION}-${ITERATION}.tar.gz -TAR_URL=https://github.com/apel/ssm/archive/$TAR_FILE +TAR_URL=https://github.com/RedProkofiev/ssm/archive/$TAR_FILE wget --no-check-certificate $TAR_URL -O $TAR_FILE tar xvf $TAR_FILE -C $SOURCE_DIR rm -f $TAR_FILE @@ -157,7 +157,7 @@ fi # Place changelog in specs. -FPM_VERSION="--$PACK_TYPE-changelog $SOURCE_DIR/ssm-$VERSION-$ITERATION/CHANGELOG \ +PACKAGE_VERSION="--$PACK_TYPE-changelog $SOURCE_DIR/ssm-$VERSION-$ITERATION/CHANGELOG \ --python-install-bin /usr/bin \ --python-install-lib $PYTHON_ROOT_DIR$LIB_EXTENSION \ --exclude *.pyc \ @@ -165,11 +165,11 @@ FPM_VERSION="--$PACK_TYPE-changelog $SOURCE_DIR/ssm-$VERSION-$ITERATION/CHANGELO $SOURCE_DIR/ssm-$VERSION-$ITERATION/setup.py" -# Spaces betwixt verbose and FPM_VERSION for --rpm-changelog, space here command not found renders fpm_version as sep command +# Spaces betwixt verbose and package_version for --rpm-changelog, space here command not found renders package_version as sep command # probably bash string handling issue, add handled string -BUILD_PACKAGE=${FPM_CORE}${FPM_PYTHON}${VERBOSE}${FPM_VERSION} -echo $BUILD_PACKAGE -eval $BUILD_PACKAGE +BUILD_PACKAGE_COMMAND=${FPM_CORE}${FPM_PYTHON}${VERBOSE}${PACKAGE_VERSION} +echo $BUILD_PACKAGE_COMMAND +eval $BUILD_PACKAGE_COMMAND # fpm -s pleaserun -t $PACK_TYPE \ From c64dd80d3034a613ac7c06a0f7c811deb39833da Mon Sep 17 00:00:00 2001 From: RedProkofiev Date: Wed, 13 Dec 2023 14:40:45 +0000 Subject: [PATCH 06/11] Fixing import json error with addition of --python-bin flag --- scripts/ssm-build.sh | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/scripts/ssm-build.sh b/scripts/ssm-build.sh index a0309f54..01be343e 100755 --- a/scripts/ssm-build.sh +++ b/scripts/ssm-build.sh @@ -10,6 +10,7 @@ usage() { echo "Usage: $0 (deb | rpm) [options]" echo -e "Build script for Apel-SSM.\n" echo " -h Displays help." + echo " -v Verbose FPM output." echo " -s Directory of source files. Defaults to /debbuild/source or SOME RPM DIR." echo -e " -b Directory of build files. Defaults to /debbuild/build or SOME RPM DIR.\n" 1>&2; exit 1; @@ -22,9 +23,10 @@ usage() { SOURCE_ASSIGNED=0 BUILD_ASSIGNED=0 +BIN_DIR="/usr/bin/python3.8 " \ # Configurable options -while getopts ":hs:b:v" o; do +while getopts ":hs:b:v:e" o; do case "${o}" in h) echo "SSM Help" usage; @@ -40,6 +42,9 @@ while getopts ":hs:b:v" o; do v) v=${OPTARG} VERBOSE="--verbose " \ ;; + e) e=${OPTARG} + BIN_DIR="$b " \ + ;; *) usage; ;; esac @@ -93,7 +98,7 @@ rm -rf $BUILD_DIR/* # Get and extract the source TAR_FILE=${VERSION}-${ITERATION}.tar.gz -TAR_URL=https://github.com/RedProkofiev/ssm/archive/$TAR_FILE +TAR_URL=https://github.com/apel/ssm/archive/$TAR_FILE wget --no-check-certificate $TAR_URL -O $TAR_FILE tar xvf $TAR_FILE -C $SOURCE_DIR rm -f $TAR_FILE @@ -150,6 +155,9 @@ elif (( ${PY_NUM:0:1} == 3 )) ; then fi +if [ "$PACK_TYPE" == "deb" ]; then + FPM_PYTHON="${FPM_PYTHON} --python-bin ${BIN_DIR}" +fi # FPM Version Specific End # Change pythoninstall lib? @@ -172,14 +180,14 @@ echo $BUILD_PACKAGE_COMMAND eval $BUILD_PACKAGE_COMMAND -# fpm -s pleaserun -t $PACK_TYPE \ -# -n apel-ssm-service \ -# -v $VERSION \ -# --iteration $ITERATION \ -# -m "Apel Administrators " \ -# --description "Secure Stomp Messenger (SSM) Service Daemon files." \ -# --architecture all \ -# --no-auto-depends \ -# --depends apel-ssm \ -# --package $BUILD_DIR \ -# /usr/bin/ssmreceive +fpm -s pleaserun -t $PACK_TYPE \ + -n apel-ssm-service \ + -v $VERSION \ + --iteration $ITERATION \ + -m "Apel Administrators " \ + --description "Secure Stomp Messenger (SSM) Service Daemon files." \ + --architecture all \ + --no-auto-depends \ + --depends apel-ssm \ + --package $BUILD_DIR \ + /usr/bin/ssmreceive From 11907d48ce16b50103569f0c2ccb38215fd6e19e Mon Sep 17 00:00:00 2001 From: RedProkofiev Date: Fri, 12 Jan 2024 11:39:01 +0000 Subject: [PATCH 07/11] Build/pleaserun --- scripts/{ssm-build.sh => ssm-build-dual.sh} | 106 +++++++------------- 1 file changed, 35 insertions(+), 71 deletions(-) rename scripts/{ssm-build.sh => ssm-build-dual.sh} (60%) diff --git a/scripts/ssm-build.sh b/scripts/ssm-build-dual.sh similarity index 60% rename from scripts/ssm-build.sh rename to scripts/ssm-build-dual.sh index 01be343e..233475e8 100755 --- a/scripts/ssm-build.sh +++ b/scripts/ssm-build-dual.sh @@ -4,7 +4,9 @@ # Adapted from the Debian only build script, now with RPM! # @Author: Nicholas Whyatt (RedProkofiev@github.com) -set -e +# Script runs well with FPM 1.14.2 on ruby 2.7.1, setuptools 51.3.3 on RHEL and Deb platforms + +set -ex usage() { echo "Usage: $0 (deb | rpm) [options]" @@ -16,17 +18,11 @@ usage() { exit 1; } -# cheap python hack! -# if ! python3 -c 'import sys; assert sys.version_info >= (3,6)' > /dev/null; then -# export PYTHON_VERSION=`python -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}".format(*version))' -# elif ! python2 -c 'import sys; assert sys.version_info >= (3,6)' > /dev/null; then - SOURCE_ASSIGNED=0 BUILD_ASSIGNED=0 -BIN_DIR="/usr/bin/python3.8 " \ # Configurable options -while getopts ":hs:b:v:e" o; do +while getopts ":hs:b:v" o; do case "${o}" in h) echo "SSM Help" usage; @@ -40,10 +36,7 @@ while getopts ":hs:b:v:e" o; do BUILD_ASSIGNED=1 ;; v) v=${OPTARG} - VERBOSE="--verbose " \ - ;; - e) e=${OPTARG} - BIN_DIR="$b " \ + VERBOSE="--verbose " ;; *) usage; ;; @@ -62,9 +55,6 @@ VERSION=$2 ITERATION=$3 PYTHON_ROOT_DIR=$4 # i.e. /usr/lib/python3.6 -# TODO: Replace rpm directories with their sensible equivalents -# It ain't pretty, but it is readable and it gets the job done -# LIB_EXTENSION is the install dir for python lib files, and is system dependent if [[ "$PACK_TYPE" = "deb" ]]; then LIB_EXTENSION="/dist-packages" if [[ "$SOURCE_ASSIGNED" = 0 ]]; then @@ -86,7 +76,6 @@ else # If package type is neither deb nor rpm, show an error message and exit usage; fi - # Directory cleaning and repository management # Create SSM and DEB dir (if not present) mkdir -p $SOURCE_DIR @@ -98,7 +87,7 @@ rm -rf $BUILD_DIR/* # Get and extract the source TAR_FILE=${VERSION}-${ITERATION}.tar.gz -TAR_URL=https://github.com/apel/ssm/archive/$TAR_FILE +TAR_URL=https://github.com/RedProkofiev/ssm/archive/$TAR_FILE wget --no-check-certificate $TAR_URL -O $TAR_FILE tar xvf $TAR_FILE -C $SOURCE_DIR rm -f $TAR_FILE @@ -108,86 +97,61 @@ PY_VERSION=$(basename $PYTHON_ROOT_DIR) PY_NUM=${PY_VERSION#python} echo $PY_NUM - # Universal FPM Call -FPM_CORE="fpm -s python -t $PACK_TYPE \ +FPM_CORE="fpm -s python \ + -t $PACK_TYPE \ -n apel-ssm \ -v $VERSION \ --iteration $ITERATION \ -m \"Apel Administrators \" \ --description \"Secure Stomp Messenger (SSM).\" \ - --no-auto-depends " \ - + --no-auto-depends " -# Python 2 -if (( ${PY_NUM:0:1} == 2 )) ; then - if (( ${PY_NUM:2:3} < 7 )) ; then # or version is later than 4.0.0 - echo "Python version is insufficient, you supplied $PY_NUM when you need 2.7. Python 2 will be removed in 4.0.0." - usage; - fi +if [[ ${PY_NUM:0:1} == "3" ]]; then echo "Building $VERSION iteration $ITERATION for Python $PY_NUM as $PACK_TYPE." - FPM_PYTHON="--depends python2.7 \ - --depends python-pip \ - --depends 'python-stomp < 5.0.0' \ + # python-stomp < 5.0.0 to python-stomp, python to python3/pip3 + # edited python-pip3 to python-pip + FPM_PYTHON="--depends python3 \ + --depends python-pip3 \ + --depends 'python-stomp' \ --depends python-ldap \ --depends libssl-dev \ --depends libsasl2-dev \ - --depends openssl " \ + --depends openssl " -# Python 3 -elif (( ${PY_NUM:0:1} == 3 )) ; then - if (( ${PY_NUM:2:3} < 6 )) ; then - echo "Python version is insufficient, you supplied $PY_NUM when you need above 3.5." - usage; - fi +elif [[ ${PY_NUM:0:1} == "2" ]]; then echo "Building $VERSION iteration $ITERATION for Python $PY_NUM as $PACK_TYPE." - # python-stomp < 5.0.0 to python-stomp - # everything else is chill - FPM_PYTHON="--depends python3.6 \ - --depends python-pip3 \ - --depends 'python-stomp' \ + FPM_PYTHON="--depends python2.7 \ + --depends python-pip \ + --depends 'python-stomp < 5.0.0' \ --depends python-ldap \ --depends libssl-dev \ --depends libsasl2-dev \ - --depends openssl " \ - -fi - -if [ "$PACK_TYPE" == "deb" ]; then - FPM_PYTHON="${FPM_PYTHON} --python-bin ${BIN_DIR}" + --depends openssl " fi -# FPM Version Specific End -# Change pythoninstall lib? -# is it the darned changelog? Changelog source dir may be completely off.s -# Place changelog in specs. - - +# python-bin from python-install-bin PACKAGE_VERSION="--$PACK_TYPE-changelog $SOURCE_DIR/ssm-$VERSION-$ITERATION/CHANGELOG \ - --python-install-bin /usr/bin \ + --python-bin /usr/bin/$PY_VERSION \ --python-install-lib $PYTHON_ROOT_DIR$LIB_EXTENSION \ --exclude *.pyc \ --package $BUILD_DIR \ $SOURCE_DIR/ssm-$VERSION-$ITERATION/setup.py" - -# Spaces betwixt verbose and package_version for --rpm-changelog, space here command not found renders package_version as sep command -# probably bash string handling issue, add handled string BUILD_PACKAGE_COMMAND=${FPM_CORE}${FPM_PYTHON}${VERBOSE}${PACKAGE_VERSION} -echo $BUILD_PACKAGE_COMMAND -eval $BUILD_PACKAGE_COMMAND - +echo "$BUILD_PACKAGE_COMMAND" +eval "$BUILD_PACKAGE_COMMAND" fpm -s pleaserun -t $PACK_TYPE \ - -n apel-ssm-service \ - -v $VERSION \ - --iteration $ITERATION \ - -m "Apel Administrators " \ - --description "Secure Stomp Messenger (SSM) Service Daemon files." \ - --architecture all \ - --no-auto-depends \ - --depends apel-ssm \ - --package $BUILD_DIR \ - /usr/bin/ssmreceive +-n apel-ssm-service \ +-v $VERSION \ +--iteration $ITERATION \ +-m "Apel Administrators " \ +--description "Secure Stomp Messenger (SSM) Service Daemon files." \ +--architecture all \ +--no-auto-depends \ +--depends apel-ssm \ +--package $BUILD_DIR \ +/usr/bin/ssmreceive From 89ed0edf241c8ff7ccfc804fb5b8df5c997b3b6c Mon Sep 17 00:00:00 2001 From: RedProkofiev Date: Wed, 17 Jan 2024 10:10:49 +0000 Subject: [PATCH 08/11] Adding documentation, removing test coordinates, modifying help message --- scripts/ssm-build-dual.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/ssm-build-dual.sh b/scripts/ssm-build-dual.sh index 233475e8..b39baa51 100755 --- a/scripts/ssm-build-dual.sh +++ b/scripts/ssm-build-dual.sh @@ -5,11 +5,17 @@ # @Author: Nicholas Whyatt (RedProkofiev@github.com) # Script runs well with FPM 1.14.2 on ruby 2.7.1, setuptools 51.3.3 on RHEL and Deb platforms +# Download ruby (if you're locked to 2.5, use RVM) and then run: +# sudo gem install fpm -v 1.14.2 +# ./ssm-build-dual.sh (deb | rpm) e.g. +# ./ssm-build.dual.sh deb 3.4.0 1 /usr/lib/python3.6 +# For SSM 3.4.0 and up. Versions before that would technically work, but the changelog +# then was in a Debian format that doesn't parse and fails hard if you want to build RPM. -set -ex +set -e usage() { - echo "Usage: $0 (deb | rpm) [options]" + echo "[options] Usage: $0 (deb | rpm) " echo -e "Build script for Apel-SSM.\n" echo " -h Displays help." echo " -v Verbose FPM output." @@ -18,6 +24,7 @@ usage() { exit 1; } +# Bool flags to prevent automatic overwrite of input SOURCE_ASSIGNED=0 BUILD_ASSIGNED=0 @@ -55,6 +62,7 @@ VERSION=$2 ITERATION=$3 PYTHON_ROOT_DIR=$4 # i.e. /usr/lib/python3.6 +# Alter library, build and source directories depending on the package if [[ "$PACK_TYPE" = "deb" ]]; then LIB_EXTENSION="/dist-packages" if [[ "$SOURCE_ASSIGNED" = 0 ]]; then @@ -87,7 +95,7 @@ rm -rf $BUILD_DIR/* # Get and extract the source TAR_FILE=${VERSION}-${ITERATION}.tar.gz -TAR_URL=https://github.com/RedProkofiev/ssm/archive/$TAR_FILE +TAR_URL=https://github.com/apel/ssm/archive/$TAR_FILE wget --no-check-certificate $TAR_URL -O $TAR_FILE tar xvf $TAR_FILE -C $SOURCE_DIR rm -f $TAR_FILE @@ -107,6 +115,7 @@ FPM_CORE="fpm -s python \ --description \"Secure Stomp Messenger (SSM).\" \ --no-auto-depends " +# Simple Python filter for version specific FPM if [[ ${PY_NUM:0:1} == "3" ]]; then echo "Building $VERSION iteration $ITERATION for Python $PY_NUM as $PACK_TYPE." @@ -132,7 +141,7 @@ elif [[ ${PY_NUM:0:1} == "2" ]]; then --depends openssl " fi -# python-bin from python-install-bin +# python-bin must always be specified in modern linux PACKAGE_VERSION="--$PACK_TYPE-changelog $SOURCE_DIR/ssm-$VERSION-$ITERATION/CHANGELOG \ --python-bin /usr/bin/$PY_VERSION \ --python-install-lib $PYTHON_ROOT_DIR$LIB_EXTENSION \ @@ -140,10 +149,11 @@ PACKAGE_VERSION="--$PACK_TYPE-changelog $SOURCE_DIR/ssm-$VERSION-$ITERATION/CHAN --package $BUILD_DIR \ $SOURCE_DIR/ssm-$VERSION-$ITERATION/setup.py" +# Construct and evaluate the primary FPM call BUILD_PACKAGE_COMMAND=${FPM_CORE}${FPM_PYTHON}${VERBOSE}${PACKAGE_VERSION} -echo "$BUILD_PACKAGE_COMMAND" eval "$BUILD_PACKAGE_COMMAND" +# When installed, use pleaserun to perform system specific service setup fpm -s pleaserun -t $PACK_TYPE \ -n apel-ssm-service \ -v $VERSION \ From f7ee9b4d3beb6bfedd049e752fc770d4ef680148 Mon Sep 17 00:00:00 2001 From: RedProkofiev Date: Thu, 18 Jan 2024 09:43:21 +0000 Subject: [PATCH 09/11] Fix code quality issues --- scripts/ssm-build-dual.sh | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/scripts/ssm-build-dual.sh b/scripts/ssm-build-dual.sh index b39baa51..a5cb26c7 100755 --- a/scripts/ssm-build-dual.sh +++ b/scripts/ssm-build-dual.sh @@ -15,7 +15,7 @@ set -e usage() { - echo "[options] Usage: $0 (deb | rpm) " + echo "Usage: $0 [options] (deb | rpm) " echo -e "Build script for Apel-SSM.\n" echo " -h Displays help." echo " -v Verbose FPM output." @@ -42,8 +42,7 @@ while getopts ":hs:b:v" o; do BUILD_DIR=$b BUILD_ASSIGNED=1 ;; - v) v=${OPTARG} - VERBOSE="--verbose " + v) VERBOSE="--verbose " ;; *) usage; ;; @@ -86,24 +85,23 @@ fi # Directory cleaning and repository management # Create SSM and DEB dir (if not present) -mkdir -p $SOURCE_DIR -mkdir -p $BUILD_DIR +mkdir -p "$SOURCE_DIR" +mkdir -p "$BUILD_DIR" # Clean up any previous build -rm -rf $SOURCE_DIR/* -rm -rf $BUILD_DIR/* +rm -rf "${SOURCE_DIR:?}"/* +rm -rf "${BUILD_DIR:?}"/* # Get and extract the source TAR_FILE=${VERSION}-${ITERATION}.tar.gz TAR_URL=https://github.com/apel/ssm/archive/$TAR_FILE -wget --no-check-certificate $TAR_URL -O $TAR_FILE -tar xvf $TAR_FILE -C $SOURCE_DIR -rm -f $TAR_FILE +wget --no-check-certificate "$TAR_URL" -O "$TAR_FILE" +tar xvf "$TAR_FILE" -C "$SOURCE_DIR" +rm -f "$TAR_FILE" # Get supplied Python version -PY_VERSION=$(basename $PYTHON_ROOT_DIR) +PY_VERSION="$(basename "$PYTHON_ROOT_DIR")" PY_NUM=${PY_VERSION#python} -echo $PY_NUM # Universal FPM Call FPM_CORE="fpm -s python \ @@ -154,14 +152,14 @@ BUILD_PACKAGE_COMMAND=${FPM_CORE}${FPM_PYTHON}${VERBOSE}${PACKAGE_VERSION} eval "$BUILD_PACKAGE_COMMAND" # When installed, use pleaserun to perform system specific service setup -fpm -s pleaserun -t $PACK_TYPE \ +fpm -s pleaserun -t "$PACK_TYPE" \ -n apel-ssm-service \ --v $VERSION \ ---iteration $ITERATION \ +-v "$VERSION" \ +--iteration "$ITERATION" \ -m "Apel Administrators " \ --description "Secure Stomp Messenger (SSM) Service Daemon files." \ --architecture all \ --no-auto-depends \ --depends apel-ssm \ ---package $BUILD_DIR \ +--package "$BUILD_DIR" \ /usr/bin/ssmreceive From 8a15ee44a343e67dee8bf67ae1bb2f9c9377651e Mon Sep 17 00:00:00 2001 From: RedProkofiev Date: Thu, 18 Jan 2024 10:25:03 +0000 Subject: [PATCH 10/11] Remove whitespace --- scripts/ssm-build-dual.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/ssm-build-dual.sh b/scripts/ssm-build-dual.sh index a5cb26c7..fe697f54 100755 --- a/scripts/ssm-build-dual.sh +++ b/scripts/ssm-build-dual.sh @@ -14,14 +14,14 @@ set -e -usage() { +usage() { echo "Usage: $0 [options] (deb | rpm) " echo -e "Build script for Apel-SSM.\n" echo " -h Displays help." echo " -v Verbose FPM output." - echo " -s Directory of source files. Defaults to /debbuild/source or SOME RPM DIR." + echo " -s Directory of source files. Defaults to /debbuild/source or SOME RPM DIR." echo -e " -b Directory of build files. Defaults to /debbuild/build or SOME RPM DIR.\n" 1>&2; - exit 1; + exit 1; } # Bool flags to prevent automatic overwrite of input @@ -62,7 +62,7 @@ ITERATION=$3 PYTHON_ROOT_DIR=$4 # i.e. /usr/lib/python3.6 # Alter library, build and source directories depending on the package -if [[ "$PACK_TYPE" = "deb" ]]; then +if [[ "$PACK_TYPE" = "deb" ]]; then LIB_EXTENSION="/dist-packages" if [[ "$SOURCE_ASSIGNED" = 0 ]]; then SOURCE_DIR=~/debbuild/source @@ -136,7 +136,7 @@ elif [[ ${PY_NUM:0:1} == "2" ]]; then --depends python-ldap \ --depends libssl-dev \ --depends libsasl2-dev \ - --depends openssl " + --depends openssl " fi # python-bin must always be specified in modern linux From ee07f16b4d070f07d007cbcba97e16de07dd4597 Mon Sep 17 00:00:00 2001 From: RedProkofiev Date: Mon, 22 Jan 2024 13:29:47 +0000 Subject: [PATCH 11/11] Changes to setup.py - Adds cryptography as a dependency before pyopenssl - Modified pyopenssl to lower case to satisfy pip call --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d5cdd70e..a495ca0c 100644 --- a/setup.py +++ b/setup.py @@ -51,10 +51,11 @@ def main(): download_url='https://github.com/apel/ssm/releases', license='Apache License, Version 2.0', install_requires=[ + 'cryptography==3.3.0', 'stomp.py<5.0.0', 'python-ldap<3.4.0', 'setuptools', - 'PyOpenSSL', + 'pyopenssl<=21.0.0', ], extras_require={ 'AMS': ['argo-ams-library', 'certifi<2020.4.5.2', ],