medium change set

This commit is contained in:
Danieliskot
2023-12-26 00:38:18 +01:00
parent 51ad55627c
commit 09218bf9b4
7 changed files with 60 additions and 49 deletions
+41 -29
View File
@@ -1,32 +1,37 @@
#!/usr/bin/env bash
. initrd/functions
set -eET -o pipefail
exec > >(tee -i /tmp/llf.log) 2>&1
cd "$(dirname $(readlink -f ${0}))"
cp -f $([ ${V} ]&&echo ${V}) config .config
for i in mksquashfs cpio gzip sed grep xorriso tar find file; do
if [ ! -x "$(command -v ${i})" ]; then
exec > >(tee -i /tmp/llf.log) 2>&1
#trap 'echo $(basename ${BASH_SOURCE[0]}):${LINENO}: "${BASH_COMMAND}"' DEBUG
set -eET -o pipefail
. initrd/functions||true
for i in mksquashfs cpio gzip sed grep xorriso tar find file grub-mkrescue; do
if [ ! -x "$(type -P ${i})" ]; then
progsNotFound+=(${i})
case ${i} in
mksquashfs) a="squashfs-tools";;
readelf) a="binutils";;
find) a="find-utils";;
grub-mkrescue) a="grub2";;
*) a="${i}"
esac
echo "Please install ${a} package to run this tool"
echo "Please install ${a} package"
false
fi
done
main()
{
local DATA ret tmpRoot utc v krnV
echo "KERNEL=\"${kernel}}\"" >>.config
echo "LMK=\"/lib/modules/\"" >>.config
krnV="$(file -bL ${kernel} | grep -o 'version .*' | cut -d' ' -f2)"
top="${PWD}"
INITRAMFS="${workTmpDir}/initRd"
DATA="${workTmpDir}/isoImage"
env DATA="${DATA}" INITRAMFS="${INITRAMFS}" V="${V}" top="${top}" initrd/create
cat <<eot >>.config
KERNEL='$(readlink -f ${kernel})'
LMK='/lib/modules/${krnV}'
eot
env INITRAMFS="${INITRAMFS}" V="${V}" top="${top}" LMK="/lib/modules/${krnV}" initrd/create||true
ret="${?}"
tmpRoot="${workTmpDir}/tmpRoot"
mkdir -p $([ ${V} ]&&echo ${V}) ${DATA}/changes ${DATA}/os/modules
@@ -52,7 +57,7 @@ main()
cp -f $([ ${V} ]&&echo ${V}) ${KERNEL} ${DATA}/vmlinuz
cd ${DATA}
utc="$(date +%s)"
v="$(git -C ${top} rev-parse HEAD 2>/dev/null|tr [:lower:] [:upper:]):$(git -C ${top} branch --show-current 2>/dev/null|tr [:lower:] [:upper:]):GIT"||v="INFINITY:PRIVATE:LOCAL"
v="$(git -C ${top} rev-parse HEAD 2>/dev/null|tr [:lower:] [:upper:]):$(git -C ${top} branch --show-current 2>/dev/null|tr [:lower:] [:upper:]):GIT"||true;v="INFINITY:PRIVATE:LOCAL"
cat <<eot >.LlfMeta
# Built using Linux-Live-Framework technology.
LLF_NAME="${DISTRO}"
@@ -61,41 +66,48 @@ LLF_UTC="${utc}"
eot
[[ ${ret} = 2 ]]&&echo "LLF_ELF_STATIC_INITRD=\"y\"" >>.LlfMeta||echo "LLF_ELF_STATIC_INITRD=\"n\"" >>.LlfMeta
grub-mkrescue $([ ${V} ]&&echo ${V}) -o /${DISTRO}-${utc}.iso --compress=xz --product-name="${DISTRO}" --product-version="v=${v} t=${UTC}" .
mv -f /${DISTRO}-${utc}.iso ${top}/images/${DISTRO}-${utc}.iso
#xorriso -as mkisofs -o /${DISTRO}-${utc}.iso -iso-level 3 -J -R -D -A ${DISTRO} -V ${DISTRO} -no-emul-boot -boot-info-table -boot-load-size 2 -b isolinux.bin -c boot/grub/grub.cat -eltorito-alt-boot -e /efi.img -no-emul-boot .
#isohybrid --version >/dev/null 2>&1&&isohybrid -u /${DISTRO}-${utc}.iso
}
selectKernel()
{
local checkbox_output list krn
mapfile -t list < <(find /boot -type f|egrep"bzImage|kernel|vmlinuz" 2>/dev/null|egrep -v "init|$.old"|sort -n)
local checkbox_output list
mapfile -t list < <(find /boot -type f|egrep "bzImage|kernel|vmlinuz" 2>/dev/null|egrep -v "init|.*.old$"|sort -rn)
if [ ${#list[@]} -gt 1 ]; then
. ext/checkbox/checkbox.sh checkbox.sh --message="Please choose your kernel version to proceed:" --index --options="$(for i in "${list[@]}"; do basename "${i}";done;)"
krn="/boot/${list[${checkbox_output}]}"
. ext/checkbox/checkbox.sh --message="Please choose your kernel version to proceed:" --index --options="$(for i in "${list[@]}"; do basename "${i}";done;)"
kernel="${list[${checkbox_output}]}"
else
krn="${list[0]}"
kernel="${list[0]}"
fi
kernel="${krn}"
export kernel
}
declare -g kernel DISTRO workTmpDir V setCompatFlags
for i; do
case ${i} in
validArgs="$(getopt --name "${0}" --options 'i::k:d:w:CDnv' --longoptions 'interactive,,kernel:,distro:,workdir:,clean,debug,dry-run,verbose' -- "$@")"
[[ ${?} -ne 0 ]]&&false
eval set -- "${validArgs}"
while :; do
case ${1} in
-i|--interactive) helper=true ;;
-k|--kernel) kernel="${2}"; shift ;;
-d|--distro) DISTRO="${2}"; shift ;;
-w|--workdir) workTmpDir="${2}"; shift ;;
-D|--debug) set -x; setCompatFlags+=" -x " ;;
-n|--dry-run) set -n; setCompatFlags+=" -n " ;;
-v|--verbose) set -v; V="-v" ;;
-D|--debug) set -x ;;
-n|--dry-run) set -nv ;;
-v|--verbose) set -v ;;
-C|--clean) clean=true ;;
--) shift; break ;;
*) echo "Unknown option: ${i}"; exit 1 ;;
esac
shift
done
trap '. initrd/functions&&[[ ${clean} ]]&& { m A "\nCleaning-up";if rp "rm -rf ${workTmpDir}";then m i "Done!\n";else m w "Failed!\n";fi; };exit ${?}' HUP INT QUIT ILL TRAP ABRT TERM
[[ -t 0 && ${helper} || ${helper} ]]&&if selectKernel&&main; then true else; false; fi
[[ -e ${kernel} ]]||m e "Kernel not found: ${kernel}\n"&&false
#shift $((OPTIND-1))
export SHELLOPTS
cp -f config .config
export V setCompatFlags clean
trap '. initrd/functions 2>/dev/null;[[ ${clean} ]]&& { m A "\nCleaning-up";if rp f "rm -rf ${workTmpDir}";then m i "\nDone!\n";else m w "\nFailed!\n";fi; };reset;exit ${?}' QUIT EXIT INT TERM
[[ ${helper} ]]&&selectKernel
[[ -z ${DISTRO} ]]&&. .config&&m w "DISTRO not set. Using defaults: ${DISTRO}\n"||true
workTmpDir="${workTmpDir:-$(mktemp -d /tmp/Llf_WorkDir_XXXXXXX)}"||true
workTmpDir="${workTmpDir:-$(mktemp -d cache/Llf_WorkDir_XXXXX_$(date +%s))}"||true
mkdir -p "${workTmpDir}"
if main; then true; else false; fi
export workTmpDir DISTRO kernel V
main
exit ${?}