From 2a06b641c1154d1bb1c3efe104c0ea101b452930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramon=20Buld=C3=B3?= Date: Thu, 11 Jun 2015 13:59:34 +0200 Subject: [PATCH 01/24] Add overlayfs support. Building images works fine. Enable it by adding use_overlayfs="true" to manjaro-tools.conf. The miso_overlayfs hook doesn't work, to test change the miso hook to miso_overlayfs. --- Makefile | 2 + initcpio/hooks/miso_overlayfs | 257 ++++++++++++++++++++++++++++++++++ initcpio/inst/miso_overlayfs | 31 ++++ lib/util-iso.sh | 128 +++++++++++++---- lib/util.sh | 2 + 5 files changed, 389 insertions(+), 31 deletions(-) create mode 100644 initcpio/hooks/miso_overlayfs create mode 100644 initcpio/inst/miso_overlayfs diff --git a/Makefile b/Makefile index 8f9df66..27d5256 100644 --- a/Makefile +++ b/Makefile @@ -61,12 +61,14 @@ LIBS = \ CPIOHOOKS = \ initcpio/hooks/miso \ + initcpio/hooks/miso_overlayfs \ initcpio/hooks/miso_loop_mnt \ initcpio/hooks/miso_pxe_common \ initcpio/hooks/miso_pxe_http CPIOINST = \ initcpio/inst/miso \ + initcpio/inst/miso_overlayfs \ initcpio/inst/miso_loop_mnt \ initcpio/inst/miso_pxe_common \ initcpio/inst/miso_pxe_http \ diff --git a/initcpio/hooks/miso_overlayfs b/initcpio/hooks/miso_overlayfs new file mode 100644 index 0000000..249a669 --- /dev/null +++ b/initcpio/hooks/miso_overlayfs @@ -0,0 +1,257 @@ +# kernel_cmdline +# Looks for a parameter on the kernel's boot-time command line. +# +# returns: 0 if param was found. Also prints its value if it was a K=V param. +# 1 if it was not. Also prints value passed as +# + +kernel_cmdline () +{ + for param in $(/bin/cat /proc/cmdline); do + case "${param}" in + $1=*) echo "${param##*=}"; return 0 ;; + $1) return 0 ;; + *) continue ;; + esac + done + [ -n "${2}" ] && echo "${2}" + return 1 +} + +# 1$ : kernel argument to check +overlay_arg_available() { + for arg in $(echo "$(kernel_cmdline overlay)" | /bin/sed 's/,/ /g') + do + [ "${arg}" == "$1" ] && return 0 + done + + return 1 +} + +# args: source, mountpoint +_mnt_bind() { + local src="${1}" + local mnt="${2}" + msg "::: Binding ${src} to ${mnt}" + mkdir -p "${mnt}" + /bin/mount -o bind "${src}" "${mnt}" +} + +# args: /path/to/image_file, mountpoint +_mnt_squashfs() { + local img="${1}" + local mnt="${2}" + local img_fullname="${img##*/}"; + local img_name="${img_fullname%.*}" + local tmp_mnt="/ro_branch/${img_name}" + + if [ "${copytoram}" = "y" ]; then + msg -n ":: Copying squashfs image to RAM..." + /bin/cp "${img}" "/copytoram/${img_fullname}" + if [ $? -ne 0 ]; then + echo ">> ERROR: while copy ${img} to /copytoram/${img_fullname}" + launch_interactive_shell + fi + img="/copytoram/${img_fullname}" + msg "done." + fi + + mkdir -p "${tmp_mnt}" + /bin/mount -r -t squashfs "${img}" "${tmp_mnt}" + if [ $? -ne 0 ]; then + echo ">> ERROR: while mounting ${img} to ${tmp_mnt}" + launch_interactive_shell + fi + + if [ "/${mnt#/*/}" = "/" ]; then + overlayfs="${overlayfs}:${tmp_mnt}" + else + _mnt_bind "${tmp_mnt}" "${mnt}" + fi +} + +run_hook() { + modprobe loop + if [ "x${arch}" = "x" ]; then + arch="$(uname -m)" + fi + + if [ "x${rw_branch_size}" = "x" ]; then + rw_branch_size="75%" + fi + + if [ "x${copytoram_size}" = "x" ]; then + copytoram_size="75%" + fi + + if [ "x${misobasedir}" = "x" ]; then + misobasedir="manjaro" + fi + + if [ "x${isomounts}" != "x" ]; then + isomounts="/bootmnt/${isomounts}" + else + isomounts="/bootmnt/${misobasedir}/isomounts" + fi + + # set mount handler for miso + mount_handler="miso_mount_handler" +} + +testdevice() { + fstype=$( blkid -s TYPE -o value ${MDEV} ) + mount -r -t ${fstype} -o noatime "${MDEV}" "/bootmnt" >/dev/null 2>/dev/null + if [ $? -eq 0 ]; then + if [ -f "/bootmnt/.miso" ]; then + msg "::: INFO: miso system at ${MDEV}" + found="yes" + else + /bin/umount "/bootmnt/" 2>/dev/null + msg "::: INFO: No miso system at ${MDEV}" + MDEV="" + fi + else + msg ">> ERROR: Couldn't mount ${MDEV}" + MDEV="" + fi +} + +probedevice() { + + if [[ -n "${ip}" && -n "${miso_http_srv}" && -f "${isomounts}" ]]; then + found="yes" + return + fi + +# Loop device test every second up to some limit + if [ "x${usbdelay}" != "x" ]; then + waittime=${usbdelay} + else + waittime=35 + fi + waitcount=0 + while [ ${waittime} -ne ${waitcount} ]; do + # first we look for root, e.g. /dev/sda1 to see if .miso will be found + if [ "x${root}" != "x" ]; then + [ ${waitcount} -eq 0 ] && msg ":: Looking for ${root}" + if [ -e ${root} ]; then + MDEV=${root} + testdevice + fi + fi + + # if still not found, we will look for misolabel + if [ "x${misolabel}" != "x" ]; then + [ ${waitcount} -eq 0 ] && msg ":: Looking for LABEL ${misolabel}" + MDEV=$( blkid -L ${misolabel} ) + if [ "x${MDEV}" != "x" ]; then + testdevice + else + msg "::: INFO: LABEL ${misolabel} is not valid!" + misolabel="" + fi + fi + + # still nothing found, we will look for boot device + if [ -z "${found}" ]; then + [ ${waitcount} -eq 0 ] && msg ":: Looking for boot device" + if [ "x${nocd}" = "x" ]; then + # Look for CD + cdroms=$( /bin/cat /proc/sys/dev/cdrom/info | { while read a b c; do + if [ "${a}" = "drive" -a "${b}" = "name:" ]; then + echo "${c}" + break + fi + done + } ) + for i in ${cdroms}; do + MDEV=/dev/${i} + testdevice + if [ "x${MDEV}" != "x" ]; then + break + fi + done + fi + + # Test partitions + if [ "x${MDEV}" = "x" ]; then + for d in /dev/sd[a-z][0-9]*; do + MDEV=${d} + testdevice + if [ "x${MDEV}" != "x" ]; then + break + fi + done + fi + + fi + + [ "x${MDEV}" != "x" ] && break + + /bin/sleep 1 + waitcount=$(( ${waitcount} + 1 )) + done +} + +miso_mount_handler() { + local newroot="${1}" + local found + local overlayfs + + # Probe all devices + probedevice + + if [ -z "${found}" ]; then + echo ">> ERROR: unable to find boot device" + echo " Falling back to interactive prompt" + echo " You can try to fix the problem manually, log out when you are finished" + launch_interactive_shell + fi + + if [ "${copytoram}" = "y" ]; then + msg -n ":: Mounting /copytoram (tmpfs) filesystem, size=${copytoram_size}..." + mount -t tmpfs -o "size=${copytoram_size}",mode=0755 copytoram /copytoram + msg "done." + fi + + msg -n ":: Mounting rw_branch (tmpfs) filesystem, size=${rw_branch_size}..." + mount -t tmpfs -o "size=${rw_branch_size}",mode=0755 rw_branch /rw_branch + msg "done." + + msg ":: Mounting images" + while read img imgarch mountpoint type kernelarg; do + # check if this line is a comment (starts with #) + [ "${img#"#"}" != "${img}" ] && continue + + [ "$imgarch" != "$arch" ] && continue + + [ ! -r "/bootmnt/${misobasedir}/${img}" ] && continue + + # check if the overlay should be loaded + overlay_arg_available "$kernelarg" + + + if [ $? == 1 ] && [ "$kernelarg" != "" ]; then + continue + fi + + if [ "${type}" = "bind" ]; then + _mnt_bind "/bootmnt/${misobasedir}/${img}" "${newroot}${mountpoint}" + elif [ "${type}" = "squashfs" ]; then + _mnt_squashfs "/bootmnt/${misobasedir}/${img}" "${newroot}${mountpoint}" + fi + done < "${isomounts}" + + msg "Mounting ${overlayfs:1}" + mkdir -p "/rw_branch/upper" + mkdir -p "/rw_branch/work" + mount -t overlay overlay -olowerdir="${overlayfs:1}",upperdir="/rw_branch/upper",workdir="/rw_branch/work" "${newroot}/" + + if [ "${copytoram}" = "y" ]; then + /bin/umount /bootmnt + else + _mnt_bind /bootmnt "${newroot}/bootmnt" + fi +} + +# vim:ft=sh:ts=4:sw=4:et: diff --git a/initcpio/inst/miso_overlayfs b/initcpio/inst/miso_overlayfs new file mode 100644 index 0000000..d88ba38 --- /dev/null +++ b/initcpio/inst/miso_overlayfs @@ -0,0 +1,31 @@ +#!/bin/bash + +build() { + add_module "cdrom" + add_module "overlay" + add_module "squashfs" + add_module "isofs" + add_module "loop" + add_module "usb_storage" + add_module "sd_mod" + add_module "sr_mod" + add_module "virtio_pci" + add_module "virtio_blk" + + add_dir /rw_branch + add_dir /ro_branch + add_dir /copytoram + add_dir /bootmnt + + add_runscript + + add_binary /usr/lib/udev/cdrom_id + add_binary blockdev + add_binary losetup + add_binary mountpoint + + add_file /usr/lib/udev/rules.d/60-cdrom_id.rules +} + +# vim: set ft=sh ts=4 sw=4 et: + diff --git a/lib/util-iso.sh b/lib/util-iso.sh index e9b48c2..e2c061e 100644 --- a/lib/util-iso.sh +++ b/lib/util-iso.sh @@ -204,8 +204,13 @@ make_image_custom() { msg "Prepare [${custom} installation] (${custom}-image)" local path="${work_dir}/${custom}-image" mkdir -p ${path} - umount_image_handler - aufs_mount_root_image "${path}" + if [[ ${use_overlayfs} == "true" ]];then + mkdir -p "${work_dir}/work" + mount -t overlay overlay -olowerdir="${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" + else + umount_image_handler + aufs_mount_root_image "${path}" + fi chroot_create "${path}" "${packages}" clean_up_image "${path}" pacman -Qr "${path}" > "${path}/${custom}-image-pkgs.txt" @@ -213,8 +218,13 @@ make_image_custom() { [[ -d ${custom}-overlay ]] && copy_overlay_custom configure_custom_image "${path}" ${is_custom_pac_conf} && clean_pacman_conf "${path}" - umount_image_handler - aufs_clean "${path}" + if [[ ${use_overlayfs} == "true" ]];then + umount "${path}" + rm -rf "${work_dir}/work" + else + umount_image_handler + aufs_clean "${path}" + fi : > ${work_dir}/build.${FUNCNAME} msg "Done [${custom} installation] (${custom}-image)" fi @@ -225,12 +235,21 @@ make_image_livecd() { msg "Prepare [livecd installation] (livecd-image)" local path="${work_dir}/livecd-image" mkdir -p ${path} - umount_image_handler - if [[ -n "${custom}" ]] ; then - aufs_mount_custom_image "${path}" - aufs_append_root_image "${path}" + if [[ ${use_overlayfs} == "true" ]];then + mkdir -p "${work_dir}/work" + if [[ -n "${custom}" ]] ; then + mount -t overlay overlay -olowerdir="${work_dir}/${custom}-image":"${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" + else + mount -t overlay overlay -olowerdir="${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" + fi else - aufs_mount_root_image "${path}" + umount_image_handler + if [[ -n "${custom}" ]] ; then + aufs_mount_custom_image "${path}" + aufs_append_root_image "${path}" + else + aufs_mount_root_image "${path}" + fi fi chroot_create "${path}" "${packages}" clean_up_image "${path}" @@ -243,8 +262,13 @@ make_image_livecd() { ${is_custom_pac_conf} && clean_pacman_conf "${path}" # Clean up GnuPG keys? rm -rf "${path}/etc/pacman.d/gnupg" - umount_image_handler - aufs_clean "${path}" + if [[ ${use_overlayfs} == "true" ]];then + umount "${path}" + rm -rf "${work_dir}/work" + else + umount_image_handler + aufs_clean "${path}" + fi : > ${work_dir}/build.${FUNCNAME} msg "Done [livecd-image]" fi @@ -255,12 +279,21 @@ make_image_xorg() { msg "Prepare [pkgs-image]" local path="${work_dir}/pkgs-image" mkdir -p ${path}/opt/livecd/pkgs - umount_image_handler - if [[ -n "${custom}" ]] ; then - aufs_mount_custom_image "${path}" - aufs_append_root_image "${path}" + if [[ ${use_overlayfs} == "true" ]];then + mkdir -p "${work_dir}/work" + if [[ -n "${custom}" ]] ; then + mount -t overlay overlay -olowerdir="${work_dir}/${custom}-image":"${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" + else + mount -t overlay overlay -olowerdir="${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" + fi else - aufs_mount_root_image "${path}" + umount_image_handler + if [[ -n "${custom}" ]] ; then + aufs_mount_custom_image "${path}" + aufs_append_root_image "${path}" + else + aufs_mount_root_image "${path}" + fi fi download_to_cache "${path}" "${packages_xorg}" copy_cache_xorg @@ -273,8 +306,13 @@ make_image_xorg() { rm -r ${path}/var make_repo "${path}/opt/livecd/pkgs/gfx-pkgs" "${path}/opt/livecd/pkgs" configure_xorg_drivers "${path}" - umount_image_handler - aufs_clean "${path}" + if [[ ${use_overlayfs} == "true" ]];then + umount "${path}" + rm -rf "${work_dir}/work" + else + umount_image_handler + aufs_clean "${path}" + fi : > ${work_dir}/build.${FUNCNAME} msg "Done [pkgs-image]" fi @@ -285,12 +323,21 @@ make_image_lng() { msg "Prepare [lng-image]" local path="${work_dir}/lng-image" mkdir -p ${path}/opt/livecd/lng - umount_image_handler - if [[ -n "${custom}" ]] ; then - aufs_mount_custom_image "${path}" - aufs_append_root_image "${path}" + if [[ ${use_overlayfs} == "true" ]];then + mkdir -p "${work_dir}/work" + if [[ -n "${custom}" ]] ; then + mount -t overlay overlay -olowerdir="${work_dir}/${custom}-image":"${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" + else + mount -t overlay overlay -olowerdir="${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" + fi else - aufs_mount_root_image "${path}" + umount_image_handler + if [[ -n "${custom}" ]] ; then + aufs_mount_custom_image "${path}" + aufs_append_root_image "${path}" + else + aufs_mount_root_image "${path}" + fi fi if [[ -n ${packages_lng_kde} ]]; then download_to_cache "${path}" "${packages_lng} ${packages_lng_kde}" @@ -307,8 +354,13 @@ make_image_lng() { cp ${PKGDATADIR}/pacman-lng.conf ${path}/opt/livecd rm -r ${path}/var make_repo ${path}/opt/livecd/lng/lng-pkgs ${path}/opt/livecd/lng - umount_image_handler - aufs_clean "${path}" + if [[ ${use_overlayfs} == "true" ]];then + umount "${path}" + rm -rf "${work_dir}/work" + else + umount_image_handler + aufs_clean "${path}" + fi : > ${work_dir}/build.${FUNCNAME} msg "Done [lng-image]" fi @@ -323,18 +375,32 @@ make_image_boot() { cp ${work_dir}/root-image/boot/vmlinuz* ${path_iso}/${arch}/${iso_name} local path="${work_dir}/boot-image" mkdir -p ${path} - umount_image_handler - if [[ -n "${custom}" ]] ; then - aufs_mount_custom_image "${path}" - aufs_append_root_image "${path}" + if [[ ${use_overlayfs} == "true" ]];then + mkdir -p "${work_dir}/work" + if [[ -n "${custom}" ]] ; then + mount -t overlay overlay -olowerdir="${work_dir}/${custom}-image":"${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" + else + mount -t overlay overlay -olowerdir="${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" + fi else - aufs_mount_root_image "${path}" + umount_image_handler + if [[ -n "${custom}" ]] ; then + aufs_mount_custom_image "${path}" + aufs_append_root_image "${path}" + else + aufs_mount_root_image "${path}" + fi fi copy_initcpio "${path}" || die "Failed to copy initcpio." gen_boot_image "${path}" mv ${path}/boot/${iso_name}.img ${path_iso}/${arch}/${iso_name}.img [[ -f ${path}/boot/intel-ucode.img ]] && copy_ucode "${path}" "${path_iso}" - umount_image_handler + if [[ ${use_overlayfs} == "true" ]];then + umount "${path}" + rm -rf "${work_dir}/work" + else + umount_image_handler + fi rm -R ${path} : > ${work_dir}/build.${FUNCNAME} msg "Done [${iso_name}/boot]" diff --git a/lib/util.sh b/lib/util.sh index 003d9ff..f10d6c7 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -404,6 +404,8 @@ init_buildiso(){ [[ -z ${iso_compression} ]] && iso_compression='xz' [[ -z ${iso_checksum} ]] && iso_checksum='md5' + + [[ -z ${use_overlayfs} ]] && use_overlayfs='false' } load_config(){ From bdb87f704b5026b9057c9cfc0681075d1274a3ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramon=20Buld=C3=B3?= Date: Thu, 11 Jun 2015 17:01:39 +0200 Subject: [PATCH 02/24] Removing directories inside the overlayfs will cause latter that when remounting them the directory is empty, even if the lower dirs are not. --- lib/util-iso-image.sh | 1 - lib/util-iso.sh | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/util-iso-image.sh b/lib/util-iso-image.sh index 7ed29ee..9f6b3b5 100644 --- a/lib/util-iso-image.sh +++ b/lib/util-iso-image.sh @@ -360,7 +360,6 @@ download_to_cache(){ pacman -v -Sp $2 --noconfirm > "$1"/cache-packages.txt sed -ni '/.pkg.tar.xz/p' "$1"/cache-packages.txt sed -i "s/.*\///" "$1"/cache-packages.txt - rm -rf "$1/etc" } # $1: image path diff --git a/lib/util-iso.sh b/lib/util-iso.sh index e2c061e..9f6c323 100644 --- a/lib/util-iso.sh +++ b/lib/util-iso.sh @@ -73,13 +73,11 @@ copy_livecd_helpers(){ copy_cache_lng(){ msg2 "Copying language package cache ..." rsync -v --files-from="${work_dir}/lng-image/cache-packages.txt" /var/cache/pacman/pkg "${work_dir}/lng-image/opt/livecd/lng" - rm -f "${work_dir}/lng-image/cache-packages.txt" } copy_cache_xorg(){ msg2 "Copying xorg package cache ..." rsync -v --files-from="${work_dir}/pkgs-image/cache-packages.txt" /var/cache/pacman/pkg "${work_dir}/pkgs-image/opt/livecd/pkgs" - rm -f "${work_dir}/pkgs-image/cache-packages.txt" } prepare_cachedirs(){ @@ -212,7 +210,6 @@ make_image_custom() { aufs_mount_root_image "${path}" fi chroot_create "${path}" "${packages}" - clean_up_image "${path}" pacman -Qr "${path}" > "${path}/${custom}-image-pkgs.txt" cp "${path}/${custom}-image-pkgs.txt" ${cache_dir_iso}/${iso_name}-${custom}-${dist_release}-${arch}-pkgs.txt [[ -d ${custom}-overlay ]] && copy_overlay_custom @@ -225,6 +222,7 @@ make_image_custom() { umount_image_handler aufs_clean "${path}" fi + clean_up_image "${path}" : > ${work_dir}/build.${FUNCNAME} msg "Done [${custom} installation] (${custom}-image)" fi @@ -252,7 +250,6 @@ make_image_livecd() { fi fi chroot_create "${path}" "${packages}" - clean_up_image "${path}" pacman -Qr "${path}" > "${path}/livecd-image-pkgs.txt" copy_overlay_livecd "${path}" # copy over setup helpers and config loader @@ -269,6 +266,7 @@ make_image_livecd() { umount_image_handler aufs_clean "${path}" fi + clean_up_image "${path}" : > ${work_dir}/build.${FUNCNAME} msg "Done [livecd-image]" fi @@ -313,6 +311,8 @@ make_image_xorg() { umount_image_handler aufs_clean "${path}" fi + rm -rf "${work_dir}/pkgs-image/etc" + rm -f "${work_dir}/pkgs-image/cache-packages.txt" : > ${work_dir}/build.${FUNCNAME} msg "Done [pkgs-image]" fi @@ -361,6 +361,8 @@ make_image_lng() { umount_image_handler aufs_clean "${path}" fi + rm -f "${work_dir}/lng-image/etc" + rm -f "${work_dir}/lng-image/cache-packages.txt" : > ${work_dir}/build.${FUNCNAME} msg "Done [lng-image]" fi From fef11e8ce57d1a1bcf8765e67693c7217e993b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramon=20Buld=C3=B3?= Date: Wed, 24 Jun 2015 11:05:07 +0200 Subject: [PATCH 03/24] overlayfs: fix initializing gpg at livecd boot --- lib/util-iso.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/util-iso.sh b/lib/util-iso.sh index 9f6c323..007274c 100644 --- a/lib/util-iso.sh +++ b/lib/util-iso.sh @@ -257,8 +257,6 @@ make_image_livecd() { copy_startup_scripts "${path}/usr/bin" configure_livecd_image "${path}" ${is_custom_pac_conf} && clean_pacman_conf "${path}" - # Clean up GnuPG keys? - rm -rf "${path}/etc/pacman.d/gnupg" if [[ ${use_overlayfs} == "true" ]];then umount "${path}" rm -rf "${work_dir}/work" @@ -266,6 +264,8 @@ make_image_livecd() { umount_image_handler aufs_clean "${path}" fi + # Clean up GnuPG keys + rm -rf "${path}/etc/pacman.d/gnupg" clean_up_image "${path}" : > ${work_dir}/build.${FUNCNAME} msg "Done [livecd-image]" @@ -301,7 +301,6 @@ make_image_xorg() { done fi cp ${PKGDATADIR}/pacman-gfx.conf ${path}/opt/livecd - rm -r ${path}/var make_repo "${path}/opt/livecd/pkgs/gfx-pkgs" "${path}/opt/livecd/pkgs" configure_xorg_drivers "${path}" if [[ ${use_overlayfs} == "true" ]];then @@ -311,6 +310,7 @@ make_image_xorg() { umount_image_handler aufs_clean "${path}" fi + rm -r ${path}/var rm -rf "${work_dir}/pkgs-image/etc" rm -f "${work_dir}/pkgs-image/cache-packages.txt" : > ${work_dir}/build.${FUNCNAME} @@ -352,7 +352,6 @@ make_image_lng() { done fi cp ${PKGDATADIR}/pacman-lng.conf ${path}/opt/livecd - rm -r ${path}/var make_repo ${path}/opt/livecd/lng/lng-pkgs ${path}/opt/livecd/lng if [[ ${use_overlayfs} == "true" ]];then umount "${path}" @@ -361,6 +360,7 @@ make_image_lng() { umount_image_handler aufs_clean "${path}" fi + rm -r ${path}/var rm -f "${work_dir}/lng-image/etc" rm -f "${work_dir}/lng-image/cache-packages.txt" : > ${work_dir}/build.${FUNCNAME} From 005b2db446966457c2d0455b9b716316f2b4ec18 Mon Sep 17 00:00:00 2001 From: udeved Date: Thu, 25 Jun 2015 00:16:18 +0200 Subject: [PATCH 04/24] [util-iso-overlayfs] try to keep changes in image creation code at minimum so we can switch to any filesystem we want --- Makefile | 1 + lib/util-iso-aufs.sh | 18 ++++++--- lib/util-iso-overlayfs.sh | 28 +++++++++++++ lib/util-iso.sh | 85 +++++++++++++-------------------------- 4 files changed, 69 insertions(+), 63 deletions(-) create mode 100644 lib/util-iso-overlayfs.sh diff --git a/Makefile b/Makefile index 4719b41..bd785be 100644 --- a/Makefile +++ b/Makefile @@ -66,6 +66,7 @@ LIBS_PKG = \ LIBS_ISO = \ lib/util-iso.sh \ lib/util-iso-aufs.sh \ + lib/util-iso-overlayfs.sh \ lib/util-iso-image.sh \ lib/util-iso-calamares.sh \ lib/util-livecd.sh \ diff --git a/lib/util-iso-aufs.sh b/lib/util-iso-aufs.sh index fe3e471..ed38b35 100644 --- a/lib/util-iso-aufs.sh +++ b/lib/util-iso-aufs.sh @@ -10,7 +10,7 @@ # GNU General Public License for more details. # $1: new branch -aufs_mount_root_image(){ +mount_root_image(){ msg2 "mount [root-image] on [${1##*/}]" mount -t aufs -o br="$1":${work_dir}/root-image=ro none "$1" } @@ -35,11 +35,6 @@ aufs_remove_image(){ fi } -# $1: image path -aufs_clean(){ - find $1 -name '.wh.*' -delete &> /dev/null -} - umount_image_handler(){ aufs_remove_image "${work_dir}/livecd-image" aufs_remove_image "${work_dir}/${custom}-image" @@ -47,3 +42,14 @@ umount_image_handler(){ aufs_remove_image "${work_dir}/pkgs-image" aufs_remove_image "${work_dir}/boot-image" } + +mount_custom_image(){ + aufs_mount_custom_image "$1" + aufs_append_root_image "$1" +} + +# $1: image path +umount_image(){ + umount_image_handler + find $1 -name '.wh.*' -delete &> /dev/null +} diff --git a/lib/util-iso-overlayfs.sh b/lib/util-iso-overlayfs.sh new file mode 100644 index 0000000..ef61e57 --- /dev/null +++ b/lib/util-iso-overlayfs.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# $1: new branch +mount_root_image(){ + msg2 "mount [root-image] on [${1##*/}]" + mkdir -p "${work_dir}/work" + mount -t overlay overlay -olowerdir="${work_dir}/root-image",upperdir="$1",workdir="${work_dir}/work" "$1" +} + +umount_image(){ + umount "$1" + rm -rf "${work_dir}/work" +} + +mount_custom_image(){ + msg2 "mount [${1##*/}] on [${custom}-image]" + mkdir -p "${work_dir}/work" + mount -t overlay overlay -olowerdir="${work_dir}/${custom}-image":"${work_dir}/root-image",upperdir="$1",workdir="${work_dir}/work" "$1" +} diff --git a/lib/util-iso.sh b/lib/util-iso.sh index fc30312..09dad62 100644 --- a/lib/util-iso.sh +++ b/lib/util-iso.sh @@ -12,7 +12,12 @@ import ${LIBDIR}/util-iso-image.sh import ${LIBDIR}/util-iso-boot.sh import ${LIBDIR}/util-iso-calamares.sh -import ${LIBDIR}/util-iso-aufs.sh + +if ${use_overlayfs};then + import ${LIBDIR}/util-iso-overlayfs.sh +else + import ${LIBDIR}/util-iso-aufs.sh +fi # $1: path # $2: exit code @@ -228,26 +233,18 @@ make_image_custom() { msg "Prepare [${custom} installation] (${custom}-image)" local path="${work_dir}/${custom}-image" mkdir -p ${path} - if [[ ${use_overlayfs} == "true" ]];then - mkdir -p "${work_dir}/work" - mount -t overlay overlay -olowerdir="${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" - else - umount_image_handler - aufs_mount_root_image "${path}" - fi + + mount_root_image "${path}" + chroot_create "${path}" "${packages}" pacman -Qr "${path}" > "${path}/${custom}-image-pkgs.txt" cp "${path}/${custom}-image-pkgs.txt" ${cache_dir_iso}/${iso_name}-${custom}-${dist_release}-${arch}-pkgs.txt [[ -d ${custom}-overlay ]] && copy_overlay_custom configure_custom_image "${path}" ${is_custom_pac_conf} && clean_pacman_conf "${path}" - if [[ ${use_overlayfs} == "true" ]];then - umount "${path}" - rm -rf "${work_dir}/work" - else - umount_image_handler - aufs_clean "${path}" - fi + + umount_image "${path}" + clean_up_image "${path}" : > ${work_dir}/build.${FUNCNAME} msg "Done [${custom} installation] (${custom}-image)" @@ -259,22 +256,13 @@ make_image_livecd() { msg "Prepare [livecd installation] (livecd-image)" local path="${work_dir}/livecd-image" mkdir -p ${path} - if [[ ${use_overlayfs} == "true" ]];then - mkdir -p "${work_dir}/work" - if [[ -n "${custom}" ]] ; then - mount -t overlay overlay -olowerdir="${work_dir}/${custom}-image":"${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" - else - mount -t overlay overlay -olowerdir="${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" - fi + + if [[ -n "${custom}" ]] ; then + mount_custom_image "${path}" else - umount_image_handler - if [[ -n "${custom}" ]] ; then - aufs_mount_custom_image "${path}" - aufs_append_root_image "${path}" - else - aufs_mount_root_image "${path}" - fi + mount_root_image "${path}" fi + chroot_create "${path}" "${packages}" pacman -Qr "${path}" > "${path}/livecd-image-pkgs.txt" copy_overlay_livecd "${path}" @@ -283,13 +271,9 @@ make_image_livecd() { copy_startup_scripts "${path}/usr/bin" configure_livecd_image "${path}" ${is_custom_pac_conf} && clean_pacman_conf "${path}" - if [[ ${use_overlayfs} == "true" ]];then - umount "${path}" - rm -rf "${work_dir}/work" - else - umount_image_handler - aufs_clean "${path}" - fi + + umount_image "${path}" + # Clean up GnuPG keys rm -rf "${path}/etc/pacman.d/gnupg" clean_up_image "${path}" @@ -303,22 +287,13 @@ make_image_xorg() { msg "Prepare [pkgs-image]" local path="${work_dir}/pkgs-image" mkdir -p ${path}/opt/livecd/pkgs - if [[ ${use_overlayfs} == "true" ]];then - mkdir -p "${work_dir}/work" - if [[ -n "${custom}" ]] ; then - mount -t overlay overlay -olowerdir="${work_dir}/${custom}-image":"${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" - else - mount -t overlay overlay -olowerdir="${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" - fi + + if [[ -n "${custom}" ]] ; then + mount_custom_image "${path}" else - umount_image_handler - if [[ -n "${custom}" ]] ; then - aufs_mount_custom_image "${path}" - aufs_append_root_image "${path}" - else - aufs_mount_root_image "${path}" - fi + mount_root_image "${path}" fi + download_to_cache "${path}" "${packages}" copy_cache_xorg if [[ -n "${packages_cleanup}" ]]; then @@ -329,13 +304,9 @@ make_image_xorg() { cp ${PKGDATADIR}/pacman-gfx.conf ${path}/opt/livecd make_repo "${path}/opt/livecd/pkgs/gfx-pkgs" "${path}/opt/livecd/pkgs" configure_xorg_drivers "${path}" - if [[ ${use_overlayfs} == "true" ]];then - umount "${path}" - rm -rf "${work_dir}/work" - else - umount_image_handler - aufs_clean "${path}" - fi + + umount_image "${path}" + rm -r ${path}/var rm -rf "${work_dir}/pkgs-image/etc" rm -f "${work_dir}/pkgs-image/cache-packages.txt" From 954c48d32c6134b5a6220ef4cb1b033679f330f6 Mon Sep 17 00:00:00 2001 From: udeved Date: Thu, 25 Jun 2015 00:17:09 +0200 Subject: [PATCH 05/24] [util-iso-boot] chamge mkinitcpio hook for overlayfs use --- lib/util-iso-boot.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/util-iso-boot.sh b/lib/util-iso-boot.sh index 7469851..9c1857f 100644 --- a/lib/util-iso-boot.sh +++ b/lib/util-iso-boot.sh @@ -39,6 +39,9 @@ set_mkinicpio_hooks(){ if ! ${plymouth_boot};then sed -e 's/plymouth //' -i $1 fi + if ${use_oberlayfs};then + sed -e 's/miso/miso_overlayfs/' -i $1 + fi } copy_initcpio(){ From 6b4aaf7c979a5c02b3e6ddf8bac19e3288cf032c Mon Sep 17 00:00:00 2001 From: udeved Date: Thu, 25 Jun 2015 00:17:43 +0200 Subject: [PATCH 06/24] [conf] add use_overlayfs --- conf/manjaro-tools.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf/manjaro-tools.conf b/conf/manjaro-tools.conf index d89a3a0..555a564 100644 --- a/conf/manjaro-tools.conf +++ b/conf/manjaro-tools.conf @@ -77,3 +77,6 @@ # valid: md5, sha1, sha256, sha384, sha512 # iso_checksum=md5 + +# experimental; use overlayfs instead of aufs +use_overlayfs="false" From 57a039088ae4485bc5dc411e36a90c0753e670f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramon=20Buld=C3=B3?= Date: Thu, 25 Jun 2015 02:25:05 +0200 Subject: [PATCH 07/24] livecd: Remove pamac auto-update in the livecd when the network is up, it causes various problems when booting. --- lib/util-iso-image.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/util-iso-image.sh b/lib/util-iso-image.sh index 7f62aa9..96008cc 100644 --- a/lib/util-iso-image.sh +++ b/lib/util-iso-image.sh @@ -343,6 +343,12 @@ configure_sysctl(){ fi } +# Remove pamac auto-update when the network is up, it causes problems when booting in the livecd +# $1: chroot +configure_pamac_live() { + rm -f $1/etc/NetworkManager/dispatcher.d/99_update_pamac_tray +} + configure_root_image(){ msg "Configuring [root-image]" configure_lsb "$1" @@ -369,6 +375,7 @@ configure_livecd_image(){ configure_services_live "$1" configure_calamares "$1" configure_thus "$1" + configure_pamac_live "$1" msg "Done configuring [livecd-image]" } From 7ef28c88d58a63fcd14501a0d85ae05dc9b70b26 Mon Sep 17 00:00:00 2001 From: udeved Date: Thu, 25 Jun 2015 09:59:35 +0200 Subject: [PATCH 08/24] clean up mounting code --- lib/util-iso-aufs.sh | 34 ++++++------------------------- lib/util-iso-overlayfs.sh | 13 +++++++----- lib/util-iso.sh | 43 ++++++++++++++++++--------------------- 3 files changed, 34 insertions(+), 56 deletions(-) diff --git a/lib/util-iso-aufs.sh b/lib/util-iso-aufs.sh index ed38b35..72bf9b0 100644 --- a/lib/util-iso-aufs.sh +++ b/lib/util-iso-aufs.sh @@ -15,41 +15,19 @@ mount_root_image(){ mount -t aufs -o br="$1":${work_dir}/root-image=ro none "$1" } -# $1: add branch -aufs_append_root_image(){ +mount_custom_image(){ + msg2 "mount [${1##*/}] on [${custom}-image]" + mount -t aufs -o br="$1":${work_dir}/${custom}-image=ro none "$1" + msg2 "append [root-image] on [${1##*/}]" mount -t aufs -o remount,append:${work_dir}/root-image=ro none "$1" } -# $1: add branch -aufs_mount_custom_image(){ - msg2 "mount [${1##*/}] on [${custom}-image]" - mount -t aufs -o br="$1":${work_dir}/${custom}-image=ro none "$1" -} - -# $1: del branch -aufs_remove_image(){ +# $1: image path +umount_image(){ if mountpoint -q "$1";then msg2 "unmount ${1##*/}" umount $1 fi -} - -umount_image_handler(){ - aufs_remove_image "${work_dir}/livecd-image" - aufs_remove_image "${work_dir}/${custom}-image" - aufs_remove_image "${work_dir}/root-image" - aufs_remove_image "${work_dir}/pkgs-image" - aufs_remove_image "${work_dir}/boot-image" -} - -mount_custom_image(){ - aufs_mount_custom_image "$1" - aufs_append_root_image "$1" -} - -# $1: image path -umount_image(){ - umount_image_handler find $1 -name '.wh.*' -delete &> /dev/null } diff --git a/lib/util-iso-overlayfs.sh b/lib/util-iso-overlayfs.sh index ef61e57..314e97b 100644 --- a/lib/util-iso-overlayfs.sh +++ b/lib/util-iso-overlayfs.sh @@ -16,13 +16,16 @@ mount_root_image(){ mount -t overlay overlay -olowerdir="${work_dir}/root-image",upperdir="$1",workdir="${work_dir}/work" "$1" } -umount_image(){ - umount "$1" - rm -rf "${work_dir}/work" -} - mount_custom_image(){ msg2 "mount [${1##*/}] on [${custom}-image]" mkdir -p "${work_dir}/work" mount -t overlay overlay -olowerdir="${work_dir}/${custom}-image":"${work_dir}/root-image",upperdir="$1",workdir="${work_dir}/work" "$1" } + +umount_image(){ + if mountpoint -q "$1";then + msg2 "unmount ${1##*/}" + umount $1 + rm -rf "${work_dir}/work" + fi +} diff --git a/lib/util-iso.sh b/lib/util-iso.sh index 09dad62..df9421d 100644 --- a/lib/util-iso.sh +++ b/lib/util-iso.sh @@ -59,6 +59,14 @@ check_requirements(){ fi } +umount_image_handler(){ + umount_image "${work_dir}/livecd-image" + umount_image "${work_dir}/${custom}-image" + umount_image "${work_dir}/root-image" + umount_image "${work_dir}/pkgs-image" + umount_image "${work_dir}/boot-image" +} + copy_overlay_root(){ msg2 "Copying overlay ..." cp -a --no-preserve=ownership overlay/* $1 @@ -306,10 +314,11 @@ make_image_xorg() { configure_xorg_drivers "${path}" umount_image "${path}" - + rm -r ${path}/var - rm -rf "${work_dir}/pkgs-image/etc" - rm -f "${work_dir}/pkgs-image/cache-packages.txt" + rm -rf "${path}/etc" + rm -f "${path}/cache-packages.txt" + : > ${work_dir}/build.${FUNCNAME} msg "Done [pkgs-image]" fi @@ -324,32 +333,20 @@ make_image_boot() { cp ${work_dir}/root-image/boot/vmlinuz* ${path_iso}/${arch}/${iso_name} local path="${work_dir}/boot-image" mkdir -p ${path} - if [[ ${use_overlayfs} == "true" ]];then - mkdir -p "${work_dir}/work" - if [[ -n "${custom}" ]] ; then - mount -t overlay overlay -olowerdir="${work_dir}/${custom}-image":"${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" - else - mount -t overlay overlay -olowerdir="${work_dir}/root-image",upperdir="${path}",workdir="${work_dir}/work" "${path}" - fi + + if [[ -n "${custom}" ]] ; then + mount_custom_image "${path}" else - umount_image_handler - if [[ -n "${custom}" ]] ; then - aufs_mount_custom_image "${path}" - aufs_append_root_image "${path}" - else - aufs_mount_root_image "${path}" - fi + mount_root_image "${path}" fi + copy_initcpio "${path}" || die "Failed to copy initcpio." gen_boot_image "${path}" mv ${path}/boot/${iso_name}.img ${path_iso}/${arch}/${iso_name}.img [[ -f ${path}/boot/intel-ucode.img ]] && copy_ucode "${path}" "${path_iso}" - if [[ ${use_overlayfs} == "true" ]];then - umount "${path}" - rm -rf "${work_dir}/work" - else - umount_image_handler - fi + + umount_image "${path}" + rm -R ${path} : > ${work_dir}/build.${FUNCNAME} msg "Done [${iso_name}/boot]" From 3c6200f19a5ef2552fbc731258e4aff6ee9d5722 Mon Sep 17 00:00:00 2001 From: udeved Date: Thu, 25 Jun 2015 10:00:39 +0200 Subject: [PATCH 09/24] [conf] small fix --- conf/manjaro-tools.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/manjaro-tools.conf b/conf/manjaro-tools.conf index 555a564..780920b 100644 --- a/conf/manjaro-tools.conf +++ b/conf/manjaro-tools.conf @@ -79,4 +79,4 @@ # iso_checksum=md5 # experimental; use overlayfs instead of aufs -use_overlayfs="false" +# use_overlayfs="false" From 67b4d20570a854aa7afeb0a26e26889ea518182c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramon=20Buld=C3=B3?= Date: Thu, 25 Jun 2015 12:17:33 +0200 Subject: [PATCH 10/24] Remove pacman-boot, it may slow boots times considerably. --- README.md | 4 ++-- conf/profile.conf.example | 4 ++-- lib/util.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d90b68b..daf43c9 100644 --- a/README.md +++ b/README.md @@ -186,12 +186,12 @@ Each iso profile must have these files or symlinks to shared: # unset defaults to given values # names must match systemd service names # services in start_systemd array don't need to be listed here -# start_systemd_live=('livecd' 'mhwd-live' 'pacman-init' 'pacman-boot') +# start_systemd_live=('livecd' 'mhwd-live' 'pacman-init') # unset defaults to given values, # names must match openrc service names # services in start_openrc array don't need to be listed here -# start_openrc_live=('livecd' 'mhwd-live' 'pacman-init' 'pacman-boot') +# start_openrc_live=('livecd' 'mhwd-live' 'pacman-init') ~~~ ######* Packages diff --git a/conf/profile.conf.example b/conf/profile.conf.example index 8a22a37..02ec2f6 100644 --- a/conf/profile.conf.example +++ b/conf/profile.conf.example @@ -61,9 +61,9 @@ # unset defaults to given values # names must match systemd service names # services in start_systemd array don't need to be listed here -# start_systemd_live=('livecd' 'mhwd-live' 'pacman-init' 'pacman-boot') +# start_systemd_live=('livecd' 'mhwd-live' 'pacman-init') # unset defaults to given values, # names must match openrc service names # services in start_openrc array don't need to be listed here -# start_openrc_live=('livecd' 'mhwd-live' 'pacman-init' 'pacman-boot') +# start_openrc_live=('livecd' 'mhwd-live' 'pacman-init') diff --git a/lib/util.sh b/lib/util.sh index a373d87..eb9011e 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -452,11 +452,11 @@ load_profile_config(){ fi if [[ -z ${start_systemd_live[@]} ]];then - start_systemd_live=('livecd' 'mhwd-live' 'pacman-init' 'pacman-boot') + start_systemd_live=('livecd' 'mhwd-live' 'pacman-init') fi if [[ -z ${start_openrc_live[@]} ]];then - start_openrc_live=('livecd' 'mhwd-live' 'pacman-init' 'pacman-boot') + start_openrc_live=('livecd' 'mhwd-live' 'pacman-init') fi return 0 From 3b32ed3af0afdb7987892088bc71d9f986d7181b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramon=20Buld=C3=B3?= Date: Thu, 25 Jun 2015 12:30:30 +0200 Subject: [PATCH 11/24] Fix typo --- lib/util-iso-boot.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util-iso-boot.sh b/lib/util-iso-boot.sh index 9c1857f..a59f432 100644 --- a/lib/util-iso-boot.sh +++ b/lib/util-iso-boot.sh @@ -39,8 +39,8 @@ set_mkinicpio_hooks(){ if ! ${plymouth_boot};then sed -e 's/plymouth //' -i $1 fi - if ${use_oberlayfs};then - sed -e 's/miso/miso_overlayfs/' -i $1 + if ${use_overlayfs};then + sed -e 's/miso /miso_overlayfs/' -i $1 fi } From 9c9045b8e6aef024f2bb7252d61ef40f6ea14703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramon=20Buld=C3=B3?= Date: Thu, 25 Jun 2015 12:30:54 +0200 Subject: [PATCH 12/24] Fix missing space --- lib/util-iso-boot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util-iso-boot.sh b/lib/util-iso-boot.sh index a59f432..b7293a4 100644 --- a/lib/util-iso-boot.sh +++ b/lib/util-iso-boot.sh @@ -40,7 +40,7 @@ set_mkinicpio_hooks(){ sed -e 's/plymouth //' -i $1 fi if ${use_overlayfs};then - sed -e 's/miso /miso_overlayfs/' -i $1 + sed -e 's/miso /miso_overlayfs /' -i $1 fi } From 176d6d9cc242a9423ea9b78db48fb7233fa539b0 Mon Sep 17 00:00:00 2001 From: udeved Date: Thu, 25 Jun 2015 16:57:04 +0200 Subject: [PATCH 13/24] [buildiso] show use_overlayfs on -q --- bin/buildiso.in | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/buildiso.in b/bin/buildiso.in index 08d371e..b936735 100755 --- a/bin/buildiso.in +++ b/bin/buildiso.in @@ -104,6 +104,7 @@ display_settings(){ msg2 "iso_app_id: ${iso_app_id}" msg2 "iso_compression: ${iso_compression}" msg2 "iso_checksum: ${iso_checksum}" + msg2 "use_overlayfs: ${use_overlayfs}" msg "BUILD QUEUE:" show_build_queue From d568fbecf9673a09b1a113b63c2977ab61745d5d Mon Sep 17 00:00:00 2001 From: udeved Date: Thu, 25 Jun 2015 16:57:34 +0200 Subject: [PATCH 14/24] [conf] document mimimum kernel req for overlayfs --- conf/manjaro-tools.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/manjaro-tools.conf b/conf/manjaro-tools.conf index 780920b..888848a 100644 --- a/conf/manjaro-tools.conf +++ b/conf/manjaro-tools.conf @@ -79,4 +79,5 @@ # iso_checksum=md5 # experimental; use overlayfs instead of aufs +# requires minimum 4.0 kernel on the build host # use_overlayfs="false" From 1f2b60af61ba0c2aef731c48bb8b0d9f30642201 Mon Sep 17 00:00:00 2001 From: udeved Date: Thu, 25 Jun 2015 16:59:11 +0200 Subject: [PATCH 15/24] update readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index daf43c9..5eaf7be 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,10 @@ Specifying args will override manjaro-tools.conf settings. # valid: md5, sha1, sha256, sha384, sha512 # iso_checksum=md5 + +# experimental; use overlayfs instead of aufs +# requires minimum 4.0 kernel on the build host +# use_overlayfs="false" ~~~ ####Config files in iso profiles From 9c681f2404a9d5e99634b6be37fb9e5e76e5d1c7 Mon Sep 17 00:00:00 2001 From: udeved Date: Thu, 25 Jun 2015 17:53:18 +0200 Subject: [PATCH 16/24] [util-iso-aufs] perhaps fixes the long standing umount error on certain conditions --- lib/util-iso-aufs.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/util-iso-aufs.sh b/lib/util-iso-aufs.sh index 72bf9b0..a097095 100644 --- a/lib/util-iso-aufs.sh +++ b/lib/util-iso-aufs.sh @@ -17,10 +17,7 @@ mount_root_image(){ mount_custom_image(){ msg2 "mount [${1##*/}] on [${custom}-image]" - mount -t aufs -o br="$1":${work_dir}/${custom}-image=ro none "$1" - - msg2 "append [root-image] on [${1##*/}]" - mount -t aufs -o remount,append:${work_dir}/root-image=ro none "$1" + mount -t aufs -o br="$1":${work_dir}/${custom}-image=ro:${work_dir}/root-image=ro none "$1" } # $1: image path From 04d8622c0aebbf1d16e004972aa02872aa04b4ce Mon Sep 17 00:00:00 2001 From: udeved Date: Thu, 25 Jun 2015 18:00:45 +0200 Subject: [PATCH 17/24] [conf] upd manjaro-tools.conf doc --- conf/manjaro-tools.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/manjaro-tools.conf b/conf/manjaro-tools.conf index 888848a..1640a93 100644 --- a/conf/manjaro-tools.conf +++ b/conf/manjaro-tools.conf @@ -79,5 +79,5 @@ # iso_checksum=md5 # experimental; use overlayfs instead of aufs -# requires minimum 4.0 kernel on the build host +# requires minimum 4.0 kernel on the build host and on iso in profile.conf # use_overlayfs="false" From 997a0b7da8815a107567bcf6faeb0b9ffb470c5d Mon Sep 17 00:00:00 2001 From: udeved Date: Thu, 25 Jun 2015 18:00:55 +0200 Subject: [PATCH 18/24] upd readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5eaf7be..395b56c 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ Specifying args will override manjaro-tools.conf settings. # iso_checksum=md5 # experimental; use overlayfs instead of aufs -# requires minimum 4.0 kernel on the build host +# requires minimum 4.0 kernel on the build host and on iso in profile.conf # use_overlayfs="false" ~~~ From 0bbddff9306c12b375c281d612d4939efcb7408c Mon Sep 17 00:00:00 2001 From: udeved Date: Thu, 25 Jun 2015 20:30:01 +0200 Subject: [PATCH 19/24] [util-iso-image] try to fix local repo issue add pacman.conf to chroot-run args --- lib/util-iso-image.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/util-iso-image.sh b/lib/util-iso-image.sh index 96008cc..46ff4b8 100644 --- a/lib/util-iso-image.sh +++ b/lib/util-iso-image.sh @@ -389,12 +389,14 @@ download_to_cache(){ chroot-run \ -r "${mountargs_ro}" \ -w "${mountargs_rw}" \ + -C ${PKGDATADIR}/pacman-${pacman_conf_arch}.conf \ -B "${build_mirror}/${branch}" \ "$1" \ pacman -v -Syw $2 --noconfirm chroot-run \ -r "${mountargs_ro}" \ -w "${mountargs_rw}" \ + -C ${PKGDATADIR}/pacman-${pacman_conf_arch}.conf \ -B "${build_mirror}/${branch}" \ "$1" \ pacman -v -Sp $2 --noconfirm > "$1"/cache-packages.txt From 276d2a1be5640772ea5ef52d12ee6820035a4e3e Mon Sep 17 00:00:00 2001 From: udeved Date: Thu, 25 Jun 2015 20:51:56 +0200 Subject: [PATCH 20/24] [util-iso] revert previous, simply cleaning pacman_conf on pkgs image should do --- lib/util-iso-image.sh | 2 -- lib/util-iso.sh | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util-iso-image.sh b/lib/util-iso-image.sh index 46ff4b8..96008cc 100644 --- a/lib/util-iso-image.sh +++ b/lib/util-iso-image.sh @@ -389,14 +389,12 @@ download_to_cache(){ chroot-run \ -r "${mountargs_ro}" \ -w "${mountargs_rw}" \ - -C ${PKGDATADIR}/pacman-${pacman_conf_arch}.conf \ -B "${build_mirror}/${branch}" \ "$1" \ pacman -v -Syw $2 --noconfirm chroot-run \ -r "${mountargs_ro}" \ -w "${mountargs_rw}" \ - -C ${PKGDATADIR}/pacman-${pacman_conf_arch}.conf \ -B "${build_mirror}/${branch}" \ "$1" \ pacman -v -Sp $2 --noconfirm > "$1"/cache-packages.txt diff --git a/lib/util-iso.sh b/lib/util-iso.sh index df9421d..9adfd98 100644 --- a/lib/util-iso.sh +++ b/lib/util-iso.sh @@ -301,6 +301,8 @@ make_image_xorg() { else mount_root_image "${path}" fi + + ${is_custom_pac_conf} && clean_pacman_conf "${path}" download_to_cache "${path}" "${packages}" copy_cache_xorg From e7bea908b409cc4a5eecee64c4a1bafb0beee121 Mon Sep 17 00:00:00 2001 From: udeved Date: Fri, 26 Jun 2015 19:08:29 +0200 Subject: [PATCH 21/24] [Makefile] start 0.9.10 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bd785be..77781f6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -Version=0.9.9 +Version=0.9.10 PREFIX = /usr/local SYSCONFDIR = /etc From ddfaeaf8517eeffdb763923322e1dc8f368fd53e Mon Sep 17 00:00:00 2001 From: udeved Date: Fri, 26 Jun 2015 21:19:52 +0200 Subject: [PATCH 22/24] [util-iso] change merged temporary list location to work_dir --- lib/util-iso.sh | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/lib/util-iso.sh b/lib/util-iso.sh index 9adfd98..ae76cac 100644 --- a/lib/util-iso.sh +++ b/lib/util-iso.sh @@ -24,7 +24,6 @@ fi check_profile(){ local keyfiles=('profile.conf' 'mkinitcpio.conf' 'Packages' 'Packages-Livecd') local keydirs=('overlay' 'overlay-livecd' 'isolinux') - local err="Profile [$1] sanity check failed!" local has_keyfiles=false has_keydirs=false for f in ${keyfiles[@]}; do if [[ -f $1/$f ]];then @@ -245,6 +244,7 @@ make_image_custom() { mount_root_image "${path}" chroot_create "${path}" "${packages}" + pacman -Qr "${path}" > "${path}/${custom}-image-pkgs.txt" cp "${path}/${custom}-image-pkgs.txt" ${cache_dir_iso}/${iso_name}-${custom}-${dist_release}-${arch}-pkgs.txt [[ -d ${custom}-overlay ]] && copy_overlay_custom @@ -272,6 +272,7 @@ make_image_livecd() { fi chroot_create "${path}" "${packages}" + pacman -Qr "${path}" > "${path}/livecd-image-pkgs.txt" copy_overlay_livecd "${path}" # copy over setup helpers and config loader @@ -301,7 +302,7 @@ make_image_xorg() { else mount_root_image "${path}" fi - + ${is_custom_pac_conf} && clean_pacman_conf "${path}" download_to_cache "${path}" "${packages}" @@ -497,28 +498,16 @@ load_pkgs(){ _purge="s|>cleanup.*||g" \ _purge_rm="s|>cleanup||g" + local list + if [[ $1 == "${packages_custom}" ]];then - local temp=/tmp/buildiso - prepare_dir ${temp} - sort -u ../shared/Packages-Custom ${packages_custom} > ${temp}/${packages_custom} - packages=$(sed "$_com_rm" "${temp}/${packages_custom}" \ - | sed "$_space" \ - | sed "$_blacklist" \ - | sed "$_purge" \ - | sed "$_init" \ - | sed "$_init_rm" \ - | sed "$_arch" \ - | sed "$_arch_rm" \ - | sed "$_nonfree_default" \ - | sed "$_multi" \ - | sed "$_nonfree_i686" \ - | sed "$_nonfree_x86_64" \ - | sed "$_nonfree_multi" \ - | sed "$_kernel" \ - | sed "$_clean") - #rm ${temp}/${packages_custom} + sort -u ../shared/Packages-Custom ${packages_custom} > ${work_dir}/${packages_custom} + list=${work_dir}/${packages_custom} else - packages=$(sed "$_com_rm" "$1" \ + list=$1 + fi + + packages=$(sed "$_com_rm" "$list" \ | sed "$_space" \ | sed "$_blacklist" \ | sed "$_purge" \ @@ -533,7 +522,6 @@ load_pkgs(){ | sed "$_nonfree_multi" \ | sed "$_kernel" \ | sed "$_clean") - fi if [[ $1 == 'Packages-Xorg' ]]; then packages_cleanup=$(sed "$_com_rm" "$1" \ From 2d752be2d1dbeff67e60b26cb661dc553e00c69e Mon Sep 17 00:00:00 2001 From: udeved Date: Fri, 26 Jun 2015 21:31:02 +0200 Subject: [PATCH 23/24] update readme --- README.md | 113 +----------------------------------------------------- 1 file changed, 1 insertion(+), 112 deletions(-) diff --git a/README.md b/README.md index 395b56c..3909c74 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ manjaro-tools ============= -Manjaro-tools-0.9.9 +Manjaro-tools-0.9.10 User manual @@ -119,117 +119,6 @@ Specifying args will override manjaro-tools.conf settings. # use_overlayfs="false" ~~~ -####Config files in iso profiles - -Each iso profile must have these files or symlinks to shared: - - -######* profile.conf - -~~~ -########################################## -###### use this file in the profile ###### -########################################## - -# possible values: openrc,systemd -# initsys="systemd" - -# use multilib packages; x86_64 only -# multilib="true" - -# displaymanager="lightdm" - -# Set to false to disable autologin in the livecd -# autologin="true" - -# nonfree xorg drivers -# nonfree_xorg="true" - -# use plymouth; initcpio hook -# plymouth_boot="true" - -# use pxe boot; initcpio hook -# pxe_boot="true" - -################ install ################ - -# unset defaults to given value -# kernel="linux319" - -# unset defaults to given value -# efi_boot_loader="grub" - -# set uefi partition size -# efi_part_size=32M - -# unset defaults to given value -# plymouth_theme=manjaro-elegant - -# unset defaults to given values -# names must match systemd service names -# start_systemd=('bluetooth' 'cronie' 'ModemManager' 'NetworkManager' 'org.cups.cupsd' 'tlp' 'tlp-sleep') - -# unset defaults to given values, -# names must match openrc service names -# start_openrc=('acpid' 'bluetooth' 'consolekit' 'cronie' 'cupsd' 'dbus' 'syslog-ng' 'NetworkManager') - -################# livecd ################# - -# unset defaults to given value -# hostname="manjaro" - -# unset defaults to given value -# username="manjaro" - -# unset defaults to given value -# password="manjaro" - -# unset defaults to given values -# addgroups="video,audio,power,disk,storage,optical,network,lp,scanner,wheel" - -# unset defaults to given values -# names must match systemd service names -# services in start_systemd array don't need to be listed here -# start_systemd_live=('livecd' 'mhwd-live' 'pacman-init') - -# unset defaults to given values, -# names must match openrc service names -# services in start_openrc array don't need to be listed here -# start_openrc_live=('livecd' 'mhwd-live' 'pacman-init') -~~~ - -######* Packages -* Contains root image packages -* ideally no xorg - -######* Packages-Custom/desktop -* Contains the custom image packages -* desktop environment packages go here -* this file is joined at build time with shared/Packages-Custom to pull in shared desktop packages - -######* Packages-Xorg -* Contains the Xorg package repo - -######* Packages-Livecd -* Contains packages you only want on livecd but not installed on the target system with installer -* default files are in shared folder and can be symlinked or defined in a real file - -###### optional custom pacman.conf in profile - -* for i686 - -~~~ -pacman-default.conf -~~~ - -* for x86_64 - -~~~ -pacman-multilib.conf -~~~ - -If you need a custom livecd-overlay, create overlay-livecd folder in profile, and symlink from shared/overlay-livecd/your_selection to the overlay-livecd folder. - ###2. buildpkg buildpkg is the chroot build script of manjaro-tools. From d3ad2b453fee4fc56da7e19de3b221cc211fd1c1 Mon Sep 17 00:00:00 2001 From: udeved Date: Fri, 26 Jun 2015 22:38:32 +0200 Subject: [PATCH 24/24] [util-iso] use Packages-Desktop as more logical name for shared desktop packages --- lib/util-iso.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util-iso.sh b/lib/util-iso.sh index ae76cac..20e6b63 100644 --- a/lib/util-iso.sh +++ b/lib/util-iso.sh @@ -501,7 +501,7 @@ load_pkgs(){ local list if [[ $1 == "${packages_custom}" ]];then - sort -u ../shared/Packages-Custom ${packages_custom} > ${work_dir}/${packages_custom} + sort -u ../shared/Packages-Desktop ${packages_custom} > ${work_dir}/${packages_custom} list=${work_dir}/${packages_custom} else list=$1