Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ Vagrantfile
_output/*
bin
packaging/rpm/_rpmbuild/
packaging/rpm/paack-result/
scripts/image-builder/_builds/
sshfile
66 changes: 51 additions & 15 deletions packaging/rpm/make-microshift-images-rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
Expand Down Expand Up @@ -41,18 +33,62 @@ EOF
while read image; do echo " - $image"; done >> "${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 <pull_secret> <architectures> <rpm_mock_target>"
echo " $(basename $0) srpm <pull_secret> <architectures>"
echo " $(basename $0) copr <pull_secret> <architectures> <copr_repo>"
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
6 changes: 5 additions & 1 deletion packaging/rpm/paack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down