Skip to content
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

Add build script to create .deb packages for Debian/Ubuntu style systems using FPM, changes to setup.py to facilitate this #73

Merged
merged 28 commits into from
Aug 16, 2018

Conversation

gregcorbett
Copy link
Member

Resolves #60

This PR:

  • Adds a build script to build tagged versions of SSM. As with the RPM build script, testing on a non-tagged version requires some manual fudging (see manual testing below)
  • Modifies the setup.py script to facilitate generating packages via FPM by:
    • Installing README.md under the directory /usr/share/doc/apel-ssm (rather than in a file)
    • Preventing the install of the test package of SSM (i.e. the unittests)
    • No longer installing system specific init files and moving apel directory creation into main()
  • Updates install documentation

Manual Testing

Running this stripped down version of the build script, that works within a checked out copy of the code base i.e. it doesn't go any fetch a version from GitHub.

apt-get install lintian
apt-get install ruby ruby-dev rubygems build-essential
gem install --no-ri --no-rdoc fpm -v 1.9.3

TAG=2.X.X-1

# Where to install the python lib files
PYTHON_INSTALL_LIB=/usr/lib/python2.7/dist-packages

# Split the tag into version and package number
# so they can be passed to fpm separately.
# This will work with RCs of the form X.Y.Z-0.A.rcA
VERSION=`echo "$TAG" | cut -d - -f 1`
ITERATION=`echo "$TAG" | cut -d - -f 2`

fpm -s python -t deb \
-n apel-ssm \
-v $VERSION \
--iteration $ITERATION \
-m "Apel Administrators <apel-admins@stfc.ac.uk>" \
--description "Secure Stomp Messenger (SSM)." \
--no-auto-depends \
--depends python2.7 \
--depends python-pip \
--depends python-ldap \
--depends libssl-dev \
--depends libsasl2-dev \
--deb-changelog CHANGELOG \
--python-install-bin /usr/bin \
--python-install-lib $PYTHON_INSTALL_LIB \
--exclude *.pyc \
setup.py

fpm -s pleaserun -t deb \
-n apel-ssm-service \
-v $VERSION \
--iteration $ITERATION \
-m "Apel Administrators <apel-admins@stfc.ac.uk>" \
--description "Secure Stomp Messenger (SSM) unit files." \
--no-auto-depends \
--depends apel-ssm \
/usr/bin/ssmreceive

lintian apel-ssm_${TAG}_all.deb

README.md Outdated
* `apt-get -f install`

Install any missing python requirements that don't have system packages.
* `pip install "stomp.py>=3.1.1" python-daemon python-ldap dirq`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these have Ubuntu packages?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stomp.py, no - there is a confusingly named python-stompy but its a complete different library
dirq - seemingly not

there does look like there are suitable packages for python-ldap and python-daemon, so I'll use them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly I just wanted to understand the differences. Can discuss later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I remember now, the python python-ldap requires the system python-ldap headers in order to install. That's why it's listed here and in the build script as a dependency.

And python-daemon is an optional requirement, so should stay out of the package dependencies as per #70.

I'll reword this line to be clearer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Infact, system python-ldap seems to be sufficient!

README.md Outdated
## Installing the DEB

### Installation
Install APEL SSM.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the following "Install..." lines should prob end in a colon as the code bit is a follow on.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

@@ -0,0 +1,84 @@
#!/bin/bash

# Execute the following as root to install lintian and fpm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Colon at end.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

# apt-get install ruby ruby-dev rubygems build-essential
# gem install --no-ri --no-rdoc fpm

# Then run this file, altering the version.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the version in TAG?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment clarified

# This file will create two versions of the deb file:
# - apel-ssm_<version>_all.deb contains all the files necessary to run a
# the SSM as a sender.
# - apel-ssm-service_<version>_amd64.deb will install service files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this one AMD 64 specific?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is the more system specific / service files. The exact value should probably be a configurable option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you mean just because this is what we use?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although it looks like we can package it as all, the deb equivalent of noarch

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok, that would seem to be more consistent with the RPMs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chaged


