diff options
author | Daniel Hwang <gnawhleinad@github.com> | 2016-09-06 18:18:05 -0700 |
---|---|---|
committer | Max Illfelder <illfelder@users.noreply.github.com> | 2016-09-06 18:18:05 -0700 |
commit | d30eb989abf658c2bdf07e39aa9e40054a316620 (patch) | |
tree | 0192f66b17d37e1ae8e3e96f857d861f71f93fe6 /google_config | |
parent | e25c427c1da7b12bbdb03a7e6d8610bbce5b11f5 (diff) | |
download | google-compute-image-packages-d30eb989abf658c2bdf07e39aa9e40054a316620.tar.gz |
Build packages by distro (#337)
Diffstat (limited to 'google_config')
-rwxr-xr-x | google_config/build_packages.sh | 81 |
1 files changed, 62 insertions, 19 deletions
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 |