diff --git a/.gitignore b/.gitignore index 2efc7621fd..42b319e3cd 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ Vagrantfile _output/* bin packaging/rpm/_rpmbuild/ +packaging/rpm/paack-result/ scripts/image-builder/_builds/ sshfile diff --git a/packaging/rpm/make-microshift-images-rpm.sh b/packaging/rpm/make-microshift-images-rpm.sh index a1c9fc27e2..c5550374a0 100755 --- a/packaging/rpm/make-microshift-images-rpm.sh +++ b/packaging/rpm/make-microshift-images-rpm.sh @@ -4,16 +4,8 @@ set -e -o pipefail # generated from other info SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" BASE_VERSION="$(${SCRIPT_DIR}/../../pkg/release/get.sh base)" - RPMBUILD_DIR="${SCRIPT_DIR}/_rpmbuild/" -BUILD=${BUILD:-$1} -BUILD=${BUILD:-rpm} -TARGET=${TARGET:-$2} -TARGET=${TARGET:-fedora-36-x86_64} RELEASE=${RELEASE:-1} -COPR_REPO=${COPR_REPO:-@redhat-et/microshift-containers} - -ARCHITECTURES=${ARCHITECTURES:-"x86_64:amd64 aarch64:arm64"} build() { cat >"${RPMBUILD_DIR}"microshift-images.yaml <> "${RPMBUILD_DIR}"microshift-images.yaml done - ${SCRIPT_DIR}/paack.py ${BUILD} "${RPMBUILD_DIR}"microshift-images.yaml -r "${RPMBUILD_DIR}" $BUILD_OPT + ${SCRIPT_DIR}/paack.py ${BUILD} "${RPMBUILD_DIR}"microshift-images.yaml -r "${RPMBUILD_DIR}" $BUILD_OPT +} +function usage() { + echo "Usage:" + echo " $(basename $0) rpm " + echo " $(basename $0) srpm " + echo " $(basename $0) copr " + echo "" + echo "pull_secret: Path to a file containing the OpenShift pull secret" + echo "architectures: One or more RPM architectures" + echo "rpm_mock_target: Target for building RPMs inside a chroot (e.g. 'rhel-8-x86_64')" + echo "copr_repo: Target Fedora Copr repository name (e.g. '@redhat-et/microshift-containers')" + echo "" + echo "Notes:" + echo " - The OpenShift pull secret can be downloaded from https://console.redhat.com/openshift/downloads#tool-pull-secret" + echo " - Use 'x86_64:amd64' or 'aarch64:arm64' as an architecture value" + echo " - See /etc/mock/*.cfg for possible RPM mock target values" + exit 1 } +# parse command line +BUILD=$1 +PULL_SECRET=$2 +ARCHITECTURES=$3 +case $BUILD in +rpm) + [ $# -ne 4 ] && usage + TARGET=$4 + ;; +srpm) + [ $# -ne 3 ] && usage + ;; +copr) + [ $# -ne 4 ] && usage + COPR_REPO=$4 + ;; +*) + usage +esac + # prepare the rpmbuild env mkdir -p "${RPMBUILD_DIR}"/{BUILD,RPMS,SOURCES,SPECS,SRPMS} +# pass pull secret as an environment variable +export REGISTRY_AUTH_FILE=$PULL_SECRET + +# run the build case $BUILD in - copr) BUILD_OPT=$COPR_REPO build;; - rpm) BUILD_OPT=$TARGET build;; - srpm) build;; - *) - echo "Usage: $0 [copr|rpm|srpm]" - exit 1 +rpm) + BUILD_OPT=$TARGET build + ;; +srpm) + build + ;; +copr) + BUILD_OPT=$COPR_REPO build + ;; esac diff --git a/packaging/rpm/paack.py b/packaging/rpm/paack.py index 43541221b8..7b8f4436c4 100755 --- a/packaging/rpm/paack.py +++ b/packaging/rpm/paack.py @@ -410,7 +410,11 @@ def _create_images_tarball(self, package, arch_info): for image in arch_info['images']: arch_name = arch_info.get('image_arch', arch_info['name']) print("pulling %s for arch %s, to %s" % (image, arch_name, directory)) - result = system('sudo podman pull --arch %s --root "%s" %s' % (arch_name, directory, image)) + auth_file = os.getenv('REGISTRY_AUTH_FILE') + if auth_file!='': + result = system('sudo podman pull --authfile %s --arch %s --root "%s" %s' % (auth_file, arch_name, directory, image)) + else: + result = system('sudo podman pull --arch %s --root "%s" %s' % ( arch_name, directory, image)) if result!=0: print("error pulling image") sys.exit(result)