# Split the tag into version and package number
# so they can be passed to fpm separately.
# This will work with RCs of the form X.Y.Z-0.A.rcA
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And any other package that uses our version scheme? e.g 1.2.3-1.1.alpha1

Copy link
Member Author

@gregcorbett gregcorbett Aug 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should do, I think it will split on the -. If it does I'll clarify the comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clarified

-v $VERSION \
--iteration $ITERATION \
-m "Apel Administrators <apel-admins@stfc.ac.uk>" \
--description "Secure Stomp Messenger (SSM) unit files." \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the system files that let you do service apel-ssm start

Copy link
Member

@tofu-rocketry tofu-rocketry Aug 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought there weren't any for Ubuntu.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No there are, they just differ from the RedHat(6) style file the RPM would install

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed "unit files" to "Service Daemon files"

@@ -28,15 +30,6 @@ def main():
copyfile('scripts/apel-ssm.logrotate', 'conf/apel-ssm')
copyfile('README.md', 'apel-ssm')

if not path.exists('/var/log/apel'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this has been replaced by the bit below in data_files? Is that the better way to do it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe so, it lets setuptools worry about the directory creation rather than doing it 'manually'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

scripts=['bin/ssmreceive', 'bin/ssmsend'],
data_files=[(conf_dir, conf_files),
('/etc/logrotate.d', ['conf/apel-ssm']),
('/etc/init.d', ['bin/apel-ssm']),
('/usr/share/doc', ['apel-ssm'])],
('/usr/share/doc/apel-ssm', ['apel-ssm']),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where'd the docs go before this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it went in a file under /usr/share/doc rather than a file under /usr/share/doc/apel-ssm.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that sounds better now.

-n apel-ssm \
-v $VERSION \
--iteration $ITERATION \
-m "Apel Administrators <apel-admins@stfc.ac.uk>" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of config here that seems like it would be better handled with a config file or as constants earlier in the script. Email is repeated.

Can the depends be given as a list?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably would be better as a config file, or at the very least reducing the duplication of the email.

I don't think so, the documentation around depends says A dependency. This flag can be specified multiple times.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, is there an option to read a list of dependencies or anything like that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. Ideally, dependencies would be read from the setup.py script but as some of the python packages don't have a system packages I didn't use that feature.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is best to do this as a config file? Sourcing a separate file that list the variables? Like this:

TAG=...
SOURCE_DIR=...
BUILD_DIR=...
# etc etc

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there's no built in way, I'd leave it as is.

@tofu-rocketry
Copy link
Member

The Codacy suggestion could also be fixed: https://app.codacy.com/app/apel/ssm/pullRequest?prid=1888023

@@ -61,21 +62,21 @@ fpm -s python -t deb \
--python-install-bin /usr/bin \
--python-install-lib $PYTHON_INSTALL_LIB \
--exclude *.pyc \
--package $BUILD_DIR \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot neater. 👍

@tofu-rocketry
Copy link
Member

Think that's everything covered. Shall we rebase?

- ubuntu (and RedHat) seem to prefer this to file
  directly under /usr/share/doc/apel-ssm
- and fpm errors because it seems to assume
  apel-ssm is a directory (see jordansissel/fpm#586)
- it is very RedHat/Centos/SL specific and whereas the setup.py script
  is meant to be a more general way of installing ssm
- it also seems to cause problems with fpm and the packages generated
  by pleaserun as the bad init script conflicts with the unit files
- add a note saying this script does not install init scripts
- so packages created by fpm will also create them
- so fpm generated package is appropriately named
- as it mangle them and those it doesn't mangle aren't
  packages under ubunutu so need to be installed by pip
- as pip is needed to install the python requirements
  and the system python-ldap package is needed for
  the python python-ldap to install
- to prevent a nasty surprise on systems where python 3
  is the default python
- in its previous location, it seemed to have no effect.
- it has been moved to before any "depends" options
@tofu-rocketry tofu-rocketry merged commit 6aee1f9 into apel:dev Aug 16, 2018
@gregcorbett gregcorbett deleted the deb-fpm branch August 16, 2018 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants