diff options
-rwxr-xr-x | build_packages.sh | 61 | ||||
-rwxr-xr-x | google_compute_engine_init/build_packages.sh | 62 | ||||
-rwxr-xr-x | google_config/build_packages.sh | 81 |
3 files changed, 170 insertions, 34 deletions
diff --git a/build_packages.sh b/build_packages.sh index e669ca1..4298995 100755 --- a/build_packages.sh +++ b/build_packages.sh @@ -13,9 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Build the Linux guest environment deb and rpm packages. +#/ Usage: build_packages.sh [options] +#/ +#/ Build the Python package for Linux daemons, scripts, and libraries. +#/ +#/ OPTIONS: +#/ -h Show this message +#/ -o DISTRO,... Build only specified distros -TIMESTAMP="$(date +%s)" +function usage() { + grep '^#/' < "$0" | cut -c 4- +} function build_distro() { declare -r distro="$1" @@ -48,10 +56,47 @@ function build_distro() { setup.py } -# RHEL/CentOS -build_distro 'el6' 'rpm' '/usr/lib/python2.6/site-packages' -build_distro 'el7' 'rpm' '/usr/lib/python2.7/site-packages' +TIMESTAMP="$(date +%s)" + +while getopts 'ho:' OPTION; do + case "$OPTION" in + h) + usage + exit 2 + ;; + o) + set -f + IFS=',' + BUILD=($OPTARG) + set +f + ;; + ?) + usage + exit + ;; + esac +done + +if [ -z "$BUILD" ]; then + BUILD=('el6' 'el7' 'wheezy' 'jessie') +fi -# Debian -build_distro 'wheezy' 'deb' '/usr/lib/python2.7/dist-packages' -build_distro 'jessie' 'deb' '/usr/lib/python2.7/dist-packages' +for build in "${BUILD[@]}"; do + case "$build" in + el6) # RHEL/CentOS 6 + build_distro 'el6' 'rpm' '/usr/lib/python2.6/site-packages' + ;; + el7) # RHEL/CentOS 7 + build_distro 'el7' 'rpm' '/usr/lib/python2.7/site-packages' + ;; + wheezy) # Debian 7 + build_distro 'wheezy' 'deb' '/usr/lib/python2.7/dist-packages' + ;; + jessie) # Debian 8 + build_distro 'jessie' 'deb' '/usr/lib/python2.7/dist-packages' + ;; + *) + echo "Invalid build '${build}'. Use 'el6', 'el7', 'wheezy', or 'jessie'." + ;; + esac +done diff --git a/google_compute_engine_init/build_packages.sh b/google_compute_engine_init/build_packages.sh index ce119ad..4d8c20b 100755 --- a/google_compute_engine_init/build_packages.sh +++ b/google_compute_engine_init/build_packages.sh @@ -13,7 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -TIMESTAMP="$(date +%s)" +#/ Usage: build_packages.sh [options] +#/ +#/ Build the package that contains init configuration for the +#/ google-compute-engine Python package. +#/ +#/ OPTIONS: +#/ -h Show this message +#/ -o DISTRO,... Build only specified distros + +function usage() { + grep '^#/' < "$0" | cut -c 4- +} function build_distro() { declare -r distro="$1" @@ -63,10 +74,47 @@ function build_distro() { "${init_files[@]}" } -# RHEL/CentOS -build_distro 'el6' 'rpm' 'upstart' '/etc/init' -build_distro 'el7' 'rpm' 'systemd' '/usr/lib/systemd/system' +TIMESTAMP="$(date +%s)" + +while getopts 'ho:' OPTION; do + case "$OPTION" in + h) + usage + exit 2 + ;; + o) + set -f + IFS=',' + BUILD=($OPTARG) + set +f + ;; + ?) + usage + exit + ;; + esac +done + +if [ -z "$BUILD" ]; then + BUILD=('el6' 'el7' 'wheezy' 'jessie') +fi -# Debian -build_distro 'wheezy' 'deb' 'sysvinit' '/etc/init.d' -build_distro 'jessie' 'deb' 'systemd' '/usr/lib/systemd/system' +for build in "${BUILD[@]}"; do + case "$build" in + el6) # RHEL/CentOS 6 + build_distro 'el6' 'rpm' 'upstart' '/etc/init' + ;; + el7) # RHEL/CentOS 7 + build_distro 'el7' 'rpm' 'systemd' '/usr/lib/systemd/system' + ;; + wheezy) # Debian 7 + build_distro 'wheezy' 'deb' 'sysvinit' '/etc/init.d' + ;; + jessie) # Debian 8 + build_distro 'jessie' 'deb' 'systemd' '/usr/lib/systemd/system' + ;; + *) + echo "Invalid build '${build}'. Use 'el6', 'el7', 'wheezy', or 'jessie'." + ;; + esac +done diff --git a/google_config/build_packages.sh b/google_config/build_packages.sh index af35e7d..00acc2a 100755 --- a/google_config/build_packages.sh +++ b/google_config/build_packages.sh @@ -13,12 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -COMMON_FILES=( - 'rsyslog/90-google.conf=/etc/rsyslog.d/90-google.conf' - 'sysctl/11-gce-network-security.conf=/etc/sysctl.d/11-gce-network-security.conf' - 'udev/64-gce-disk-removal.rules=/etc/udev/rules.d/64-gce-disk-removal.rules' - 'udev/65-gce-disk-naming.rules=/etc/udev/rules.d/65-gce-disk-naming.rules') -TIMESTAMP="$(date +%s)" +#/ Usage: build_packages.sh [options] +#/ +#/ Build the package containing non-Python scripts and guest configuration. +#/ +#/ OPTIONS: +#/ -h Show this message +#/ -o DISTRO,... Build only specified distros + +function usage() { + grep '^#/' < "$0" | cut -c 4- +} function build_distro() { declare -r distro="$1" @@ -46,19 +51,57 @@ function build_distro() { "${files[@]:2}" } -# RHEL/CentOS 6 -build_distro 'el6' 'rpm' \ - 'bin/set_hostname=/etc/dhcp/dhclient-exit-hooks' +COMMON_FILES=( + 'rsyslog/90-google.conf=/etc/rsyslog.d/90-google.conf' + 'sysctl/11-gce-network-security.conf=/etc/sysctl.d/11-gce-network-security.conf' + 'udev/64-gce-disk-removal.rules=/etc/udev/rules.d/64-gce-disk-removal.rules' + 'udev/65-gce-disk-naming.rules=/etc/udev/rules.d/65-gce-disk-naming.rules') +TIMESTAMP="$(date +%s)" -# RHEL/CentOS 7 -build_distro 'el7' 'rpm' \ - 'bin/set_hostname=/usr/bin/set_hostname' \ - 'dhcp/google_hostname.sh=/etc/dhcp/dhclient.d/google_hostname.sh' +while getopts 'ho:' OPTION; do + case "$OPTION" in + h) + usage + exit 2 + ;; + o) + set -f + IFS=',' + BUILD=($OPTARG) + set +f + ;; + ?) + usage + exit + ;; + esac +done -# Debian 7 -build_distro 'wheezy' 'deb' \ - 'bin/set_hostname=/etc/dhcp/dhclient-exit-hooks.d/set_hostname' +if [ -z "$BUILD" ]; then + BUILD=('el6' 'el7' 'wheezy' 'jessie') +fi -# Debian 8 -build_distro 'jessie' 'deb' \ - 'bin/set_hostname=/etc/dhcp/dhclient-exit-hooks.d/set_hostname' +for build in "${BUILD[@]}"; do + case "$build" in + el6) # RHEL/CentOS 6 + build_distro 'el6' 'rpm' \ + 'bin/set_hostname=/etc/dhcp/dhclient-exit-hooks' + ;; + el7) # RHEL/CentOS 7 + build_distro 'el7' 'rpm' \ + 'bin/set_hostname=/usr/bin/set_hostname' \ + 'dhcp/google_hostname.sh=/etc/dhcp/dhclient.d/google_hostname.sh' + ;; + wheezy) # Debian 7 + build_distro 'wheezy' 'deb' \ + 'bin/set_hostname=/etc/dhcp/dhclient-exit-hooks.d/set_hostname' + ;; + jessie) # Debian 8 + build_distro 'jessie' 'deb' \ + 'bin/set_hostname=/etc/dhcp/dhclient-exit-hooks.d/set_hostname' + ;; + *) + echo "Invalid build '${build}'. Use 'el6', 'el7', 'wheezy', or 'jessie'." + ;; + esac +done |