mirror of
https://github.com/rocky-linux/sig-cloud-instance-images.git
synced 2024-12-18 15:18:35 +00:00
parent
f7a74536c0
commit
9faa504140
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@ -17,6 +17,10 @@ jobs:
|
|||||||
architecture:
|
architecture:
|
||||||
- x64
|
- x64
|
||||||
- ARM64
|
- ARM64
|
||||||
|
variant:
|
||||||
|
- Base
|
||||||
|
- Minimal
|
||||||
|
- UBI
|
||||||
runs-on:
|
runs-on:
|
||||||
- self-hosted
|
- self-hosted
|
||||||
- ${{ matrix.architecture }}
|
- ${{ matrix.architecture }}
|
||||||
@ -25,10 +29,10 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Build images
|
- name: Build images
|
||||||
run: make
|
run: make VARIANT=${{ matrix.variant }}
|
||||||
|
|
||||||
- name: Get image name
|
- name: Get image name
|
||||||
run: echo "ARTIFACT_NAME=$(make publish)" >> $GITHUB_ENV
|
run: echo "ARTIFACT_NAME=$(make publish VARIANT=${{ matrix.variant }})" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
|
34
Makefile
34
Makefile
@ -1,33 +1,34 @@
|
|||||||
ARCH = $(shell uname -m)
|
ARCH = $(shell uname -m)
|
||||||
BUILDDATE = $(shell /bin/date +%Y%m%d_%H%M)
|
BUILDDATE = $(shell /bin/date +%Y%m%d_%H%M)
|
||||||
KICKSTART_DIR = kickstarts
|
|
||||||
KICKSTART_PATH = "${KICKSTART_DIR}/Rocky-8-Container.ks"
|
|
||||||
LOG_DIR = logs
|
LOG_DIR = logs
|
||||||
OUT = out
|
OUT = out
|
||||||
RELEASE_VER = 8.6
|
RELEASE_VER = 8.6
|
||||||
MAJOR = $(shell v='$(RELEASE_VER)'; echo "$${v%.*}")
|
MAJOR = $(shell v='$(RELEASE_VER)'; echo "$${v%.*}")
|
||||||
TEMPLATE_DIR = templates
|
TEMPLATE_DIR = templates
|
||||||
TEMPLATE_PATH = "${TEMPLATE_DIR}/tdl-${ARCH}.xml"
|
TEMPLATE_PATH = "${TEMPLATE_DIR}/tdl-${ARCH}.xml"
|
||||||
|
|
||||||
OUTNAME := rocky-${RELEASE_VER}-docker
|
|
||||||
BASEIMAGE_META := base_image-$(OUTNAME).meta
|
|
||||||
TARGETIMAGE_META := target_image-$(OUTNAME).meta
|
|
||||||
|
|
||||||
STORAGEDIR := /var/lib/imagefactory/storage
|
STORAGEDIR := /var/lib/imagefactory/storage
|
||||||
|
|
||||||
.PHONY := all clean setup
|
|
||||||
.DEFAULT_GOAL := $(OUTNAME).tar.xz
|
|
||||||
|
|
||||||
BASEIMAGEUUID = $(shell awk '$$1=="UUID:"{print $$NF}' $(BASEIMAGE_META))
|
|
||||||
TARGETIMAGEUUID = $(shell awk '$$1=="UUID:"{print $$NF}' $(TARGETIMAGE_META))
|
|
||||||
|
|
||||||
ifneq ($(DEBUG),)
|
ifneq ($(DEBUG),)
|
||||||
DEBUGPARAM := --debug
|
DEBUGPARAM := --debug
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Basic type is just 'container'
|
# Basic type is just 'container'
|
||||||
TYPE=container
|
TYPE=Container
|
||||||
CONTAINER_NAME = rocky-$(MAJOR)-$(TYPE)-$(RELEASE_VER).$(BUILDDATE).$(ARCH)
|
VARIANT=Base
|
||||||
|
CONTAINER_NAME = Rocky-$(MAJOR)-$(TYPE)-$(VARIANT)-$(RELEASE_VER).$(BUILDDATE).$(ARCH)
|
||||||
|
|
||||||
|
KICKSTART_DIR = kickstarts
|
||||||
|
KICKSTART_PATH = "${KICKSTART_DIR}/Rocky-8-${TYPE}-${VARIANT}.ks"
|
||||||
|
|
||||||
|
OUTNAME := rocky-${RELEASE_VER}-${TYPE}-${VARIANT}
|
||||||
|
BASEIMAGE_META := base_image-$(OUTNAME).meta
|
||||||
|
TARGETIMAGE_META := target_image-$(OUTNAME).meta
|
||||||
|
BASEIMAGEUUID = $(shell awk '$$1=="UUID:"{print $$NF}' $(BASEIMAGE_META))
|
||||||
|
TARGETIMAGEUUID = $(shell awk '$$1=="UUID:"{print $$NF}' $(TARGETIMAGE_META))
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY := all clean setup
|
||||||
|
.DEFAULT_GOAL := $(OUTNAME).tar.xz
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm *.meta
|
-rm *.meta
|
||||||
@ -36,7 +37,8 @@ publish:
|
|||||||
@echo $(OUTNAME)-$(ARCH).tar.xz
|
@echo $(OUTNAME)-$(ARCH).tar.xz
|
||||||
|
|
||||||
$(KICKSTART_DIR):
|
$(KICKSTART_DIR):
|
||||||
git clone --branch r$(MAJOR) --single-branch https://git.rockylinux.org/rocky/kickstarts.git kickstarts
|
git clone --branch r$(MAJOR) --single-branch https://git.resf.org/sig_core/kickstarts.git kickstarts
|
||||||
|
sed -i 's/$$basearch/$(ARCH)/g' kickstarts/*.ks
|
||||||
|
|
||||||
$(BASEIMAGE_META): $(KICKSTART_DIR)
|
$(BASEIMAGE_META): $(KICKSTART_DIR)
|
||||||
sudo imagefactory $(DEBUGPARAM) base_image \
|
sudo imagefactory $(DEBUGPARAM) base_image \
|
||||||
|
120
tools/fetch-and-branch.sh
Normal file
120
tools/fetch-and-branch.sh
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
version=${1}
|
||||||
|
type=${2}
|
||||||
|
arch=${3}
|
||||||
|
date=${4:-$(date +%Y%m%d)}
|
||||||
|
revision=${5:-0}
|
||||||
|
|
||||||
|
major=${1:0:1}
|
||||||
|
minor=${1:2:1}
|
||||||
|
TEMPLATE="library-template"
|
||||||
|
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
printf "%s: RELEASE TYPE ARCH [DATE]\n\n" $0
|
||||||
|
log "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
log() {
|
||||||
|
printf "[%s] :: %s\n" "$(date -Isec)" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
log-cmd() {
|
||||||
|
set -x
|
||||||
|
command $@
|
||||||
|
set +x
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -z "$version" || ! "$version" =~ [0-9]+.[0-9]+ ]]; then
|
||||||
|
usage "Invalid or empty version"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$type" in
|
||||||
|
Base|Minimal) ;;
|
||||||
|
*)
|
||||||
|
usage "Invalid type"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pattern=$(printf "Rocky-%s.%s-%s-%s" "$version" "$date" "$type" "$arch")
|
||||||
|
|
||||||
|
has-branch(){
|
||||||
|
local res=$(log-cmd git branch --list "$1")
|
||||||
|
if [[ -z $res ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
current-branch() {
|
||||||
|
local res=$(log-cmd git branch --show-current)
|
||||||
|
ret=0
|
||||||
|
if [[ ! -z $res ]]; then
|
||||||
|
ret=1
|
||||||
|
fi
|
||||||
|
echo $res
|
||||||
|
return $ret
|
||||||
|
}
|
||||||
|
|
||||||
|
generate-packagelist() {
|
||||||
|
log "Generating package list"
|
||||||
|
if [[ -f build.meta ]]; then
|
||||||
|
log-cmd xmllint --xpath "//packages/*/@name" <(printf "$(jq '.icicle' < build.meta)\n" | tr -d '\\' | tail -c +2 | head -c -2) | \
|
||||||
|
awk -F\= '{print substr($2,2,length($2)-2)}' | \
|
||||||
|
sort > packages.txt
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
log "No build.meta found. Skipping packagelist generation"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
generate-filelist() {
|
||||||
|
log "Generating filelist"
|
||||||
|
if [[ -f layer.tar.xz ]]; then
|
||||||
|
log-cmd tar -tf layer.tar.xz > filelist.txt
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
log "No layer.tar.xz found. Skipping filelist generation"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
latest-build() {
|
||||||
|
local path=$(printf "s3://resf-empanadas/buildimage-%s-%s/Rocky-%s-Container-%s-%s-%s.%s.%s" $version $arch $major $type $version $date $revision $arch)
|
||||||
|
local res=$(log-cmd aws --region us-east-2 --profile resf-peridot-prod s3 ls --recursive "$path" | sort | tail -1 | awk '{print $4}' | sed 's,^\(.*\)/.*$,\1,g')
|
||||||
|
echo "$res"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if has-branch $pattern; then
|
||||||
|
usage "Branch ${pattern} already exists. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Creating branch ${pattern}"
|
||||||
|
|
||||||
|
log-cmd git checkout -b "${pattern}" $TEMPLATE
|
||||||
|
|
||||||
|
branch=$(current-branch)
|
||||||
|
if [[ "${branch}" != "${pattern}" ]]; then
|
||||||
|
log "Not on the proper branch after creation. Exiting for safety."
|
||||||
|
exit 127
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clear the history of the branch (Required for Docker Hub Official Images to only have one commit on the branch)
|
||||||
|
log-cmd git update-ref -d HEAD
|
||||||
|
|
||||||
|
builddir=$(latest-build)
|
||||||
|
if [[ -z "$builddir" ]]; then
|
||||||
|
log "Builddir not found. Exiting"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
log-cmd aws --region us-east-2 --profile resf-peridot-prod s3 sync "s3://resf-empanadas/$builddir" $PWD
|
||||||
|
|
||||||
|
generate-packagelist
|
||||||
|
generate-filelist
|
Loading…
Reference in New Issue
Block a user