From 180d9b1cc539f15cb9afd5a6d95f144219e40f1c Mon Sep 17 00:00:00 2001 From: Gerardo Exequiel Pozzi Date: Fri, 23 Apr 2010 23:01:15 -0300 Subject: [PATCH] [archiso2dual] Refactor the code Notable changes: * -R option added. Used to specify a file with a list of files or directories to remove from root-image.sqfs. This option only works with -T full. A list of files/directories that will be removed is printed. * -T purge_us profile removed, now is managed via -R option. * Profiles looks now: -T Type of target image (work is done on root-image.sqfs): basic: join both images, no changes in root-image split: 'basic' + split out usr/share/ and lib/modules/ from root-image full: 'split' + remove specified directories (with -R) from root-image * Code is now a bit small made by some refactions. Signed-off-by: Gerardo Exequiel Pozzi --- archiso2dual/Makefile | 1 + archiso2dual/archiso2dual | 191 +++++++++++------------------------ archiso2dual/removefiles.lst | 7 ++ 3 files changed, 67 insertions(+), 132 deletions(-) create mode 100644 archiso2dual/removefiles.lst diff --git a/archiso2dual/Makefile b/archiso2dual/Makefile index 43c7ad1..eaa031d 100644 --- a/archiso2dual/Makefile +++ b/archiso2dual/Makefile @@ -7,6 +7,7 @@ install: all install -D -m 644 isomounts.x86_64 $(DESTDIR)/usr/share/archiso2dual/isomounts.x86_64 install -D -m 644 isomounts.x86_64-i686 $(DESTDIR)/usr/share/archiso2dual/isomounts.x86_64-i686 install -D -m 644 isolinux.cfg $(DESTDIR)/usr/share/archiso2dual/isolinux.cfg + install -D -m 644 removefiles.lst $(DESTDIR)/usr/share/archiso2dual/removefiles.lst uninstall: rm -f $(DESTDIR)/usr/sbin/archiso2dual diff --git a/archiso2dual/archiso2dual b/archiso2dual/archiso2dual index b4cd934..376761f 100755 --- a/archiso2dual/archiso2dual +++ b/archiso2dual/archiso2dual @@ -18,6 +18,7 @@ profile_type="basic" work_dir="/tmp/archiso2dual" isomounts_file="/usr/share/archiso2dual/isomounts" isolinuxcfg_file="/usr/share/archiso2dual/isolinux.cfg" +removefiles_file="/usr/share/archiso2dual/removefiles.lst" appname=${0##*/} _error="0" _confirm="n" @@ -117,36 +118,19 @@ mksquashfs_image() { fi } -usrshare_copy_from_root_image() { +usrshare_make_image() { echo "Executing: ${FUNCNAME}" mkdir -p ${work_dir}/tmp/any/usrshare/usr cp -a ${work_dir}/tmp/i686/root-image/usr/share ${work_dir}/tmp/any/usrshare/usr -} - -usrshare_purge() { - echo "Executing: ${FUNCNAME}" - rm -rf ${work_dir}/tmp/any/usrshare/usr/share/man - rm -rf ${work_dir}/tmp/any/usrshare/usr/share/info - rm -rf ${work_dir}/tmp/any/usrshare/usr/share/doc -} - -usrshare_make_image() { - echo "Executing: ${FUNCNAME}" mksquashfs_image usrshare any } libmodules_make_image() { - echo "Executing: ${FUNCNAME}" - for _arch in i686 x86_64; do - mksquashfs_image libmodules ${_arch} - done -} - -libmodules_copy_from_root_image() { echo "Executing: ${FUNCNAME}" for _arch in i686 x86_64; do mkdir -p ${work_dir}/tmp/${_arch}/libmodules/lib cp -a ${work_dir}/tmp/${_arch}/root-image/lib/modules ${work_dir}/tmp/${_arch}/libmodules/lib + mksquashfs_image libmodules ${_arch} done } @@ -157,33 +141,31 @@ root_image_extract() { done } +root_image_purge() { + echo "Executing: ${FUNCNAME}" + while read _file; do + [ "${_file#"#"}" != "${_file}" ] && continue + for _arch in i686 x86_64; do + rm -rf "${work_dir}/tmp/${_arch}/root-image/${_file}" + done + done < "${removefiles_file}" +} + +root_image_list_purge() { + while read _file; do + [ "${_file#"#"}" != "${_file}" ] && continue + for _arch in i686 x86_64; do + echo "${work_dir}/tmp/${_arch}/root-image/${_file}" + done + done < "${removefiles_file}" +} + root_image_make_image() { - echo "Executing: ${FUNCNAME}" - for _arch in i686 x86_64; do - mksquashfs_image root-image ${_arch} - done -} - -root_image_remove_usrshare() { echo "Executing: ${FUNCNAME}" for _arch in i686 x86_64; do rm -rf ${work_dir}/tmp/${_arch}/root-image/usr/share - done -} - -root_image_remove_libmodules() { - echo "Executing: ${FUNCNAME}" - for _arch in i686 x86_64; do rm -rf ${work_dir}/tmp/${_arch}/root-image/lib/modules - done -} - -root_image_purge() { - echo "Executing: ${FUNCNAME}" - for _arch in i686 x86_64; do - rm -rf ${work_dir}/tmp/${_arch}/root-image/boot - rm -rf ${work_dir}/tmp/${_arch}/root-image/usr/include - rm -rf ${work_dir}/tmp/${_arch}/root-image/usr/src + mksquashfs_image root-image ${_arch} done } @@ -200,89 +182,6 @@ make_workspace() { mkdir ${_v} -p ${work_dir}/tmp/any } -do_common_begin() { - make_workspace - - iso_mount - - kernel_copy - isolinux_copy - squashfs_copy - - iso_umount - - isolinuxcfg_copy - isomounts_copy -} - -do_common_end() { - make_iso -} - -do_basic() { - do_common_begin - do_common_end -} - -do_split() { - do_common_begin - - root_image_extract - - usrshare_copy_from_root_image - usrshare_make_image - - libmodules_copy_from_root_image - libmodules_make_image - - root_image_remove_usrshare - root_image_remove_libmodules - root_image_make_image - - do_common_end -} - -do_purge_us() { - do_common_begin - - root_image_extract - - usrshare_copy_from_root_image - usrshare_purge - usrshare_make_image - - libmodules_copy_from_root_image - libmodules_make_image - - root_image_remove_usrshare - root_image_remove_libmodules - root_image_make_image - - do_common_end -} - -do_full() { - do_common_begin - - root_image_extract - - usrshare_copy_from_root_image - usrshare_purge - usrshare_make_image - - libmodules_copy_from_root_image - libmodules_make_image - - root_image_remove_usrshare - root_image_remove_libmodules - root_image_purge - root_image_make_image - - do_common_end -} - - - show_help() { exitvalue=${1} @@ -299,13 +198,14 @@ show_help() (default to '${isomounts_file}'" echo " -S Path to isolinux.cfg file (default to '${isolinuxcfg_file}'" + echo " -R Path to removefiles file + (default to '${removefiles_file}'" echo " -w Set work directory (default to '${work_dir}')" echo " -T Type of target image (work is done on root-image.sqfs): - basic: join both images, no changes in *.sqfs - split: 'basic' + split usr/share/ and lib/modules/ from / - purge_us: 'split' + prune usr/share/{doc,info,man}/ - full: 'purge_us' + prune boot/ usr/include/ usr/src/ + basic: join both images, no changes in root-image + split: 'basic' + split out usr/share/ and lib/modules/ from root-image + full: 'split' + remove specified directories (with -R) from root-image (default to '${profile_type}')" echo " -L