diff options
author | Max Illfelder <illfelder@google.com> | 2016-05-17 19:47:49 -0700 |
---|---|---|
committer | Max Illfelder <illfelder@google.com> | 2016-05-17 19:47:49 -0700 |
commit | a47a8b769f7dd0da357709129c3a40a20bdbcaa0 (patch) | |
tree | 9781bf031c0cc57ebbe232ebbeda087bf2420f76 | |
parent | f713a378a0d496509b8f2eb5fcae7fede920cb44 (diff) | |
download | google-compute-image-packages-a47a8b769f7dd0da357709129c3a40a20bdbcaa0.tar.gz |
Enable deb and rpm packaging for the Linux guest.
-rw-r--r-- | MANIFEST.in | 1 | ||||
-rwxr-xr-x | package.sh | 43 | ||||
-rwxr-xr-x | package/systemd/prerm.sh (renamed from package/systemd/postrm.sh) | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | package/sysvinit/postinst.sh | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | package/sysvinit/prerm.sh (renamed from package/sysvinit/postrm.sh) | 0 | ||||
-rwxr-xr-x | package/upstart/prerm.sh (renamed from package/upstart/postrm.sh) | 0 | ||||
-rwxr-xr-x | setup.py | 54 |
7 files changed, 80 insertions, 18 deletions
diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..dc046f4 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +graft package diff --git a/package.sh b/package.sh new file mode 100755 index 0000000..e2027b2 --- /dev/null +++ b/package.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Build the Linux guest environment deb and rpm packages. + +TIMESTAMP="$(date -u +%Y%m%d%H%M%S)" + +for CONFIG in 'systemd' 'sysvinit' 'upstart'; +do + fpm \ + -s python \ + -t deb \ + --no-python-fix-name \ + --python-install-bin '/usr/bin' \ + --python-install-lib '/usr/lib/python2.7/site-packages' \ + --after-install "package/$CONFIG/postinst.sh" \ + --before-remove "package/$CONFIG/prerm.sh" \ + --iteration "$TIMESTAMP" \ + setup.py + + fpm \ + -s python \ + -t rpm \ + --no-python-fix-name \ + --python-install-bin '/usr/bin' \ + --python-install-lib '/usr/lib/python2.7/site-packages' \ + --after-install "package/$CONFIG/postinst.sh" \ + --before-remove "package/$CONFIG/prerm.sh" \ + --iteration "$TIMESTAMP" \ + setup.py +done diff --git a/package/systemd/postrm.sh b/package/systemd/prerm.sh index 2dc208c..2dc208c 100755 --- a/package/systemd/postrm.sh +++ b/package/systemd/prerm.sh diff --git a/package/sysvinit/postinst.sh b/package/sysvinit/postinst.sh index 20f1780..20f1780 100644..100755 --- a/package/sysvinit/postinst.sh +++ b/package/sysvinit/postinst.sh diff --git a/package/sysvinit/postrm.sh b/package/sysvinit/prerm.sh index 1480045..1480045 100644..100755 --- a/package/sysvinit/postrm.sh +++ b/package/sysvinit/prerm.sh diff --git a/package/upstart/postrm.sh b/package/upstart/prerm.sh index 0b161ab..0b161ab 100755 --- a/package/upstart/postrm.sh +++ b/package/upstart/prerm.sh @@ -15,35 +15,54 @@ """Create a Python package of the Linux guest environment.""" +import glob +import os +import sys + import setuptools -# NOTE Not yet able to build a working deb or rpm. Will build a working -# python package. +def GetInitFiles(path): + """Get the list of relative paths to init files. + + Args: + path: string, the relative path to the source directory. + + Returns: + list, the relative path strings for init files. + """ + valid = '%s/*' % path + invalid = '%s/*.sh' % path + return list(set(glob.glob(valid)) - set(glob.glob(invalid))) + + +data_files_dict = { + 'systemd': [('/usr/lib/systemd/system', GetInitFiles('package/systemd'))], + 'sysvinit': [('/etc/init.d', GetInitFiles('package/sysvinit'))], + 'upstart': [('/etc/init', GetInitFiles('package/upstart'))], +} + + +if os.environ.get('CONFIG') not in data_files_dict.keys(): + keys = ', '.join(data_files_dict.keys()) + sys.exit('Expected "CONFIG" environment variable set to one of [%s].' % keys) setuptools.setup( - name='google_compute_engine', - version='2.0.0', author='Google Compute Engine Team', author_email='gc-team@google.com', - url='https://github.com/GoogleCloudPlatform/compute-image-packages', - + data_files=data_files_dict.get(os.environ['CONFIG']), description='Google Compute Engine', - long_description='Google Compute Engine guest environment.', + include_package_data=True, install_requires=['boto>=2.25.0'], license='Apache Software License', - + long_description='Google Compute Engine guest environment.', + name='google_compute_engine_%s' % os.environ['CONFIG'], packages=setuptools.find_packages(), - - # These end up in /usr/bin - scripts=[ - 'scripts/optimize_local_ssd', - 'scripts/set_hostname', - 'scripts/set_multiqueue', - ], - - # These end up in /usr/bin, for example /usr/bin/google_accounts_daemon + scripts=glob.glob('scripts/*'), + url='https://github.com/GoogleCloudPlatform/compute-image-packages', + version='2.0.0', + # Entry points create scripts in /usr/bin that call a function. entry_points={ 'console_scripts': [ 'google_accounts_daemon=accounts.accounts_daemon:main', @@ -53,7 +72,6 @@ setuptools.setup( 'google_metadata_script_runner=metadata_scripts.script_manager:main', ], }, - classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: No Input/Output (Daemon)', |