diff --git a/.drone.yml b/.drone.yml index 952545a..eaed7a9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -72,7 +72,7 @@ steps: prerelease: true checksum: - sha256 - checksum_file: CHECKSUMsum-amd64.txt + checksum_file: CHECKSUMsum-centos7-amd64.txt checksum_flatten: true files: - "dist/centos7/x86_64/*" @@ -161,7 +161,7 @@ steps: prerelease: true checksum: - sha256 - checksum_file: CHECKSUMsum-srcrpm.txt + checksum_file: CHECKSUMsum-centos7-srcrpm.txt checksum_flatten: true files: - "dist/centos7/source/*.src.rpm" @@ -176,4 +176,183 @@ steps: volumes: - name: docker host: - path: /var/run/docker.sock \ No newline at end of file + path: /var/run/docker.sock +--- +kind: pipeline +name: rke2-packaging-centos8-x86_64-amd64 +platform: + os: linux + arch: amd64 +steps: +- name: build-rpm-centos8-x86_64-amd64 + image: rancher/dapper:v0.5.0 + environment: + COMBARCH: x86_64-amd64 + commands: + - dapper -f Dockerfile.centos8.dapper rpm/centos8/scripts/build + volumes: + - name: docker + path: /var/run/docker.sock + +- name: sign-rpm-centos8-x86_64-amd64 + image: centos:8 + environment: + PRIVATE_KEY: + from_secret: private_key + PRIVATE_KEY_PASS_PHRASE: + from_secret: private_key_pass_phrase + TESTING_PRIVATE_KEY: + from_secret: testing_private_key + TESTING_PRIVATE_KEY_PASS_PHRASE: + from_secret: testing_private_key_pass_phrase + commands: + - rpm/centos8/scripts/sign + when: + instance: + - drone-publish.rancher.io + ref: + - refs/head/master + - refs/tags/* + event: + - tag + +- name: yum-repo-upload-centos8-x86_64-amd64 + image: centos:7 + environment: + AWS_S3_BUCKET: + from_secret: aws_s3_bucket + AWS_ACCESS_KEY_ID: + from_secret: aws_access_key_id + AWS_SECRET_ACCESS_KEY: + from_secret: aws_secret_access_key + TESTING_AWS_S3_BUCKET: + from_secret: testing_aws_s3_bucket + TESTING_AWS_ACCESS_KEY_ID: + from_secret: testing_aws_access_key_id + TESTING_AWS_SECRET_ACCESS_KEY: + from_secret: testing_aws_secret_access_key + COMBARCH: x86_64-amd64 + commands: + - rpm/centos8/scripts/upload-repo + when: + instance: + - drone-publish.rancher.io + ref: + - refs/head/master + - refs/tags/* + event: + - tag + +- name: github-release-centos8-x86_64-amd64 + image: ibuildthecloud/github-release:v0.0.1 + settings: + api_key: + from_secret: github_token + prerelease: true + checksum: + - sha256 + checksum_file: CHECKSUMsum-centos8-amd64.txt + checksum_flatten: true + files: + - "dist/centos8/x86_64/*" + when: + instance: + - drone-publish.rancher.io + ref: + - refs/head/master + - refs/tags/* + event: + - tag +volumes: +- name: docker + host: + path: /var/run/docker.sock +--- +kind: pipeline +name: rke2-packaging-centos8-srcrpm +platform: + os: linux + arch: amd64 +steps: +- name: build-rpm-centos8-srcrpm + image: rancher/dapper:v0.5.0 + environment: + COMBARCH: x86_64-amd64 + commands: + - dapper -f Dockerfile.centos8.dapper rpm/centos8/scripts/build + volumes: + - name: docker + path: /var/run/docker.sock + +- name: sign-rpm-centos8-srcrpm + image: centos:8 + environment: + PRIVATE_KEY: + from_secret: private_key + PRIVATE_KEY_PASS_PHRASE: + from_secret: private_key_pass_phrase + TESTING_PRIVATE_KEY: + from_secret: testing_private_key + TESTING_PRIVATE_KEY_PASS_PHRASE: + from_secret: testing_private_key_pass_phrase + commands: + - rpm/centos8/scripts/sign + when: + instance: + - drone-publish.rancher.io + ref: + - refs/head/master + - refs/tags/* + event: + - tag + +- name: yum-repo-upload-centos8-srcrpm + image: centos:7 + environment: + AWS_S3_BUCKET: + from_secret: aws_s3_bucket + AWS_ACCESS_KEY_ID: + from_secret: aws_access_key_id + AWS_SECRET_ACCESS_KEY: + from_secret: aws_secret_access_key + TESTING_AWS_S3_BUCKET: + from_secret: testing_aws_s3_bucket + TESTING_AWS_ACCESS_KEY_ID: + from_secret: testing_aws_access_key_id + TESTING_AWS_SECRET_ACCESS_KEY: + from_secret: testing_aws_secret_access_key + commands: + - rpm/centos8/scripts/upload-srcrpm-repo + when: + instance: + - drone-publish.rancher.io + ref: + - refs/head/master + - refs/tags/* + event: + - tag + +- name: github-release-centos8-srcrpm + image: ibuildthecloud/github-release:v0.0.1 + settings: + api_key: + from_secret: github_token + prerelease: true + checksum: + - sha256 + checksum_file: CHECKSUMsum-centos8-srcrpm.txt + checksum_flatten: true + files: + - "dist/centos8/source/*.src.rpm" + when: + instance: + - drone-publish.rancher.io + ref: + - refs/head/master + - refs/tags/* + event: + - tag +volumes: +- name: docker + host: + path: /var/run/docker.sock diff --git a/Dockerfile.centos8.dapper b/Dockerfile.centos8.dapper new file mode 100644 index 0000000..a74ac73 --- /dev/null +++ b/Dockerfile.centos8.dapper @@ -0,0 +1,11 @@ +FROM centos:8 + +RUN yum install -y epel-release && yum -y install yum-utils rpm-build spectool git jq + +ENV DAPPER_SOURCE /source +ENV DAPPER_OUTPUT ./dist +ENV DAPPER_ENV COMBARCH DRONE_TAG TAG +ENV HOME ${DAPPER_SOURCE} +WORKDIR ${DAPPER_SOURCE} + +ENTRYPOINT ["./rpm/centos8/scripts/entry"] diff --git a/Makefile b/Makefile index 9b51a2c..e11b16e 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ COMBARCH ?= x86_64-amd64 ALL_ARCH = x86_64-amd64 aarch64-arm64 CENTOS7_TARGETS := $(addprefix centos7-,$(shell ls rpm/centos7/scripts)) +CENTOS8_TARGETS := $(addprefix centos8-,$(shell ls rpm/centos8/scripts)) .dapper: @echo Downloading dapper @@ -13,9 +14,17 @@ CENTOS7_TARGETS := $(addprefix centos7-,$(shell ls rpm/centos7/scripts)) $(CENTOS7_TARGETS): .dapper COMBARCH=${COMBARCH} ./.dapper -f Dockerfile.centos7.dapper $(@:centos7-%=%) +$(CENTOS8_TARGETS): .dapper + COMBARCH=${COMBARCH} ./.dapper -f Dockerfile.centos8.dapper $(@:centos8-%=%) + all-centos7-build: $(addprefix sub-centos7-build-,$(ALL_ARCH)) sub-centos7-build-%: - $(MAKE) COMBARCH=$* build + $(MAKE) COMBARCH=$* centos7-build + +all-centos8-build: $(addprefix sub-centos8-build-,$(ALL_ARCH)) + +sub-centos8-build-%: + $(MAKE) COMBARCH=$* centos8-build -.PHONY: $(CENTOS7_TARGETS) \ No newline at end of file +.PHONY: $(CENTOS7_TARGETS) $(CENTOS8_TARGETS) diff --git a/rpm/centos8/agent b/rpm/centos8/agent new file mode 120000 index 0000000..85b9f1b --- /dev/null +++ b/rpm/centos8/agent @@ -0,0 +1 @@ +../centos7/agent \ No newline at end of file diff --git a/rpm/centos8/common b/rpm/centos8/common new file mode 120000 index 0000000..e1ad8df --- /dev/null +++ b/rpm/centos8/common @@ -0,0 +1 @@ +../centos7/common \ No newline at end of file diff --git a/rpm/centos8/scripts/build b/rpm/centos8/scripts/build new file mode 100755 index 0000000..2829684 --- /dev/null +++ b/rpm/centos8/scripts/build @@ -0,0 +1,13 @@ +#!/bin/sh +set -ex + +cd "$(dirname $0)" + +if [[ -z "$COMBARCH" ]]; then + echo "Combined architecture was not defined, failing build" + exit 1 +fi + +./build-common +./build-server +./build-agent diff --git a/rpm/centos8/scripts/build-agent b/rpm/centos8/scripts/build-agent new file mode 100755 index 0000000..1c92e84 --- /dev/null +++ b/rpm/centos8/scripts/build-agent @@ -0,0 +1,37 @@ +#!/bin/bash +set -e -x + +cd $(dirname $0)/.. +. ./scripts/version + +if [[ -z "$COMBARCH" ]]; then + echo "Combined architecture was not defined, failing build" + exit 1 +fi + +IFS=- read RPMARCH GOARCH<<< ${COMBARCH}; unset IFS + +mkdir -p "/root/rpmbuild/SPECS" + +SRC_PATH="/root/rpmbuild/SOURCES/${RPMARCH}" +mkdir -p ${SRC_PATH} + +HOME=/root + +cp -r /source/rpm/centos8/agent/* ${SRC_PATH} +cp -r /source/rpm/centos8/agent/rke2-agent.spec /root/rpmbuild/SPECS + +cd ${SRC_PATH} + +rpmbuild \ + --define "rpm_version ${RPM_VERSION}" \ + --define "rke2_version ${RKE2_VERSION}" \ + --define "rpm_release ${RPM_RELEASE}" \ + --define "_sourcedir ${SRC_PATH}" \ + --target ${RPMARCH} \ + -ba ${SRC_PATH}/rke2-agent.spec + +mkdir -p /source/dist/centos8 +mkdir -p /source/dist/centos8/source +cp -r /root/rpmbuild/RPMS/* /source/dist/centos8 +cp -r /root/rpmbuild/SRPMS/* /source/dist/centos8/source diff --git a/rpm/centos8/scripts/build-common b/rpm/centos8/scripts/build-common new file mode 100755 index 0000000..0bb7b0d --- /dev/null +++ b/rpm/centos8/scripts/build-common @@ -0,0 +1,44 @@ +#!/bin/bash +set -e -x + +cd $(dirname $0)/.. +. ./scripts/version + +if [[ -z "$COMBARCH" ]]; then + echo "Combined architecture was not defined, failing build" + exit 1 +fi + +IFS=- read RPMARCH GOARCH<<< ${COMBARCH}; unset IFS + +mkdir -p "/root/rpmbuild/SPECS" + +SRC_PATH="/root/rpmbuild/SOURCES/${RPMARCH}" +mkdir -p ${SRC_PATH} + +HOME=/root + +cp -r /source/rpm/centos8/common/* ${SRC_PATH} +cp -r /source/rpm/centos8/common/rke2-common.spec /root/rpmbuild/SPECS + +sed -i "s/\%global ARCH.*/\%global ARCH ${GOARCH}/" ${SRC_PATH}/rke2-common.spec + +cd ${SRC_PATH} + +spectool -gf rke2-common.spec \ + --define "rke2_version ${RKE2_VERSION}" \ + --define "ARCH ${GOARCH}" + +rpmbuild -vv \ + --define "rpm_version ${RPM_VERSION}" \ + --define "rke2_version ${RKE2_VERSION}" \ + --define "rpm_release ${RPM_RELEASE}" \ + --define "rke2_policyver ${RKE2_POLICYVER}" \ + --define "_sourcedir ${SRC_PATH}" \ + --target ${RPMARCH} \ + -ba ${SRC_PATH}/rke2-common.spec + +mkdir -p /source/dist/centos8 +mkdir -p /source/dist/centos8/source +cp -r /root/rpmbuild/RPMS/* /source/dist/centos8 +cp -r /root/rpmbuild/SRPMS/* /source/dist/centos8/source diff --git a/rpm/centos8/scripts/build-server b/rpm/centos8/scripts/build-server new file mode 100755 index 0000000..58a1464 --- /dev/null +++ b/rpm/centos8/scripts/build-server @@ -0,0 +1,37 @@ +#!/bin/bash +set -e -x + +cd $(dirname $0)/.. +. ./scripts/version + +if [[ -z "$COMBARCH" ]]; then + echo "Combined architecture was not defined, failing build" + exit 1 +fi + +IFS=- read RPMARCH GOARCH<<< ${COMBARCH}; unset IFS + +mkdir -p "/root/rpmbuild/SPECS" + +SRC_PATH="/root/rpmbuild/SOURCES/${RPMARCH}" +mkdir -p ${SRC_PATH} + +HOME=/root + +cp -r /source/rpm/centos8/server/* ${SRC_PATH} +cp -r /source/rpm/centos8/server/rke2-server.spec /root/rpmbuild/SPECS + +cd ${SRC_PATH} + +rpmbuild \ + --define "rpm_version ${RPM_VERSION}" \ + --define "rke2_version ${RKE2_VERSION}" \ + --define "rpm_release ${RPM_RELEASE}" \ + --define "_sourcedir ${SRC_PATH}" \ + --target ${RPMARCH} \ + -ba ${SRC_PATH}/rke2-server.spec + +mkdir -p /source/dist/centos8 +mkdir -p /source/dist/centos8/source +cp -r /root/rpmbuild/RPMS/* /source/dist/centos8 +cp -r /root/rpmbuild/SRPMS/* /source/dist/centos8/source diff --git a/rpm/centos8/scripts/entry b/rpm/centos8/scripts/entry new file mode 100755 index 0000000..5a47439 --- /dev/null +++ b/rpm/centos8/scripts/entry @@ -0,0 +1,12 @@ +#!/bin/bash +set -ex + +if [ -e ./rpm/centos8/scripts/"$1" ]; then + ./rpm/centos8/scripts/"$@" +else + exec "$@" +fi + +if [ "$DAPPER_UID" -ne "-1" ]; then + chown -R $DAPPER_UID:$DAPPER_GID . +fi diff --git a/rpm/centos8/scripts/sign b/rpm/centos8/scripts/sign new file mode 100755 index 0000000..b6b7677 --- /dev/null +++ b/rpm/centos8/scripts/sign @@ -0,0 +1,45 @@ +#!/bin/bash +set -e -x + +yum install -y rpm-sign expect git + +pushd $(dirname $0)/.. +. ./scripts/version +popd + +cat <<\EOF >~/.rpmmacros +%_signature gpg +%_gpg_name ci@rancher.com +EOF + +case "$RPM_CHANNEL" in + "testing") + export PRIVATE_KEY_PASS_PHRASE=$TESTING_PRIVATE_KEY_PASS_PHRASE + if ! grep "BEGIN PGP PRIVATE KEY BLOCK" <<<"$TESTING_PRIVATE_KEY"; then + echo "TESTING_PRIVATE_KEY not defined, failing rpm sign" + exit 1 + fi + gpg --import - <<<"$TESTING_PRIVATE_KEY" + ;; + "latest"|"stable") + if ! grep "BEGIN PGP PRIVATE KEY BLOCK" <<<"$PRIVATE_KEY"; then + echo "PRIVATE_KEY not defined, failing rpm sign" + exit 1 + fi + gpg --import - <<<"$PRIVATE_KEY" + ;; + *) + echo "RPM_CHANNEL $RPM_CHANNEL does not match one of: [testing, latest, stable]" + exit 1 + ;; +esac + +expect </centos/8/ + +TARGET_S3_PATH="rke2/$RPM_CHANNEL/$RPM_MAJMIN/centos/8/$RPMARCH" + +case "$RPM_CHANNEL" in + "testing") + if [ -z "$TESTING_AWS_S3_BUCKET" ]; then + echo "TESTING_AWS_S3_BUCKET not defined, failing rpm upload" + exit 1 + fi + if [ -z "$TESTING_AWS_ACCESS_KEY_ID" ]; then + echo "TESTING_AWS_ACCESS_KEY_ID not defined, failing rpm upload" + exit 1 + fi + if [ -z "$TESTING_AWS_SECRET_ACCESS_KEY" ]; then + echo "TESTING_AWS_SECRET_ACCESS_KEY not defined, failing rpm upload" + exit 1 + fi + export AWS_ACCESS_KEY_ID=$TESTING_AWS_ACCESS_KEY_ID + export AWS_SECRET_ACCESS_KEY=$TESTING_AWS_SECRET_ACCESS_KEY + export AWS_S3_BUCKET=$TESTING_AWS_S3_BUCKET + ;; + "latest"|"stable") + if [ -z "$AWS_S3_BUCKET" ]; then + echo "AWS_S3_BUCKET not defined, failing rpm upload" + exit 1 + fi + if [ -z "$AWS_ACCESS_KEY_ID" ]; then + echo "AWS_ACCESS_KEY_ID not defined, failing rpm upload" + exit 1 + fi + if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then + echo "AWS_SECRET_ACCESS_KEY not defined, failing rpm upload" + exit 1 + fi + ;; + *) + echo "RPM_CHANNEL $RPM_CHANNEL does not match one of: [testing, latest, stable]" + exit 1 + ;; +esac + +rpm-s3 --bucket $AWS_S3_BUCKET -p $TARGET_S3_PATH dist/centos8/$RPMARCH/rke2-*.rpm diff --git a/rpm/centos8/scripts/upload-srcrpm-repo b/rpm/centos8/scripts/upload-srcrpm-repo new file mode 100755 index 0000000..f1886c5 --- /dev/null +++ b/rpm/centos8/scripts/upload-srcrpm-repo @@ -0,0 +1,65 @@ +#!/bin/bash +set -e -x + +pushd $(dirname $0)/.. +. ./scripts/version +popd + +yum install -y epel-release +yum install -y git python2-pip python-deltarpm +pip install --cache-dir=/var/cache/pip/ \ + git+git://github.com/Voronenko/rpm-s3.git@5695c6ad9a08548141d3713328e1bd3f533d137e + +if [ -z "$RPM_MAJMIN" ]; then + echo "RPM_MAJMIN not defined, failing rpm upload" + exit 1 +fi + +if [ -z "$RPM_CHANNEL" ]; then + echo "RPM_PATH not defined, failing rpm upload" + exit 1 +fi + +# Desired TARGET_S3_PATH would be something like rke2//centos/7/source + +TARGET_S3_PATH="rke2/$RPM_CHANNEL/$RPM_MAJMIN/centos/8/source" + +case "$RPM_CHANNEL" in + "testing") + if [ -z "$TESTING_AWS_S3_BUCKET" ]; then + echo "TESTING_AWS_S3_BUCKET not defined, failing rpm upload" + exit 1 + fi + if [ -z "$TESTING_AWS_ACCESS_KEY_ID" ]; then + echo "TESTING_AWS_ACCESS_KEY_ID not defined, failing rpm upload" + exit 1 + fi + if [ -z "$TESTING_AWS_SECRET_ACCESS_KEY" ]; then + echo "TESTING_AWS_SECRET_ACCESS_KEY not defined, failing rpm upload" + exit 1 + fi + export AWS_ACCESS_KEY_ID=$TESTING_AWS_ACCESS_KEY_ID + export AWS_SECRET_ACCESS_KEY=$TESTING_AWS_SECRET_ACCESS_KEY + export AWS_S3_BUCKET=$TESTING_AWS_S3_BUCKET + ;; + "latest"|"stable") + if [ -z "$AWS_S3_BUCKET" ]; then + echo "AWS_S3_BUCKET not defined, failing rpm upload" + exit 1 + fi + if [ -z "$AWS_ACCESS_KEY_ID" ]; then + echo "AWS_ACCESS_KEY_ID not defined, failing rpm upload" + exit 1 + fi + if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then + echo "AWS_SECRET_ACCESS_KEY not defined, failing rpm upload" + exit 1 + fi + ;; + *) + echo "RPM_CHANNEL $RPM_CHANNEL does not match one of: [testing, latest, stable]" + exit 1 + ;; +esac + +rpm-s3 --bucket $AWS_S3_BUCKET -p $TARGET_S3_PATH dist/centos8/source/rke2-*.src.rpm diff --git a/rpm/centos8/scripts/version b/rpm/centos8/scripts/version new file mode 100755 index 0000000..166883b --- /dev/null +++ b/rpm/centos8/scripts/version @@ -0,0 +1,109 @@ +#!/bin/bash +set -x + +# This version script expects either a tag of format: .. or no tag at all. + +RKE2_POLICYVER=0.1-1 #@TODO: Move this to a more global location. +RKE2_FALLBACKVER=v1.18.4-alpha15+rke2 + +TREE_STATE=clean +COMMIT=${COMMIT:-${DRONE_COMMIT:-${GITHUB_SHA:-unknown}}} +TAG=${TAG:-${DRONE_TAG:-$GITHUB_TAG}} + +# If we're in a dapperized environment, we should be able to figure out what our current tag and commit are. + +if [ -d ${DAPPER_SOURCE}/.git ]; then + pushd ${DAPPER_SOURCE} + + if [ -n "$(git status --porcelain --untracked-files=no)" ]; then + DIRTY="dirty" + TREE_STATE=dirty + fi + + if [[ "$TREE_STATE" == "clean" && -z "$TAG" ]]; then + TAG=$(git tag -l --contains HEAD | head -n 1) # this is going to not work if you have multiple tags pointing to the same commit + fi + + COMMIT=$(git rev-parse HEAD) + if [ -z "$COMMIT" ]; then + COMMIT=$(git rev-parse HEAD || true) + echo $COMMIT + exit 1 + fi + popd +fi + +if [[ -n "$TAG" ]]; then + if [[ "$TREE_STATE" = "clean" ]]; then + VERSION=$TAG # We will only accept the tag as our version if the tree state is clean and the tag is in fact defined. + fi +fi + +# In the event of us doing a build with no corresponding tag that we can discern, we'll go ahead and just build the package assuming we were dealing with master. +# This means we'll go to GitHub and pull the latest RKE2 release, and parse it to what we are expecting. + +if [[ -z "$VERSION" ]]; then + + if [[ -z "$COMMIT" ]]; then # Validate our commit hash to make sure it's actually known, otherwise our version will be off. + echo "Unknown commit hash. Exiting." + exit 1 + fi + + VERSION=$(curl -v https://api.github.com/repos/rancher/rke2/releases | jq -r '[.[] | select(.assets[] | length > 2)][0].tag_name') + + if [[ -z "$VERSION" ]]; then # Fall back to a known good RKE2 version because we had an error pulling the latest + VERSION=$RKE2_FALLBACKVER + fi + + RKE2_VERSION=$VERSION # We can naively assume the latest tag we just pulled is our RKE version. + + rke2_commit_regex="s/\+rke2/-${COMMIT:0:8}${DIRTY}\+rke2/" + VERSION=$(sed -E -e "$rke2_commit_regex" <<<"$VERSION") # Because we are building without a tag, we can assume this is not an official release, so we'll tack the first 8 characters of our commit hash. + RPM_RELEASE="0" # Set our RPM release to 0. + +else # validate the tag format and create our RKE2_VERSION variable + + if ! [[ $TAG =~ ^v[0-9]{1}\.[0-9]{2}\.[0-9]+-*[a-zA-Z0-9]*\+rke2\.[a-z]+\.[0-9]+$ ]]; then + echo "Tag does not match our expected format. Exiting." + exit 1 + fi + + rke2_version_regex='s/^(v[^-+]*.*\+rke2).*$/\1/;' # will take v1.18.4-alpha9+rke2.testing.0 and provide "1.18.4-alpha9+rke2" + + RKE2_VERSION=$(sed -E -e "$rke2_version_regex" <<<"$VERSION") +fi + +rke2_rpm_version_regex='s/\-/~/g; s/^v?([^-+]*.*)\+.*$/\1/;' # will take v1.18.4-alpha9+rke2.testing.0 and provide "1.18.4~alpha9" +rke2_rpm_release_regex='s/^.*\.([0-9]*)$/\1/;' # will take v1.18.4-alpha9+rke2.testing.0 and provide "0" + +rke2_rpm_majmin_regex='s/^v([0-9]+.[0-9]*).*/\1/;' # will take v1.18.4-alpha9+rke2.testing.0 and provide "1.18" +rke2_rpm_channel_regex='s/^.*\.(.*)\.[0-9]+$/\1/;' # will take v1.18.4-alpha9+rke2.testing.0 and provide "testing" + +RPM_VERSION=$(sed -E -e "$rke2_rpm_version_regex" <<<"$VERSION") +RPM_RELEASE=$(sed -E -e "$rke2_rpm_release_regex" <<<"$VERSION") +RPM_MAJMIN=$(sed -E -e "$rke2_rpm_majmin_regex" <<<"$VERSION") +RPM_CHANNEL=$(sed -E -e "$rke2_rpm_channel_regex" <<<"$VERSION") + +if [[ "$RPM_RELEASE" == "$VERSION" ]]; then + RPM_RELEASE="0" +fi + +if [[ "$RPM_MAJMIN" == "$VERSION" ]]; then + echo "Unknown RPM_MAJMIN found: $RPM_MAJMIN" + exit 1 +fi + +if [[ "$RPM_CHANNEL" == "$VERSION" ]]; then + echo "Unknown RPM_CHANNEL found: $RPM_CHANNEL but defaulting to testing" + RPM_CHANNEL="testing" +fi + +case "$RPM_CHANNEL" in + "testing"|"latest"|"stable") + echo "RPM_CHANNEL matched our expected variants" + ;; + *) + echo "RPM_CHANNEL $RPM_CHANNEL does not match one of: [testing, latest, stable]" + exit 1 + ;; +esac diff --git a/rpm/centos8/server b/rpm/centos8/server new file mode 120000 index 0000000..351ca20 --- /dev/null +++ b/rpm/centos8/server @@ -0,0 +1 @@ +../centos7/server \ No newline at end of file