-
Notifications
You must be signed in to change notification settings - Fork 25
FPM build script for RPM and DEB #279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d716f00
FPM call structure
nick-whyatt 1c12984
Detecting versions
nick-whyatt dd5de79
Workable structure
nick-whyatt e3e1b4c
Verbose flag added
nick-whyatt 8e2a308
Change variable names
nick-whyatt c64dd80
Fixing import json error with addition of --python-bin flag
nick-whyatt 11907d4
Build/pleaserun
nick-whyatt 89ed0ed
Adding documentation, removing test coordinates, modifying help message
nick-whyatt f7ee9b4
Fix code quality issues
nick-whyatt 8a15ee4
Remove whitespace
nick-whyatt ee07f16
Changes to setup.py
nick-whyatt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Apel-SSM Build Script 2.0: FPM edition | ||
| # Adapted from the Debian only build script, now with RPM! | ||
| # @Author: Nicholas Whyatt ([email protected]) | ||
|
|
||
| # 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) <version> <iteration> <python_root_dir> 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 -e | ||
|
|
||
| usage() { | ||
| echo "Usage: $0 [options] (deb | rpm) <version> <iteration> <python_root_dir> " | ||
| echo -e "Build script for Apel-SSM.\n" | ||
| echo " -h Displays help." | ||
| echo " -v Verbose FPM output." | ||
| echo " -s <source_dir> Directory of source files. Defaults to /debbuild/source or SOME RPM DIR." | ||
| echo -e " -b <build_dir> Directory of build files. Defaults to /debbuild/build or SOME RPM DIR.\n" 1>&2; | ||
| exit 1; | ||
| } | ||
|
|
||
| # Bool flags to prevent automatic overwrite of input | ||
| SOURCE_ASSIGNED=0 | ||
| BUILD_ASSIGNED=0 | ||
|
|
||
| # Configurable options | ||
| while getopts ":hs:b:v" 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 | ||
| ;; | ||
| v) VERBOSE="--verbose " | ||
| ;; | ||
| *) 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 | ||
|
|
||
| # Alter library, build and source directories depending on the package | ||
| 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=~/rpmbuild/SOURCES | ||
| fi | ||
| if [[ "$BUILD_ASSIGNED" = 0 ]]; then | ||
| 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 | ||
|
|
||
| # 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:?}"/* | ||
|
|
||
| # 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")" | ||
| PY_NUM=${PY_VERSION#python} | ||
|
|
||
| # Universal FPM Call | ||
| FPM_CORE="fpm -s python \ | ||
| -t $PACK_TYPE \ | ||
| -n apel-ssm \ | ||
| -v $VERSION \ | ||
| --iteration $ITERATION \ | ||
| -m \"Apel Administrators <[email protected]>\" \ | ||
| --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." | ||
|
|
||
| # 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 " | ||
|
|
||
| elif [[ ${PY_NUM:0:1} == "2" ]]; 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' \ | ||
| --depends python-ldap \ | ||
| --depends libssl-dev \ | ||
| --depends libsasl2-dev \ | ||
| --depends openssl " | ||
| fi | ||
|
|
||
| # 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 \ | ||
| --exclude *.pyc \ | ||
| --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} | ||
| 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" \ | ||
| --iteration "$ITERATION" \ | ||
| -m "Apel Administrators <[email protected]>" \ | ||
| --description "Secure Stomp Messenger (SSM) Service Daemon files." \ | ||
| --architecture all \ | ||
| --no-auto-depends \ | ||
| --depends apel-ssm \ | ||
| --package "$BUILD_DIR" \ | ||
| /usr/bin/ssmreceive |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.