diff --git a/Makefile-RHEL b/Makefile-RHEL index 11f552c..af0bd47 100644 --- a/Makefile-RHEL +++ b/Makefile-RHEL @@ -1,4 +1,4 @@ -# © Copyright IBM Corporation 2018 +# © Copyright IBM Corporation 2018, 2019 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,8 +27,8 @@ MQ_ARCHIVE ?= IBM_MQ_$(MQ_VERSION)_LINUX_$(MQ_ARCHIVE_ARCH).tar.gz # MQ_ARCHIVE_DEV is the name of the file, under the downloads directory, from which MQ Advanced # for Developers can be installed MQ_ARCHIVE_DEV ?= $(MQ_ARCHIVE_DEV_$(MQ_VERSION)) -# MQ_SDK_ARCHIVE specifies the archive to use for building the golang programs. Defaults vary on developer or advanced. -MQ_SDK_ARCHIVE ?= $(MQ_ARCHIVE_DEV_$(MQ_VERSION)) +# MQ_SDK_ARCHIVE specifies the archive to use for the MQ redistributable client, which is used for building the golang programs. +MQ_SDK_ARCHIVE ?= $(MQ_VERSION)-IBM-MQC-Redist-LinuxX64.tar.gz # Options to `go test` for the Docker tests TEST_OPTS_DOCKER ?= # MQ_IMAGE_ADVANCEDSERVER is the name and tag of the built MQ Advanced image @@ -78,7 +78,7 @@ endif # Archive names for IBM MQ Advanced for Developers MQ_ARCHIVE_DEV_9.0.5.0=mqadv_dev905_linux_x86-64.tar.gz MQ_ARCHIVE_DEV_9.1.0.0=mqadv_dev910_linux_$(MQ_DEV_ARCH).tar.gz -MQ_ARCHIVE_DEV_9.1.1.0=mqadv_dev910_linux_$(MQ_DEV_ARCH).tar.gz +MQ_ARCHIVE_DEV_9.1.1.0=mqadv_dev911_linux_$(MQ_DEV_ARCH).tar.gz ############################################################################### # Build targets @@ -113,9 +113,9 @@ downloads/$(MQ_ARCHIVE_DEV): cd downloads; curl -LO https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/$(MQ_ARCHIVE_DEV) downloads/$(MQ_SDK_ARCHIVE): - $(info $(SPACER)$(shell printf $(TITLE)"Downloading IBM MQ Advanced for Developers "$(MQ_VERSION)$(END))) + $(info $(SPACER)$(shell printf $(TITLE)"Downloading IBM MQ Advanced redistributable client "$(MQ_VERSION)$(END))) mkdir -p downloads - cd downloads; curl -LO https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/$(MQ_SDK_ARCHIVE) + cd downloads; curl -LO https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist/$(MQ_SDK_ARCHIVE) .PHONY: downloads downloads: downloads/$(MQ_ARCHIVE_DEV) downloads/$(MQ_SDK_ARCHIVE) @@ -133,7 +133,7 @@ check-prereqs: yum list | grep yum-utils || (echo "Missing required package yum-utils" && exit 1) .PHONY: check-test-prereqs -check-prereqs: +check-test-prereqs: $(info $(SPACER)$(shell printf $(TITLE)"Checking for prereqs"$(END))) which buildah || (echo "Missing required program buildah" && exit 1) which docker || (echo "Missing required program docker" && exit 1) @@ -155,14 +155,12 @@ test-devserver: check-test-prereqs test/docker/vendor .PHONY: build-advancedserver -build-advancedserver: MQ_SDK_ARCHIVE=$(MQ_ARCHIVE) build-advancedserver: check-prereqs downloads/$(MQ_ARCHIVE) build-go-programs-ex $(info $(SPACER)$(shell printf $(TITLE)"Build $(MQ_IMAGE_ADVANCEDSERVER)"$(END))) sudo mq-advanced-server-rhel/mq-buildah.sh "$(MQ_ARCHIVE)" "$(MQ_PACKAGES)" "$(MQ_IMAGE_ADVANCEDSERVER)" "$(MQ_VERSION)" "$(MQDEV)" .PHONY: build-devserver -build-devserver: MQ_SDK_ARCHIVE=$(MQ_ARCHIVE_DEV) build-devserver: MQDEV=TRUE build-devserver: MQ_PACKAGES=MQSeriesRuntime-*.rpm MQSeriesServer-*.rpm MQSeriesJava*.rpm MQSeriesJRE*.rpm MQSeriesGSKit*.rpm MQSeriesMsg*.rpm MQSeriesSamples*.rpm MQSeriesAMS-*.rpm MQSeriesWeb-*.rpm build-devserver: check-prereqs downloads/$(MQ_ARCHIVE_DEV) build-go-programs-ex diff --git a/mq-advanced-server-rhel/go-build.sh b/mq-advanced-server-rhel/go-build.sh index 831ba41..eeb17f8 100755 --- a/mq-advanced-server-rhel/go-build.sh +++ b/mq-advanced-server-rhel/go-build.sh @@ -1,6 +1,6 @@ #!/bin/bash # -*- mode: sh -*- -# © Copyright IBM Corporation 2018 +# © Copyright IBM Corporation 2018, 2019 # # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,9 +17,11 @@ # Builds and tests the golang programs used by the MQ image. -set -e +set -ex -cd $GOPATH/src/github.com/ibm-messaging/mq-container/ +# Handle a GOPATH with multiple entries (just choose the first one) +IFS=':' read -ra DIR <<< "$GOPATH" +cd ${DIR[0]}/src/github.com/ibm-messaging/mq-container/ # Build and test the Go code mkdir -p build diff --git a/mq-advanced-server-rhel/go-buildah.sh b/mq-advanced-server-rhel/go-buildah.sh index 9e9e63d..9a8d6a0 100755 --- a/mq-advanced-server-rhel/go-buildah.sh +++ b/mq-advanced-server-rhel/go-buildah.sh @@ -1,6 +1,6 @@ #!/bin/bash # -*- mode: sh -*- -# © Copyright IBM Corporation 2018 +# © Copyright IBM Corporation 2018, 2019 # # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,11 +35,11 @@ IMAGE_REVISION=${IMAGE_REVISION:="Not Applicable"} IMAGE_SOURCE=${IMAGE_SOURCE:="Not Applicable"} podman run \ - --volume ${PWD}:/go/src/github.com/ibm-messaging/mq-container/ \ - --env GOPATH=/go \ + --volume ${PWD}:/opt/app-root/src/go/src/github.com/ibm-messaging/mq-container/ \ --env IMAGE_REVISION="$IMAGE_REVISION" \ --env IMAGE_SOURCE="$IMAGE_SOURCE" \ --env MQDEV=${dev} \ + --user $(id -u) \ --rm \ ${tag} \ - bash -c "cd /go/src/github.com/ibm-messaging/mq-container/ && ./mq-advanced-server-rhel/go-build.sh" + bash -c "cd /opt/app-root/src/go/src/github.com/ibm-messaging/mq-container/ && ./mq-advanced-server-rhel/go-build.sh" diff --git a/mq-advanced-server-rhel/mq-buildah.sh b/mq-advanced-server-rhel/mq-buildah.sh index 719ca36..0c138eb 100755 --- a/mq-advanced-server-rhel/mq-buildah.sh +++ b/mq-advanced-server-rhel/mq-buildah.sh @@ -1,6 +1,6 @@ #!/bin/bash # -*- mode: sh -*- -# © Copyright IBM Corporation 2018 +# © Copyright IBM Corporation 2018, 2019 # # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,13 +17,13 @@ # Build a RHEL image, using the buildah tool # Usage -# mq-buildah.sh ARCHIVEFILE PACKAGES +# mq-buildah.sh ARCHIVE-NAME PACKAGES set -x set -e function usage { - echo "Usage: $0 ARCHIVENAME PACKAGES TAG VERSION MQDevFlag" + echo "Usage: $0 ARCHIVE-NAME PACKAGES TAG VERSION MQDevFlag" exit 20 } @@ -36,7 +36,8 @@ fi # Setup MQ server working container ############################################################################### -readonly ctr_mq=$(buildah from rhel7) +# Use RHEL 7 minimal container (which doesn't include things like Python or Yum) +readonly ctr_mq=$(buildah from rhel7-minimal) if [ -z "$ctr_mq" ] then echo "ERROR: ctr_mq is empty. Check above output for errors" @@ -60,13 +61,10 @@ readonly mqdev=$5 # Install MQ server ############################################################################### -groupadd --root ${mnt_mq} --system --gid 888 mqm -useradd --root ${mnt_mq} --system --uid 888 --gid mqm mqm -usermod --root ${mnt_mq} -aG root mqm -usermod --root ${mnt_mq} -aG mqm root - +# Use the Yum repositories configured on the host +cp /etc/yum.repos.d/* ${mnt_mq}/etc/yum.repos.d/ # Install the packages required by MQ -buildah run $ctr_mq -- yum install -y --setopt install_weak_deps=false --setopt=tsflags=nodocs --setopt=override_install_langs=en_US.utf8 \ +yum install -y --installroot=${mnt_mq} --setopt install_weak_deps=false --setopt=tsflags=nodocs --setopt=override_install_langs=en_US.utf8 \ bash \ bc \ coreutils \ @@ -78,12 +76,20 @@ buildah run $ctr_mq -- yum install -y --setopt install_weak_deps=false --setopt= passwd \ procps-ng \ sed \ + shadow-utils \ tar \ - util-linux + util-linux \ + which + +groupadd --root ${mnt_mq} --system --gid 888 mqm +useradd --root ${mnt_mq} --system --uid 888 --gid mqm mqm +usermod --root ${mnt_mq} -aG root mqm +usermod --root ${mnt_mq} -aG mqm root # Clean up cached files -buildah run $ctr_mq -- yum clean all +yum clean --installroot=${mnt_mq} all rm -rf ${mnt_mq}/var/cache/yum/* +rm -rf ${mnt_mq}/etc/yum.repos.d/* # Install MQ server packages into the MQ builder image ./mq-advanced-server-rhel/install-mq-rhel.sh ${ctr_mq} "${mnt_mq}" "${archive}" "${packages}" diff --git a/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh b/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh index 7874128..fbca330 100755 --- a/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh +++ b/mq-advanced-server-rhel/mq-golang-sdk-buildah.sh @@ -1,6 +1,6 @@ #!/bin/bash # -*- mode: sh -*- -# © Copyright IBM Corporation 2018 +# © Copyright IBM Corporation 2018, 2019 # # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,7 +20,7 @@ set -ex function usage { - echo "Usage: $0 ARCHIVENAME TAG" + echo "Usage: $0 REDIST-ARCHIVE-NAME TAG" exit 20 } @@ -29,41 +29,30 @@ if [ "$#" -ne 2 ]; then usage fi -readonly mq_archive=downloads/$1 +readonly mq_redist_archive=downloads/$1 readonly tag=$2 -# Use plain RHEL 7 container -# Note: Red Hat's devtools/go-toolset-7-rhel7 image doesn't allow use of 'root' -# user required for installing the MQ SDK -readonly ctr_mq=$(buildah from rhel7) +# Use Red Hat's Go toolset image as the base +readonly ctr_mq=$(buildah from devtools/go-toolset-7-rhel7) if [ -z "$ctr_mq" ] then echo "ERROR: ctr_mq is empty. Check above output for errors" exit 50 fi -readonly mnt_mq=$(buildah mount $ctr_mq) -if [ -z "$mnt_mq" ] +readonly mnt_mq_go=$(buildah mount $ctr_mq) +if [ -z "$mnt_mq_go" ] then - echo "ERROR: mnt_mq is empty. Check above output for errors" + echo "ERROR: mnt_mq_go is empty. Check above output for errors" exit 50 fi -# Add mqm user -sudo groupadd --root $mnt_mq --system --gid 888 mqm -sudo useradd --root $mnt_mq --system --uid 888 --gid mqm mqm -sudo usermod --root $mnt_mq -aG root mqm -sudo usermod --root $mnt_mq -aG mqm root +# Install the MQ redistributable client (including header files) into the Go builder image +mkdir -p ${mnt_mq_go}/opt/mqm +tar -xzf ${mq_redist_archive} -C ${mnt_mq_go}/opt/mqm -# Enable Yum repository for "optional" RPMs, which is needed for "golang" -buildah run ${ctr_mq} -- yum-config-manager --enable rhel-7-server-optional-rpms -# Install Go compiler -buildah run ${ctr_mq} -- yum install -y golang git gcc - -# Install the MQ SDK into the Go builder image -./mq-advanced-server-rhel/install-mq-rhel.sh ${ctr_mq} "${mnt_mq}" "${mq_archive}" "MQSeriesRuntime-*.rpm MQSeriesSDK-*.rpm MQSeriesSamples*.rpm" # Clean up Yum files -buildah run ${ctr_mq} -- yum clean all --releasever 7 -rm -rf ${mnt_mq}/var/cache/yum/* +rm -rf ${mnt_mq_go}/etc/yum.repos.d/* + buildah unmount ${ctr_mq} # Set environment variables for MQ/Go compilation buildah config \