archboot/usr/bin/archboot-x86_64-release.sh

96 lines
3.8 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# created by Tobias Powalowski <tpowa@archlinux.org>
_BASENAME="$(basename "${0}")"
2022-01-24 09:56:00 +01:00
_ARCH="x86_64"
2022-01-24 11:11:27 +01:00
_PRESET_LATEST="${_ARCH}-latest"
2022-01-24 09:56:00 +01:00
_AMD_UCODE="boot/amd-ucode.img"
_INTEL_UCODE="boot/intel-ucode.img"
2022-01-24 11:11:27 +01:00
_INITRAMFS="boot/initramfs_${_ARCH}.img"
_INITRAMFS_LATEST="boot/initramfs_${_ARCH}-latest.img"
2022-01-24 12:27:29 +01:00
_KERNEL="boot/vmlinuz_${_ARCH}"
_KERNEL_ARCHBOOT="boot/vmlinuz_archboot_${_ARCH}"
2022-01-17 11:16:53 +01:00
_W_DIR="$(mktemp -u archboot-release.XXX)"
2021-09-23 09:14:28 +02:00
usage () {
2022-01-21 07:16:45 +01:00
echo "CREATE ARCHBOOT RELEASE IMAGE"
echo "-----------------------------"
echo "Usage: ${_BASENAME} <directory>"
echo "This will create an archboot release image in <directory>."
exit 0
}
[[ -z "${1}" ]] && usage
### check for root
if ! [[ ${UID} -eq 0 ]]; then
2022-01-14 11:10:58 +01:00
echo "ERROR: Please run as root user!"
exit 1
fi
### check for x86_64
if ! [[ "$(uname -m)" == "x86_64" ]]; then
echo "ERROR: Pleae run on x86_64 hardware."
exit 1
fi
2021-10-15 09:16:30 +02:00
echo "Start release creation in $1 ..."
2022-01-24 09:57:51 +01:00
mkdir -p "${1}"
cd "${1}" || exit 1
2021-09-11 10:26:04 +02:00
# create container
2022-01-24 11:11:27 +01:00
archboot-${_ARCH}-create-container.sh "${_W_DIR}" -cc -cp || exit 1
2021-09-22 18:59:33 +02:00
# generate tarball in container, umount tmp it's a tmpfs and weird things could happen then
2021-10-15 09:16:30 +02:00
echo "Generate ISO ..."
2021-09-11 10:26:04 +02:00
# generate iso in container
2022-01-24 11:11:27 +01:00
systemd-nspawn -q -D "${_W_DIR}" /bin/bash -c "umount /tmp;archboot-${_ARCH}-iso.sh -g"
# remove not working lvm2 from latest image
2022-01-13 15:32:45 +01:00
echo "Remove lvm2 and openssh from container ${_W_DIR} ..."
systemd-nspawn -D "${_W_DIR}" /bin/bash -c "pacman -Rdd lvm2 openssh --noconfirm" >/dev/null 2>&1
# generate latest tarball in container
2021-10-15 09:16:30 +02:00
echo "Generate latest ISO ..."
2021-10-04 20:15:21 +02:00
# generate latest iso in container
2022-01-24 11:11:27 +01:00
systemd-nspawn -q -D "${_W_DIR}" /bin/bash -c "umount /tmp;archboot-${_ARCH}-iso.sh -g -p=${_PRESET_LATEST} -r=$(date +%Y.%m.%d-%H.%M)-latest"
2021-09-22 21:03:16 +02:00
# create Release.txt with included main archlinux packages
2021-10-15 09:29:07 +02:00
echo "Generate Release.txt ..."
2022-01-24 11:11:27 +01:00
(echo "Welcome to _ARCHBOOT INSTALLATION / RESCUEBOOT SYSTEM";\
2022-01-24 09:56:00 +01:00
echo "Creation Tool: 'archboot' Tobias Powalowski <tpowa@archlinux.org>";\
echo "Homepage: https://wiki.archlinux.org/title/Archboot";\
2022-01-24 11:11:27 +01:00
echo "Architecture: ${_ARCH}";\
2022-01-24 09:56:00 +01:00
echo "RAM requirement to boot: 1152 MB or greater";\
echo "Archboot:$(systemd-nspawn -q -D "${_W_DIR}" pacman -Qi archboot | grep Version | cut -d ":" -f2 | sed -e "s/\r//g")";\
echo "Kernel:$(systemd-nspawn -q -D "${_W_DIR}" pacman -Qi linux | grep Version | cut -d ":" -f2 | sed -e "s/\r//g")";\
echo "Pacman:$(systemd-nspawn -q -D "${_W_DIR}" pacman -Qi pacman | grep Version | cut -d ":" -f2 | sed -e "s/\r//g")";\
echo "Systemd:$(systemd-nspawn -q -D "${_W_DIR}" pacman -Qi systemd | grep Version | cut -d ":" -f2 | sed -e "s/\r//g")") >>Release.txt
2021-09-11 10:26:04 +02:00
# move iso out of container
2022-01-13 15:32:45 +01:00
mv "${_W_DIR}"/*.iso ./
# remove container
2022-01-13 15:32:45 +01:00
echo "Remove container ${_W_DIR} ..."
rm -r "${_W_DIR}"
2021-09-11 10:26:04 +02:00
# create boot directory with ramdisks
2021-10-15 09:29:07 +02:00
echo "Create boot directory ..."
2021-09-23 10:00:18 +02:00
mkdir -p boot/licenses/{amd-ucode,intel-ucode}
2021-10-04 20:15:21 +02:00
for i in *.iso; do
2022-01-24 09:56:00 +01:00
if ! echo "${i}" | grep -q latest "${i}"; then
isoinfo -R -i "${i}" -x /"${_AMD_UCODE}" 2>/dev/null > "${_AMD_UCODE}"
isoinfo -R -i "${i}" -x /"${_INTEL_UCODE}" 2>/dev/null > "${_INTEL_UCODE}"
2022-01-24 11:24:10 +01:00
isoinfo -R -i "${i}" -x /"${_INITRAMFS}" 2>/dev/null > "${_INITRAMFS}"
2022-01-24 12:27:29 +01:00
isoinfo -R -i "${i}" -x /"${_KERNEL}" 2>/dev/null > "${_KERNEL_ARCHBOOT}"
2021-10-04 20:15:21 +02:00
else
2022-01-24 09:56:37 +01:00
isoinfo -R -i "${i}" -x /"${_INITRAMFS}" 2>/dev/null > "${_INITRAMFS_LATEST}"
2021-10-04 20:22:43 +02:00
fi
2021-10-04 20:15:21 +02:00
done
cp /usr/share/licenses/amd-ucode/* boot/licenses/amd-ucode/
cp /usr/share/licenses/intel-ucode/* boot/licenses/intel-ucode/
2021-10-11 07:19:23 +02:00
# create torrent files
2021-10-04 21:40:40 +02:00
for i in *.iso; do
2022-01-24 09:56:00 +01:00
echo "Generating ${i} torrent ..."
2021-10-15 09:16:30 +02:00
archboot-mktorrent.sh archboot/"${1}" "${i}" >/dev/null 2>&1
2021-10-04 21:40:40 +02:00
done
2021-09-11 10:26:04 +02:00
# create sha256sums
2021-10-15 09:16:30 +02:00
echo "Generating sha256sum ..."
2021-10-10 18:53:39 +02:00
for i in *; do
[[ -f "${i}" ]] && cksum -a sha256 "${i}" >> sha256sum.txt
done
for i in boot/*; do
[[ -f "${i}" ]] && cksum -a sha256 "${i}" >> sha256sum.txt
done
2022-01-24 09:56:00 +01:00
echo "Finished release creation in ${1} ."