rocky-kiwi-descriptions/live-build.sh

105 lines
2.9 KiB
Bash
Raw Normal View History

2024-04-01 07:39:37 +00:00
#!/bin/bash
# helps build a quick live image. that way a user doesn't have to use emapandas
# nor livemedia-creator. mock is probably not necessary, but it's up to you.
# label@resf.org
set -o errexit
set -o pipefail
SCRNAME="$(basename "$0")"
SCRDIR="$(dirname "${BASH_SOURCE[0]}")"
export __usage
__usage="
usage: $SCRNAME [OPTIONS]
Options:
-o, --output-dir DIR
-l, --live-image NAME
2024-05-01 23:47:35 +00:00
-m, --minor NUM
2024-04-14 00:37:08 +00:00
-p, --peridot ID # optional. will use peridot repos.
2024-04-01 07:39:37 +00:00
-d, --debug # optional
"
2024-05-01 23:47:35 +00:00
OPTS=$(getopt -a -n live-build -o l:,o:,p:,m:,d,h \
-l live-image:,output-dir:,peridot:,minor:,debug,help -- "$@")
2024-04-01 07:39:37 +00:00
2024-04-02 02:28:38 +00:00
function is_in_path() {
builtin type -P "${1}"
}
2024-04-01 07:39:37 +00:00
function usage() {
echo "$__usage"
}
eval set -- "$OPTS"
while :; do
case "$1" in
-l | --live-image) LIVE="$2" ; shift 2 ;;
-o | --output-dir) OUTPUTDIR="$2" ; shift 2 ;;
2024-04-14 00:37:08 +00:00
-p | --peridot) PERIDOTID="$2" ; shift 2 ;;
2024-05-01 23:47:35 +00:00
-m | --minor) MINOR="$2" ; shift 2 ;;
2024-04-01 07:39:37 +00:00
-d | --debug) DEBUG="--debug" ; shift ;;
-h | --help) usage ;;
--) shift ; break ;;
esac
done
if [ -z "$LIVE" ] || [ -z "$OUTPUTDIR" ]; then
echo "Options are not set properly."
usage
exit 12
fi
if [ -e "/sys/fs/selinux/enforce" ]; then
enforce_check="$(cat /sys/fs/selinux/enforce)"
if [ "$enforce_check" -eq "1" ]; then
echo "Running with selinux enforcing is not recommended."
exit 22
fi
fi
2024-04-02 02:28:38 +00:00
is_in_path kiwi-ng &> /dev/null
ret_val=$?
if [ "$ret_val" -ne "0" ]; then
2024-04-01 07:39:37 +00:00
echo "kiwi-ng not found. kiwi packages are likely not installed on this system."
exit 32
fi
2024-04-14 00:37:08 +00:00
function switch_repo_to_peridot() {
ID="$1"
# https://yumrepofs.build.resf.org/v1/projects/${ID}/repo/
pushd repositories || { echo "not found"; exit 1; }
sed -i "s;ZZ_INTERNAL_BaseOS_REPO_URL_ZZ;https://yumrepofs.build.resf.org/v1/projects/${ID}/repo/BaseOS/\$basearch;g" core-peridot.xml
sed -i "s;ZZ_INTERNAL_AppStream_REPO_URL_ZZ;https://yumrepofs.build.resf.org/v1/projects/${ID}/repo/AppStream/\$basearch;g" core-peridot.xml
sed -i "s;ZZ_INTERNAL_CRB_REPO_URL_ZZ;https://yumrepofs.build.resf.org/v1/projects/${ID}/repo/CRB/\$basearch;g" core-peridot.xml
sed -i "s;ZZ_INTERNAL_extras_REPO_URL_ZZ;https://yumrepofs.build.resf.org/v1/projects/${ID}/repo/extras/\$basearch;g" core-peridot.xml
rm core.xml
2024-04-14 06:55:05 +00:00
ln -sf core-peridot.xml core.xml
2024-04-14 00:37:08 +00:00
popd
}
2024-04-01 07:39:37 +00:00
function main() {
/bin/rm config.xml
if [ ! -f "configs/rocky-live-${LIVE,,}.xml" ]; then
echo "${LIVE} was not found. Is it supported?"
exit 42
fi
2024-04-14 06:55:05 +00:00
ln -sf "configs/rocky-live-${LIVE,,}.xml" config.xml
2024-04-14 00:37:08 +00:00
if [ -n "$PERIDOTID" ]; then
switch_repo_to_peridot "${PERIDOTID}"
fi
2024-05-01 23:47:35 +00:00
if [ -n "$MINOR" ]; then
sed -i "s/Rocky-9-/Rocky-9-$MINOR-/g" components/live/*.xml
sed -i "s/Rocky-9-/Rocky-9.$MINOR-/g" configs/rocky-live-*.xml
fi
2024-05-01 22:26:37 +00:00
kiwi-ng $DEBUG --type="iso" --profile="$LIVE-Live" --color-output system build --description="$SCRDIR" --target-dir "$OUTPUTDIR"
2024-04-01 07:39:37 +00:00
}
main