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
+2
View File
@@ -1 +1,3 @@
.config
cache/*
images/*
+1 -1
View File
@@ -1,5 +1,5 @@
Linux Live Framework
======================
====================
This project is for supporting many CPUs architectures & extended functions unlike Linux-Live Kit (https://github.com/Tomas-M/linux-live)
+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 ${?}
+1 -1
View File
@@ -8,7 +8,7 @@
# This shell script is contributed under the terms of GPL v2 by Thomas Schoenhuetl <pilleus.pulcher@arcor.de> 22.05.2007.
# Modified script "slax2hd" for installing Generic Linux to hdd
# BY: Daniel K. aka Danieliskoto <http://danielisko.net, http://git.danielisko.net>
# BY: Daniel K. aka Danieliskot <http://danielisko.net, http://git.danielisko.net>
for i in dialog fdisk cfdisk sed grep mke2fs grub-install; do
if [ ! -x $(command -v ${i}) ]; then
+7 -9
View File
@@ -1,16 +1,14 @@
#!/usr/bin/env bash
#set -eET -o pipefail
export setCompatFlags top
grep -q -- -x <<<"${setCompatFlags}"&&set -x
grep -q -- -n <<<"${setCompatFlags}"&&set -n
grep -q -- -v <<<"${V}"&&set -v
#trap 'echo $(basename ${BASH_SOURCE[0]}):${LINENO}: "${BASH_COMMAND}"' DEBUG
export setCompatFlags top LMK setCompatFlags
trap 'rm -rf ${TOP}/${INITRAMFS}{,.img};exit ${?}' INT TERM
cd "$(dirname $(readlink -f ${0}))"||false
. ../.config||false
trap 'rm -rf ${TOP}/${INITRAMFS}{,.img};exit ${?}' HUP INT QUIT ILL TRAP ABRT TERM
#add more ELFs, if need ;)
list=(bash tar e2fsck fsck.fat f2fs mdadm mount.ntfs-3g blkid)
list=(bash blkid tar e2fsck fsck.fat fsck.f2fs mdadm mount.ntfs-3g)
# copy file to initramfs tree, including
# all library dependencies (as shown by ldd)
@@ -53,10 +51,10 @@ incDynElf()
return ${?}
}
mkdir -p $([ ${V} ]&&echo ${V}) ${INITRAMFS}/{bin,dev,etc,lib{32,64,x32,},mnt,proc,root,run,sys,tmp,usr{,/local}/{sbin,bin,lib{32,64,x32,}},var/log}
mkdir -p ${INITRAMFS}/{bin,dev,etc,lib{32,64,x32,},mnt,proc,root,run,sys,tmp,usr{,/local}/{sbin,bin,lib{32,64,x32,}},var/log}
# If bb is not found use all static prebuilt
incDynElf busybox || { cp -f $([ ${V} ]&&echo ${V}) static/busybox ${INITRAMFS}/bin;static=true; }
incDynElf busybox || { cp -f static/busybox ${INITRAMFS}/bin;static=true; }
for i in $(${INITRAMFS}/bin/busybox --list|egrep -v "tar|init|blkid"); do ln -sf $([ ${V} ]&&echo ${V}) busybox ${INITRAMFS}/bin/$i; done
mknod ${INITRAMFS}/dev/console c 5 1
@@ -92,7 +90,7 @@ echo "root::0:0::/root:/bin/bash" >${INITRAMFS}/etc/passwd
cp -f $([ ${V} ]&&echo ${V}) functions ${INITRAMFS}/lib
cp -f $([ ${V} ]&&echo ${V}) init shutdown ${INITRAMFS}
ln -sf -$([ ${V} ]&&echo ${V}) ../init ${INITRAMFS}/bin/init
ln -sf $([ ${V} ]&&echo ${V}) ../init ${INITRAMFS}/bin/init
cp -f $([ ${V} ]&&echo ${V}) ../.config ${INITRAMFS}/lib
chmod a+x -R $([ ${V} ]&&echo ${V}) ${INITRAMFS}
+7 -8
View File
@@ -25,14 +25,13 @@ d()
m()
{
case "${1}" in
q) printf '%s' "[Question]: ${2}";;
a) printf '%s' "[Answer]: ${2}";;
A) printf '%s' "[Action]: ${2}";;
i) printf '%s' "[Info]: ${2}";;
w) printf '%s' "[Warning]: ${2}";;
e) printf '%s' "[Error]: ${2}";;
f) printf '%s' "[Fatal]: ${2}";;
*) printf '%s' "${1}";;
q) echo -e "[Question]: ${2}";;
A) echo -e "[Action]: ${2}";;
i) echo -e "[Info]: ${2}";;
w) echo -e "[Warning]: ${2}";;
e) echo -e "[Error]: ${2}";;
f) echo -e "[Fatal]: ${2}";;
*) echo -e "${1}";;
esac
}
rp()
+1 -1
View File
@@ -21,7 +21,7 @@ exec >/dev/console >&1 2>&1 <&1
[[ "${DEBUG_IS_ENABLED}" = "true" ]]&&set -x
debugShell
echo "Linux Live Framework - Shutdown Magic!"
echo "Entering to clean-up things before final step."
echo "Entering to clean-up things before ${action}..."
(
mdev -s
sleep 1.5