forked from artix/artools
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cd76f7d3cf | |||
| 918b95db58 | |||
| 77c464d603 |
@@ -142,21 +142,23 @@ run_hook() {
|
|||||||
[[ -z "${cow_flags}" ]] && cow_flags="defaults"
|
[[ -z "${cow_flags}" ]] && cow_flags="defaults"
|
||||||
[[ -z "${cow_directory}" ]] && cow_directory="persistent_${label}"
|
[[ -z "${cow_directory}" ]] && cow_directory="persistent_${label}"
|
||||||
[[ -z "${cow_chunksize}" ]] && cow_chunksize="8"
|
[[ -z "${cow_chunksize}" ]] && cow_chunksize="8"
|
||||||
# set mount handler for artix
|
[[ -z "${overlay}" ]] && overlay=""
|
||||||
mount_handler="artix_mount_handler"
|
|
||||||
|
|
||||||
lower_dir=''
|
lower_dir=''
|
||||||
live_root="/run/artix"
|
live_root="/run/artix"
|
||||||
|
bootmnt="/run/bootmnt"
|
||||||
overlay_root="${live_root}/overlay_root"
|
overlay_root="${live_root}/overlay_root"
|
||||||
cow="${live_root}/cowspace"
|
cow="${live_root}/cowspace"
|
||||||
bootmnt="${live_root}/bootmnt"
|
|
||||||
cp2ram="${live_root}/copytoram"
|
cp2ram="${live_root}/copytoram"
|
||||||
|
|
||||||
|
# set mount handler for artix
|
||||||
|
mount_handler="artix_mount_handler"
|
||||||
}
|
}
|
||||||
|
|
||||||
_check_sum() {
|
_check_sum() {
|
||||||
local fs="$1"
|
local fs="${1}"
|
||||||
if [[ -f "${bootmnt}/${root}/${fs}.img" ]]; then
|
if [[ -f "${bootmnt}/${root}/${fs}.img" ]]; then
|
||||||
if [[ -f "${bootmnt}/${root}/${fs}.img.sha512" ]]; then
|
if [[ -f "${bootmnt}/${root}/${fs}.img.md5" ]]; then
|
||||||
msg -n ":: Self-test requested, please wait..."
|
msg -n ":: Self-test requested, please wait..."
|
||||||
if _verify_checksum "${fs}"; then
|
if _verify_checksum "${fs}"; then
|
||||||
msg "done. Checksum is OK, continue booting."
|
msg "done. Checksum is OK, continue booting."
|
||||||
@@ -166,14 +168,14 @@ _check_sum() {
|
|||||||
launch_interactive_shell
|
launch_interactive_shell
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "ERROR: checksum=y option specified but ${root}/${fs}.img.sha512 not found"
|
echo "ERROR: checksum=y option specified but ${root}/${fs}.img.md5 not found"
|
||||||
launch_interactive_shell
|
launch_interactive_shell
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_check_sig() {
|
_check_sig() {
|
||||||
|
local fs="${1}"
|
||||||
if [[ -f "${bootmnt}/${root}/${fs}.img" ]]; then
|
if [[ -f "${bootmnt}/${root}/${fs}.img" ]]; then
|
||||||
if [[ -f "${bootmnt}/${root}/${fs}.img.sig" ]]; then
|
if [[ -f "${bootmnt}/${root}/${fs}.img.sig" ]]; then
|
||||||
msg -n ":: Signature verification requested, please wait..."
|
msg -n ":: Signature verification requested, please wait..."
|
||||||
@@ -191,12 +193,12 @@ _check_sig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_gen_arg() {
|
_gen_arg() {
|
||||||
local arg="$1"
|
local arg="${1}"
|
||||||
echo "${lower_dir:-}${lower_dir:+:}${arg}"
|
echo "${lower_dir:-}${lower_dir:+:}${arg}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_mount_root_overlay() {
|
_mount_root_overlayfs() {
|
||||||
local sfs="$1"
|
local sfs="${1}"
|
||||||
local src="${bootmnt}/${root}"
|
local src="${bootmnt}/${root}"
|
||||||
local dest_sfs="${live_root}/sfs"
|
local dest_sfs="${live_root}/sfs"
|
||||||
local dest_img="${live_root}/img"
|
local dest_img="${live_root}/img"
|
||||||
@@ -227,15 +229,15 @@ artix_mount_handler() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for fs in rootfs livefs; do
|
if [[ "${checksum}" == "y" ]]; then
|
||||||
if [[ "${checksum}" == "y" ]]; then
|
_check_sum "rootfs"
|
||||||
_check_sum "${fs}"
|
[[ -n "${overlay}" ]] && _check_sum "${overlay}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${verify}" == "y" ]]; then
|
if [[ "${verify}" == "y" ]]; then
|
||||||
_check_sig "${fs}"
|
_check_sig "rootfs"
|
||||||
fi
|
[[ -n "${overlay}" ]] && _check_sig "${overlay}"
|
||||||
done
|
fi
|
||||||
|
|
||||||
if [[ "${copytoram}" == "y" ]]; then
|
if [[ "${copytoram}" == "y" ]]; then
|
||||||
msg ":: Mounting ${cp2ram} (tmpfs) filesystem, size=${copytoram_size}"
|
msg ":: Mounting ${cp2ram} (tmpfs) filesystem, size=${copytoram_size}"
|
||||||
@@ -258,9 +260,8 @@ artix_mount_handler() {
|
|||||||
mkdir -p ${overlay_root}
|
mkdir -p ${overlay_root}
|
||||||
mount -t tmpfs -o "size=${overlay_root_size}",mode=0755 overlay_root ${overlay_root}
|
mount -t tmpfs -o "size=${overlay_root_size}",mode=0755 overlay_root ${overlay_root}
|
||||||
|
|
||||||
for fs in livefs rootfs; do
|
[[ -n "${overlay}" ]] && _mount_root_overlayfs "${overlay}"
|
||||||
_mount_root_overlay "${fs}"
|
_mount_root_overlayfs "rootfs"
|
||||||
done
|
|
||||||
|
|
||||||
_mnt_overlayfs "${lower_dir}" "${newroot}" "/"
|
_mnt_overlayfs "${lower_dir}" "${newroot}" "/"
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ run_hook () {
|
|||||||
if [[ -n "${img_dev}" && -n "${img_loop}" ]]; then
|
if [[ -n "${img_dev}" && -n "${img_loop}" ]]; then
|
||||||
mount_handler="artix_loop_mount_handler"
|
mount_handler="artix_loop_mount_handler"
|
||||||
fi
|
fi
|
||||||
live_root="/run/artix"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
artix_loop_mount_handler () {
|
artix_loop_mount_handler () {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ _curl_get() {
|
|||||||
local _dst="${2}"
|
local _dst="${2}"
|
||||||
|
|
||||||
msg ":: Downloading '${_url}'"
|
msg ":: Downloading '${_url}'"
|
||||||
if ! curl -L -f -o "/run/artix/httpspace/${root}${_dst}/${_url##*/}" --create-dirs "${_url}"; then
|
if ! curl -L -f -o "${live_root}/httpspace/${root}${_dst}/${_url##*/}" --create-dirs "${_url}"; then
|
||||||
echo "ERROR: Downloading '${_url}'"
|
echo "ERROR: Downloading '${_url}'"
|
||||||
echo " Falling back to interactive prompt"
|
echo " Falling back to interactive prompt"
|
||||||
echo " You can try to fix the problem manually, log out when you are finished"
|
echo " You can try to fix the problem manually, log out when you are finished"
|
||||||
@@ -31,29 +31,33 @@ _curl_get() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_get_sfs() {
|
||||||
|
local _sfs="${2}"
|
||||||
|
local _src=${artix_http_srv}${root}
|
||||||
|
if [[ ! -z "$( curl -s --head "${_src}/${_sfs}.img" | grep "OK" )" ]]; then
|
||||||
|
_curl_get "${_src}/${_sfs}.img" "/"
|
||||||
|
|
||||||
|
if [[ "${checksum}" == "y" ]]; then
|
||||||
|
_curl_get "${_src}/${_sfs}.md5" "/"
|
||||||
|
fi
|
||||||
|
if [[ "${verify}" == "y" ]]; then
|
||||||
|
_curl_get "${_src}/${_sfs}.img.sig" "/"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
artix_pxe_http_mount_handler () {
|
artix_pxe_http_mount_handler () {
|
||||||
newroot="${1}"
|
newroot="${1}"
|
||||||
|
|
||||||
msg ":: Mounting /run/artix/httpspace (tmpfs) filesystem, size='${artix_http_spc}'"
|
msg ":: Mounting ${live_root}/httpspace (tmpfs) filesystem, size='${artix_http_spc}'"
|
||||||
mkdir -p "/run/artix/httpspace"
|
mkdir -p "${live_root}/httpspace"
|
||||||
mount -t tmpfs -o size="${artix_http_spc}",mode=0755 httpspace "/run/artix/httpspace"
|
mount -t tmpfs -o size="${artix_http_spc}",mode=0755 httpspace "${live_root}/httpspace"
|
||||||
|
|
||||||
local _src=${artix_http_srv}${root}/${arch}
|
_get_sfs "rootfs"
|
||||||
|
[[ -n "${overlay}" ]] && _mount_root_overlayfs "${overlay}"
|
||||||
|
|
||||||
for sfs in livefs rootfs;do
|
mkdir -p "${bootmnt}"
|
||||||
if [[ ! -z "$( curl -s --head "${_src}/${sfs}.sfs" | grep "OK" )" ]]; then
|
mount -o bind ${live_root}/httpspace ${bootmnt}
|
||||||
_curl_get "${_src}/${sfs}.sfs" "/${arch}"
|
|
||||||
|
|
||||||
if [[ "${checksum}" == "y" ]]; then
|
|
||||||
_curl_get "${_src}/${sfs}.md5" "/${arch}"
|
|
||||||
fi
|
|
||||||
if [[ "${verify}" == "y" ]]; then
|
|
||||||
_curl_get "${_src}/${sfs}.sfs.sig" "/${arch}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
mkdir -p "/run/artix/bootmnt"
|
|
||||||
mount -o bind /run/artix/httpspace /run/artix/bootmnt
|
|
||||||
|
|
||||||
artix_mount_handler ${newroot}
|
artix_mount_handler ${newroot}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ run_hook() {
|
|||||||
|
|
||||||
artix_nfs_mount_handler() {
|
artix_nfs_mount_handler() {
|
||||||
newroot="${1}"
|
newroot="${1}"
|
||||||
mkdir -p "/run/artix/bootmnt"
|
mkdir -p "${bootmnt}"
|
||||||
msg ":: Mounting '${artix_nfs_srv}'"
|
msg ":: Mounting '${artix_nfs_srv}'"
|
||||||
# Do not put "${artix_nfs_opt}" nfsmount fails!
|
# Do not put "${artix_nfs_opt}" nfsmount fails!
|
||||||
if ! nfsmount ${artix_nfs_opt} "${artix_nfs_srv}" "/run/artix/bootmnt"; then
|
if ! nfsmount ${artix_nfs_opt} "${artix_nfs_srv}" "${bootmnt}"; then
|
||||||
echo "ERROR: Mounting '${artix_nfs_srv}'"
|
echo "ERROR: Mounting '${artix_nfs_srv}'"
|
||||||
echo " Falling back to interactive prompt"
|
echo " Falling back to interactive prompt"
|
||||||
echo " You can try to fix the problem manually, log out when you are finished"
|
echo " You can try to fix the problem manually, log out when you are finished"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ if [[ ! -d /oldrun/artix/copytoram ]]; then
|
|||||||
if [[ -d /oldrun/artix/img_dev ]]; then
|
if [[ -d /oldrun/artix/img_dev ]]; then
|
||||||
umount /oldrun/artix/img_dev
|
umount /oldrun/artix/img_dev
|
||||||
else
|
else
|
||||||
umount /oldrun/artix/bootmnt
|
umount /oldrun/bootmnt
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -143,10 +143,10 @@ write_unpackfs() {
|
|||||||
local yaml=$(write_yaml_header)
|
local yaml=$(write_yaml_header)
|
||||||
yaml+=$(write_yaml_map 0 'unpack')
|
yaml+=$(write_yaml_map 0 'unpack')
|
||||||
# if ${persist}; then
|
# if ${persist}; then
|
||||||
# yaml+=$(write_yaml_seq_map 2 'source' '"/run/artix/bootmnt/LiveOS/rootfs.img"')
|
# yaml+=$(write_yaml_seq_map 2 'source' '"/run/bootmnt/LiveOS/rootfs.img"')
|
||||||
# yaml+=$(write_yaml_map 4 'sourcefs' '"ext4"')
|
# yaml+=$(write_yaml_map 4 'sourcefs' '"ext4"')
|
||||||
# else
|
# else
|
||||||
yaml+=$(write_yaml_seq_map 2 'source' '"/run/artix/bootmnt/LiveOS/rootfs.img"')
|
yaml+=$(write_yaml_seq_map 2 'source' '"/run/bootmnt/LiveOS/rootfs.img"')
|
||||||
yaml+=$(write_yaml_map 4 'sourcefs' '"squashfs"')
|
yaml+=$(write_yaml_map 4 'sourcefs' '"squashfs"')
|
||||||
# fi
|
# fi
|
||||||
yaml+=$(write_yaml_map 4 'destination' '""')
|
yaml+=$(write_yaml_map 4 'destination' '""')
|
||||||
|
|||||||
@@ -13,13 +13,17 @@
|
|||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
write_mkinitcpio_conf() {
|
write_mkinitcpio_conf() {
|
||||||
|
msg2 "Writing mkinitcpio.conf ..."
|
||||||
local conf="$1/etc/mkinitcpio-artix.conf"
|
local conf="$1/etc/mkinitcpio-artix.conf"
|
||||||
printf "%s\n" 'MODULES=(loop dm-snapshot)' > $conf
|
printf "%s\n" 'MODULES=(loop dm-snapshot)' > $conf
|
||||||
printf "%s\n" 'COMPRESSION="xz"' >> $conf
|
printf "%s\n" 'COMPRESSION="xz"' >> $conf
|
||||||
if [[ "${PROFILE}" == 'base' ]];then
|
if [[ "${PROFILE}" == 'base' ]];then
|
||||||
printf "%s\n" 'HOOKS=(base udev artix_shutdown artix artix_loop_mnt artix_pxe_common artix_pxe_http artix_pxe_nbd artix_pxe_nfs artix_kms modconf block filesystems keyboard keymap)' >> $conf
|
printf "%s\n" 'HOOKS=(base udev artix_shutdown artix artix_loop_mnt
|
||||||
|
artix_pxe_common artix_pxe_http artix_pxe_nbd artix_pxe_nfs
|
||||||
|
artix_kms modconf block filesystems keyboard keymap)' >> $conf
|
||||||
else
|
else
|
||||||
printf "%s\n" 'HOOKS=(base udev artix_shutdown artix artix_loop_mnt artix_kms modconf block filesystems keyboard keymap)' >> $conf
|
printf "%s\n" 'HOOKS=(base udev artix_shutdown artix artix_loop_mnt
|
||||||
|
artix_kms modconf block filesystems keyboard keymap)' >> $conf
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,34 +33,10 @@ prepare_initcpio(){
|
|||||||
cp /etc/initcpio/hooks/artix* $dest/etc/initcpio/hooks
|
cp /etc/initcpio/hooks/artix* $dest/etc/initcpio/hooks
|
||||||
cp /etc/initcpio/install/artix* $dest/etc/initcpio/install
|
cp /etc/initcpio/install/artix* $dest/etc/initcpio/install
|
||||||
cp /etc/initcpio/artix_shutdown $dest/etc/initcpio
|
cp /etc/initcpio/artix_shutdown $dest/etc/initcpio
|
||||||
|
|
||||||
msg2 "Writing mkinitcpio.conf ..."
|
|
||||||
write_mkinitcpio_conf "$dest"
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare_initramfs(){
|
|
||||||
local mnt="$1"
|
|
||||||
|
|
||||||
if [[ -n ${GPG_KEY} ]]; then
|
|
||||||
su ${OWNER} -c "gpg --export ${GPG_KEY} >/tmp/GPG_KEY"
|
|
||||||
exec 17<>/tmp/GPG_KEY
|
|
||||||
fi
|
|
||||||
local _kernel=$(<$mnt/usr/src/linux/version)
|
|
||||||
ARTIX_GNUPG_FD=${GPG_KEY:+17} artools-chroot $mnt \
|
|
||||||
/usr/bin/mkinitcpio -k ${_kernel} \
|
|
||||||
-c /etc/mkinitcpio-artix.conf \
|
|
||||||
-g /boot/initramfs.img
|
|
||||||
|
|
||||||
if [[ -n ${GPG_KEY} ]]; then
|
|
||||||
exec 17<&-
|
|
||||||
fi
|
|
||||||
if [[ -f /tmp/GPG_KEY ]]; then
|
|
||||||
rm /tmp/GPG_KEY
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_boot_extras(){
|
prepare_boot_extras(){
|
||||||
local src="$1" dest="$2"
|
local src="$1" dest=${iso_root}/boot
|
||||||
|
|
||||||
for u in intel amd;do
|
for u in intel amd;do
|
||||||
cp $src/boot/$u-ucode.img $dest/$u-ucode.img
|
cp $src/boot/$u-ucode.img $dest/$u-ucode.img
|
||||||
@@ -67,10 +47,45 @@ prepare_boot_extras(){
|
|||||||
cp $src/usr/share/licenses/common/GPL2/license.txt $dest/memtest.COPYING
|
cp $src/usr/share/licenses/common/GPL2/license.txt $dest/memtest.COPYING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prepare_initramfs(){
|
||||||
|
local mnt="$1"
|
||||||
|
|
||||||
|
prepare_initcpio "$mnt"
|
||||||
|
|
||||||
|
write_mkinitcpio_conf "$mnt"
|
||||||
|
|
||||||
|
if [[ -n ${GPG_KEY} ]]; then
|
||||||
|
su ${OWNER} -c "gpg --export ${GPG_KEY} >/tmp/GPG_KEY"
|
||||||
|
exec 17<>/tmp/GPG_KEY
|
||||||
|
fi
|
||||||
|
local _kernel=$(<"$mnt"/usr/src/linux/version)
|
||||||
|
ARTIX_GNUPG_FD=${GPG_KEY:+17} artools-chroot "$mnt" \
|
||||||
|
/usr/bin/mkinitcpio -k ${_kernel} \
|
||||||
|
-c /etc/mkinitcpio-artix.conf \
|
||||||
|
-g /boot/initramfs.img
|
||||||
|
|
||||||
|
if [[ -n ${GPG_KEY} ]]; then
|
||||||
|
exec 17<&-
|
||||||
|
fi
|
||||||
|
if [[ -f /tmp/GPG_KEY ]]; then
|
||||||
|
rm /tmp/GPG_KEY
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp $mnt/boot/initramfs.img ${iso_root}/boot/initramfs-${ARCH}.img
|
||||||
|
prepare_boot_extras "$mnt"
|
||||||
|
}
|
||||||
|
|
||||||
configure_grub(){
|
configure_grub(){
|
||||||
local kopts="root=LiveOS label=${iso_label}"
|
local ro_opts=("label=${iso_label}")
|
||||||
local popts=''
|
local rw_opts=("cow_label=${iso_label}")
|
||||||
sed -e "s|@kopts@|${kopts}|" -e "s|@popts@|${popts}|" -i ${iso_root}/boot/grub/kernels.cfg
|
local kopts=()
|
||||||
|
|
||||||
|
[[ "${PROFILE}" != 'base' ]] && kopts+=('overlay=livefs')
|
||||||
|
|
||||||
|
sed -e "s|@kopts@|${kopts[*]}|" \
|
||||||
|
-e "s|@ro_opts@|${ro_opts[*]}|" \
|
||||||
|
-e "s|@rw_opts@|${rw_opts[*]}|" \
|
||||||
|
-i ${iso_root}/boot/grub/kernels.cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_grub(){
|
prepare_grub(){
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ make_sig () {
|
|||||||
|
|
||||||
make_checksum(){
|
make_checksum(){
|
||||||
local file="$1"
|
local file="$1"
|
||||||
msg2 "Creating sha512sum ..."
|
msg2 "Creating md5sum ..."
|
||||||
cd ${iso_root}${live_dir}
|
cd ${iso_root}${live_dir}
|
||||||
sha512sum $file > $file.sha512
|
md5sum $file > $file.md5
|
||||||
cd ${OLDPWD}
|
cd ${OLDPWD}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,22 +148,17 @@ make_livefs() {
|
|||||||
make_bootfs() {
|
make_bootfs() {
|
||||||
if [[ ! -e ${work_dir}/bootfs.lock ]]; then
|
if [[ ! -e ${work_dir}/bootfs.lock ]]; then
|
||||||
msg "Prepare [/iso/boot]"
|
msg "Prepare [/iso/boot]"
|
||||||
local boot="${iso_root}/boot"
|
|
||||||
|
|
||||||
prepare_dir "${boot}"
|
prepare_dir "${iso_root}/boot"
|
||||||
|
|
||||||
cp ${work_dir}/rootfs/boot/vmlinuz* ${boot}/vmlinuz-${ARCH}
|
cp ${work_dir}/rootfs/boot/vmlinuz* ${iso_root}/boot/vmlinuz-${ARCH}
|
||||||
|
|
||||||
local bootfs="${work_dir}/bootfs"
|
local bootfs="${work_dir}/bootfs"
|
||||||
|
|
||||||
mount_overlay "${bootfs}" "${work_dir}"
|
mount_overlay "${bootfs}" "${work_dir}"
|
||||||
|
|
||||||
prepare_initcpio "${bootfs}"
|
|
||||||
prepare_initramfs "${bootfs}"
|
prepare_initramfs "${bootfs}"
|
||||||
|
|
||||||
cp ${bootfs}/boot/initramfs.img ${boot}/initramfs-${ARCH}.img
|
|
||||||
prepare_boot_extras "${bootfs}" "${boot}"
|
|
||||||
|
|
||||||
umount_overlay
|
umount_overlay
|
||||||
|
|
||||||
rm -R ${bootfs}
|
rm -R ${bootfs}
|
||||||
|
|||||||
Reference in New Issue
Block a user