drop container-build in root

This commit is contained in:
Louis Abel 2024-05-01 16:17:43 -07:00
parent ad58d6e53f
commit f3f2794ee8
Signed by: label
GPG Key ID: 2A6975660E424560
2 changed files with 122 additions and 0 deletions

99
container-build.sh Executable file
View File

@ -0,0 +1,99 @@
#!/bin/bash
# helps build a quick container image. that way a user doesn't have to use emapandas
# nor some other method. 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
-c, --container NAME
-p, --peridot ID # optional. will use peridot repos.
-d, --debug # optional
"
OPTS=$(getopt -a -n container-build -o c:,o:,p:,d,h \
-l container:,output-dir:,peridot:,debug,help -- "$@")
function is_in_path() {
builtin type -P "${1}"
}
function usage() {
echo "$__usage"
}
eval set -- "$OPTS"
while :; do
case "$1" in
-c | --container) CONTAINER="$2" ; shift 2 ;;
-o | --output-dir) OUTPUTDIR="$2" ; shift 2 ;;
-p | --peridot) PERIDOTID="$2" ; shift 2 ;;
-d | --debug) DEBUG="--debug" ; shift ;;
-h | --help) usage ;;
--) shift ; break ;;
esac
done
if [ -z "$CONTAINER" ] || [ -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
is_in_path kiwi-ng &> /dev/null
ret_val=$?
if [ "$ret_val" -ne "0" ]; then
echo "kiwi-ng not found. kiwi packages are likely not installed on this system."
exit 32
fi
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
ln -sf core-peridot.xml core.xml
popd
}
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
#ln -sf "configs/rocky-live-${LIVE,,}.xml" config.xml
ln -sf "configs/rocky.xml" config.xml
if [ -n "$PERIDOTID" ]; then
switch_repo_to_peridot "${PERIDOTID}"
fi
# shellcheck disable=SC2086
kiwi-ng $DEBUG --type="oci" --profile="Container-$CONTAINER" --color-output system build --description="$SCRDIR" --target-dir "$OUTPUTDIR"
}
main

View File

@ -14,6 +14,9 @@
<profile name="Vagrant-Vbox" description="Vagrant Vbox Image">
<requires profile="Core-Vagrant"/>
</profile>
<profile name="Vagrant-VMware" description="Vagrant VMware Image">
<requires profile="Core-Vagrant"/>
</profile>
</profiles>
<users profiles="Core-Vagrant">
@ -72,6 +75,24 @@
</type>
</preferences>
<!-- VMware is made as a libvirt image and converted later. This this profile
at your own risk. -->
<preferences profiles="Vagrant-VMware" arch="x86_64">
<type image="oem" format="vagrant"
filesystem="xfs"
bootpartition="true" bootpartsize="1000" bootfilesystem="xfs" efipartsize="100" firmware="uefi"
kernelcmdline="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop"
devicepersistency="by-uuid"
rootfs_label="rocky">
<oemconfig>
<oem-resize>false</oem-resize>
</oemconfig>
<bootloader name="grub2" timeout="1"/>
<size unit="G">10</size>
<vagrantconfig provider="libvirt" virtualsize="5"/>
</type>
</preferences>
<packages type="image" patternType="plusRecommended" profiles="Core-Vagrant">
<namedCollection name="core"/>
<ignore name="dracut-config-rescue"/>
@ -90,9 +111,11 @@
<package name="rsync"/>
<package name="yum-utils"/>
</packages>
<!--
<packages type="image" patternType="plusRecommended" profiles="Vagrant-Hyperv">
<package name="hyperv-daemons"/>
</packages>
-->
<packages type="image" patternType="plusRecommended" profiles="Vagrant-Libvirt">
<package name="hyperv-daemons"/>
<package name="qemu-guest-agent"/>