diff options
author | Max Illfelder <illfelder@google.com> | 2016-06-22 13:57:38 -0700 |
---|---|---|
committer | Max Illfelder <illfelder@google.com> | 2016-06-22 14:19:06 -0700 |
commit | 9c80d8c20520cbc9e83e428ce929344cf61bc478 (patch) | |
tree | 69079ff93932cb4de0c35a27065205c54649d01d | |
parent | 0019cc8ba4356a8359dff22a70492fc762081af8 (diff) | |
download | google-compute-image-packages-9c80d8c20520cbc9e83e428ce929344cf61bc478.tar.gz |
Create a Google Compute Engine init package.
The google-compute-engine package is identical to the Python package and
does not install distro specific init files. The new package is
necessary to automatically run daemons and instance setup.
-rwxr-xr-x | build_packages.sh | 16 | ||||
-rwxr-xr-x | google_compute_engine_init/build_packages.sh | 65 | ||||
-rw-r--r-- | google_compute_engine_init/systemd/google-accounts-daemon.service (renamed from package/systemd/google-accounts-daemon.service) | 0 | ||||
-rw-r--r-- | google_compute_engine_init/systemd/google-clock-skew-daemon.service (renamed from package/systemd/google-clock-skew-daemon.service) | 0 | ||||
-rw-r--r-- | google_compute_engine_init/systemd/google-instance-setup.service (renamed from package/systemd/google-instance-setup.service) | 0 | ||||
-rw-r--r-- | google_compute_engine_init/systemd/google-ip-forwarding-daemon.service (renamed from package/systemd/google-ip-forwarding-daemon.service) | 0 | ||||
-rw-r--r-- | google_compute_engine_init/systemd/google-shutdown-scripts.service (renamed from package/systemd/google-shutdown-scripts.service) | 0 | ||||
-rw-r--r-- | google_compute_engine_init/systemd/google-startup-scripts.service (renamed from package/systemd/google-startup-scripts.service) | 0 | ||||
-rwxr-xr-x | google_compute_engine_init/systemd/postinst.sh (renamed from package/systemd/postinst.sh) | 0 | ||||
-rwxr-xr-x | google_compute_engine_init/systemd/prerm.sh (renamed from package/systemd/prerm.sh) | 0 | ||||
-rwxr-xr-x | google_compute_engine_init/sysvinit/google-accounts-daemon (renamed from package/sysvinit/google-accounts-daemon) | 0 | ||||
-rwxr-xr-x | google_compute_engine_init/sysvinit/google-clock-skew-daemon (renamed from package/sysvinit/google-clock-skew-daemon) | 0 | ||||
-rwxr-xr-x | google_compute_engine_init/sysvinit/google-instance-setup (renamed from package/sysvinit/google-instance-setup) | 0 | ||||
-rwxr-xr-x | google_compute_engine_init/sysvinit/google-ip-forwarding-daemon (renamed from package/sysvinit/google-ip-forwarding-daemon) | 0 | ||||
-rwxr-xr-x | google_compute_engine_init/sysvinit/google-shutdown-scripts (renamed from package/sysvinit/google-shutdown-scripts) | 0 | ||||
-rwxr-xr-x | google_compute_engine_init/sysvinit/google-startup-scripts (renamed from package/sysvinit/google-startup-scripts) | 0 | ||||
-rwxr-xr-x | google_compute_engine_init/sysvinit/postinst.sh (renamed from package/sysvinit/postinst.sh) | 0 | ||||
-rwxr-xr-x | google_compute_engine_init/sysvinit/prerm.sh (renamed from package/sysvinit/prerm.sh) | 0 | ||||
-rw-r--r-- | google_compute_engine_init/upstart/google-accounts-daemon.conf (renamed from package/upstart/google-accounts-daemon.conf) | 0 | ||||
-rw-r--r-- | google_compute_engine_init/upstart/google-clock-skew-daemon.conf (renamed from package/upstart/google-clock-skew-daemon.conf) | 0 | ||||
-rw-r--r-- | google_compute_engine_init/upstart/google-instance-setup.conf (renamed from package/upstart/google-instance-setup.conf) | 0 | ||||
-rw-r--r-- | google_compute_engine_init/upstart/google-ip-forwarding-daemon.conf (renamed from package/upstart/google-ip-forwarding-daemon.conf) | 0 | ||||
-rw-r--r-- | google_compute_engine_init/upstart/google-shutdown-scripts.conf (renamed from package/upstart/google-shutdown-scripts.conf) | 0 | ||||
-rw-r--r-- | google_compute_engine_init/upstart/google-startup-scripts.conf (renamed from package/upstart/google-startup-scripts.conf) | 0 | ||||
-rwxr-xr-x | google_compute_engine_init/upstart/postinst.sh (renamed from package/upstart/postinst.sh) | 0 | ||||
-rwxr-xr-x | google_compute_engine_init/upstart/prerm.sh (renamed from package/upstart/prerm.sh) | 0 | ||||
-rwxr-xr-x | google_configs/build_packages.sh | 2 | ||||
-rw-r--r-- | package/instance_configs.cfg | 22 | ||||
-rwxr-xr-x | setup.py | 37 |
29 files changed, 74 insertions, 68 deletions
diff --git a/build_packages.sh b/build_packages.sh index b119403..e669ca1 100755 --- a/build_packages.sh +++ b/build_packages.sh @@ -20,21 +20,21 @@ TIMESTAMP="$(date +%s)" function build_distro() { declare -r distro="$1" declare -r pkg_type="$2" - declare -r init_config="$3" - declare -r py_path="$4" + declare -r py_path="$3" + declare depends='google-compute-engine-init' declare name='google-compute-engine' export CONFIG="${init_config}" if [[ "${pkg_type}" == 'deb' ]]; then + depends="${depends}-${distro}" name="${name}-${distro}" fi fpm \ -s python \ -t "${pkg_type}" \ - --after-install "package/${init_config}/postinst.sh" \ - --before-remove "package/${init_config}/prerm.sh" \ + --depends "${depends}" \ --depends 'python-boto' \ --depends 'python-setuptools' \ --iteration "0.${TIMESTAMP}" \ @@ -49,9 +49,9 @@ function build_distro() { } # RHEL/CentOS -build_distro 'el6' 'rpm' 'upstart' '/usr/lib/python2.6/site-packages' -build_distro 'el7' 'rpm' 'systemd' '/usr/lib/python2.7/site-packages' +build_distro 'el6' 'rpm' '/usr/lib/python2.6/site-packages' +build_distro 'el7' 'rpm' '/usr/lib/python2.7/site-packages' # Debian -build_distro 'wheezy' 'deb' 'sysvinit' '/usr/lib/python2.7/dist-packages' -build_distro 'jessie' 'deb' 'systemd' '/usr/lib/python2.7/dist-packages' +build_distro 'wheezy' 'deb' '/usr/lib/python2.7/dist-packages' +build_distro 'jessie' 'deb' '/usr/lib/python2.7/dist-packages' diff --git a/google_compute_engine_init/build_packages.sh b/google_compute_engine_init/build_packages.sh new file mode 100755 index 0000000..09dfacc --- /dev/null +++ b/google_compute_engine_init/build_packages.sh @@ -0,0 +1,65 @@ +#!/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. + +TIMESTAMP="$(date +%s)" + +function build_distro() { + declare -r distro="$1" + declare -r pkg_type="$2" + declare -r init_config="$3" + declare -r init_prefix="$4" + declare depends='google-compute-engine' + declare file_pattern='*[^.sh]' + declare init_files=(${init_config}/${file_pattern}) + declare name='google-compute-engine-init' + + for ((i=0; i<${#init_files[@]}; i++)); do + file_name="$(basename ${init_files[$i]})" + file_entry="${init_config}/${file_name}=${init_prefix}/${file_name}" + init_files[$i]="$file_entry" + done + + if [[ "${pkg_type}" == 'deb' ]]; then + depends="${depends}-${distro}" + name="${name}-${distro}" + fi + + fpm \ + -s dir \ + -t "${pkg_type}" \ + --after-install "${init_config}/postinst.sh" \ + --before-remove "${init_config}/prerm.sh" \ + --depends "${depends}" \ + --description 'Google Compute Engine Linux initialization scripts' \ + --iteration "0.${TIMESTAMP}" \ + --license 'Apache Software License' \ + --maintainer 'gc-team@google.com' \ + --name "${name}" \ + --replaces 'gce-startup-scripts' \ + --replaces 'google-startup-scripts' \ + --rpm-dist "${distro}" \ + --url 'https://github.com/GoogleCloudPlatform/compute-image-packages' \ + --vendor 'Google Compute Engine Team' \ + --version '2.0.0' \ + "${init_files[@]}" +} + +# RHEL/CentOS +build_distro 'el6' 'rpm' 'upstart' '/etc/init' +build_distro 'el7' 'rpm' 'systemd' '/usr/lib/systemd/system' + +# Debian +build_distro 'wheezy' 'deb' 'sysvinit' '/etc/init.d' +build_distro 'jessie' 'deb' 'systemd' '/usr/lib/systemd/system' diff --git a/package/systemd/google-accounts-daemon.service b/google_compute_engine_init/systemd/google-accounts-daemon.service index 04d74b5..04d74b5 100644 --- a/package/systemd/google-accounts-daemon.service +++ b/google_compute_engine_init/systemd/google-accounts-daemon.service diff --git a/package/systemd/google-clock-skew-daemon.service b/google_compute_engine_init/systemd/google-clock-skew-daemon.service index 511f55b..511f55b 100644 --- a/package/systemd/google-clock-skew-daemon.service +++ b/google_compute_engine_init/systemd/google-clock-skew-daemon.service diff --git a/package/systemd/google-instance-setup.service b/google_compute_engine_init/systemd/google-instance-setup.service index afa639a..afa639a 100644 --- a/package/systemd/google-instance-setup.service +++ b/google_compute_engine_init/systemd/google-instance-setup.service diff --git a/package/systemd/google-ip-forwarding-daemon.service b/google_compute_engine_init/systemd/google-ip-forwarding-daemon.service index d8d98ad..d8d98ad 100644 --- a/package/systemd/google-ip-forwarding-daemon.service +++ b/google_compute_engine_init/systemd/google-ip-forwarding-daemon.service diff --git a/package/systemd/google-shutdown-scripts.service b/google_compute_engine_init/systemd/google-shutdown-scripts.service index 04c82fd..04c82fd 100644 --- a/package/systemd/google-shutdown-scripts.service +++ b/google_compute_engine_init/systemd/google-shutdown-scripts.service diff --git a/package/systemd/google-startup-scripts.service b/google_compute_engine_init/systemd/google-startup-scripts.service index 1c373c5..1c373c5 100644 --- a/package/systemd/google-startup-scripts.service +++ b/google_compute_engine_init/systemd/google-startup-scripts.service diff --git a/package/systemd/postinst.sh b/google_compute_engine_init/systemd/postinst.sh index 66369fe..66369fe 100755 --- a/package/systemd/postinst.sh +++ b/google_compute_engine_init/systemd/postinst.sh diff --git a/package/systemd/prerm.sh b/google_compute_engine_init/systemd/prerm.sh index 16419b8..16419b8 100755 --- a/package/systemd/prerm.sh +++ b/google_compute_engine_init/systemd/prerm.sh diff --git a/package/sysvinit/google-accounts-daemon b/google_compute_engine_init/sysvinit/google-accounts-daemon index 96b0a55..96b0a55 100755 --- a/package/sysvinit/google-accounts-daemon +++ b/google_compute_engine_init/sysvinit/google-accounts-daemon diff --git a/package/sysvinit/google-clock-skew-daemon b/google_compute_engine_init/sysvinit/google-clock-skew-daemon index 02b0011..02b0011 100755 --- a/package/sysvinit/google-clock-skew-daemon +++ b/google_compute_engine_init/sysvinit/google-clock-skew-daemon diff --git a/package/sysvinit/google-instance-setup b/google_compute_engine_init/sysvinit/google-instance-setup index 4382f25..4382f25 100755 --- a/package/sysvinit/google-instance-setup +++ b/google_compute_engine_init/sysvinit/google-instance-setup diff --git a/package/sysvinit/google-ip-forwarding-daemon b/google_compute_engine_init/sysvinit/google-ip-forwarding-daemon index 92e72a8..92e72a8 100755 --- a/package/sysvinit/google-ip-forwarding-daemon +++ b/google_compute_engine_init/sysvinit/google-ip-forwarding-daemon diff --git a/package/sysvinit/google-shutdown-scripts b/google_compute_engine_init/sysvinit/google-shutdown-scripts index 3f93799..3f93799 100755 --- a/package/sysvinit/google-shutdown-scripts +++ b/google_compute_engine_init/sysvinit/google-shutdown-scripts diff --git a/package/sysvinit/google-startup-scripts b/google_compute_engine_init/sysvinit/google-startup-scripts index 2ee8a56..2ee8a56 100755 --- a/package/sysvinit/google-startup-scripts +++ b/google_compute_engine_init/sysvinit/google-startup-scripts diff --git a/package/sysvinit/postinst.sh b/google_compute_engine_init/sysvinit/postinst.sh index 281f6ee..281f6ee 100755 --- a/package/sysvinit/postinst.sh +++ b/google_compute_engine_init/sysvinit/postinst.sh diff --git a/package/sysvinit/prerm.sh b/google_compute_engine_init/sysvinit/prerm.sh index abc306d..abc306d 100755 --- a/package/sysvinit/prerm.sh +++ b/google_compute_engine_init/sysvinit/prerm.sh diff --git a/package/upstart/google-accounts-daemon.conf b/google_compute_engine_init/upstart/google-accounts-daemon.conf index 85ef7a5..85ef7a5 100644 --- a/package/upstart/google-accounts-daemon.conf +++ b/google_compute_engine_init/upstart/google-accounts-daemon.conf diff --git a/package/upstart/google-clock-skew-daemon.conf b/google_compute_engine_init/upstart/google-clock-skew-daemon.conf index 5213e9c..5213e9c 100644 --- a/package/upstart/google-clock-skew-daemon.conf +++ b/google_compute_engine_init/upstart/google-clock-skew-daemon.conf diff --git a/package/upstart/google-instance-setup.conf b/google_compute_engine_init/upstart/google-instance-setup.conf index 2c7d596..2c7d596 100644 --- a/package/upstart/google-instance-setup.conf +++ b/google_compute_engine_init/upstart/google-instance-setup.conf diff --git a/package/upstart/google-ip-forwarding-daemon.conf b/google_compute_engine_init/upstart/google-ip-forwarding-daemon.conf index 6d1fd05..6d1fd05 100644 --- a/package/upstart/google-ip-forwarding-daemon.conf +++ b/google_compute_engine_init/upstart/google-ip-forwarding-daemon.conf diff --git a/package/upstart/google-shutdown-scripts.conf b/google_compute_engine_init/upstart/google-shutdown-scripts.conf index b9323a5..b9323a5 100644 --- a/package/upstart/google-shutdown-scripts.conf +++ b/google_compute_engine_init/upstart/google-shutdown-scripts.conf diff --git a/package/upstart/google-startup-scripts.conf b/google_compute_engine_init/upstart/google-startup-scripts.conf index 6fa68a7..6fa68a7 100644 --- a/package/upstart/google-startup-scripts.conf +++ b/google_compute_engine_init/upstart/google-startup-scripts.conf diff --git a/package/upstart/postinst.sh b/google_compute_engine_init/upstart/postinst.sh index 5cbe3c8..5cbe3c8 100755 --- a/package/upstart/postinst.sh +++ b/google_compute_engine_init/upstart/postinst.sh diff --git a/package/upstart/prerm.sh b/google_compute_engine_init/upstart/prerm.sh index 0b161ab..0b161ab 100755 --- a/package/upstart/prerm.sh +++ b/google_compute_engine_init/upstart/prerm.sh diff --git a/google_configs/build_packages.sh b/google_configs/build_packages.sh index 94f7bba..af35e7d 100755 --- a/google_configs/build_packages.sh +++ b/google_configs/build_packages.sh @@ -33,7 +33,7 @@ function build_distro() { fpm \ -s dir \ -t "${pkg_type}" \ - --description 'Google Compute Engine guest configs' \ + --description 'Google Compute Engine Linux guest configuration' \ --iteration "0.${TIMESTAMP}" \ --license 'Apache Software License' \ --maintainer 'gc-team@google.com' \ diff --git a/package/instance_configs.cfg b/package/instance_configs.cfg deleted file mode 100644 index 8e1d63e..0000000 --- a/package/instance_configs.cfg +++ /dev/null @@ -1,22 +0,0 @@ -[Accounts] -deprovision_remove = false -groups = adm,dip,lxd,plugdev,video - -[Daemons] -accounts_daemon = true -clock_skew_daemon = true -ip_forwarding_daemon = true - -[InstanceSetup] -network_enabled = true -optimize_local_ssd = true -set_boto_config = true -set_host_keys = true -set_multiqueue = true - -[IpForwarding] -ethernet_proto_id = 66 - -[MetadataScripts] -shutdown = true -startup = true @@ -16,50 +16,13 @@ """Create a Python package of the Linux guest environment.""" import glob -import os -import sys import setuptools -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))) - - -# Common data files to add as part of all Linux distributions. -data_files = [ - ('/etc/default', ['package/instance_configs.cfg']), -] - - -# Data files specific to the various Linux init systems. -data_files_dict = { - None: [], - '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([key for key in data_files_dict.keys() if key]) - sys.exit('Expected "CONFIG" environment variable set to one of [%s].' % keys) - - setuptools.setup( author='Google Compute Engine Team', author_email='gc-team@google.com', - data_files=data_files + data_files_dict.get(os.environ.get('CONFIG')), description='Google Compute Engine', include_package_data=True, install_requires=['boto'], |