summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>2010-04-23 23:01:15 -0300
committerGerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>2010-04-23 23:07:51 -0300
commit180d9b1cc539f15cb9afd5a6d95f144219e40f1c (patch)
tree49936e13eb005ac3db334d46975654d9f03da1b9
parentde4c11c56c90aec834212cf6ad17ee86389dcb48 (diff)
downloadarchiso32-180d9b1cc539f15cb9afd5a6d95f144219e40f1c.tar.xz
[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 <profile> 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 <vmlinuz386@yahoo.com.ar>
-rw-r--r--archiso2dual/Makefile1
-rwxr-xr-xarchiso2dual/archiso2dual185
-rw-r--r--archiso2dual/removefiles.lst7
3 files changed, 64 insertions, 129 deletions
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_make_image() {
+root_image_purge() {
echo "Executing: ${FUNCNAME}"
- for _arch in i686 x86_64; do
- mksquashfs_image root-image ${_arch}
- done
+ 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_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_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_remove_libmodules() {
+root_image_make_image() {
echo "Executing: ${FUNCNAME}"
for _arch in i686 x86_64; do
+ rm -rf ${work_dir}/tmp/${_arch}/root-image/usr/share
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 <isolinux> Path to isolinux.cfg file
(default to '${isolinuxcfg_file}'"
+ echo " -R <removefiles> Path to removefiles file
+ (default to '${removefiles_file}'"
echo " -w <workdir> Set work directory
(default to '${work_dir}')"
echo " -T <profile> 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 <label> Set a label for the disk [max 11 chars]
(default to '${label}')"
@@ -327,12 +227,17 @@ show_config() {
echo " target iso image: ${imgname}"
echo " isomounts file: ${isomounts_file}.{i686,x86_64,x86_64-i686}"
echo " isolinux.cfg file: ${isolinuxcfg_file}"
+ echo " removefiles.lst file: ${removefiles_file}"
echo " working directory: ${work_dir}"
echo " profile: ${profile_type}"
echo " label: ${label}"
echo " publisher: ${publisher}"
echo " application: ${application}"
echo
+ if [ "${profile_type}" = "full" ]; then
+ echo "These files will be deleted (selected via -R option)"
+ root_image_list_purge
+ fi
}
options_check() {
@@ -393,6 +298,11 @@ sanity_check() {
_error="1"
fi
+ if [ ! -f "${removefiles_file}" ]; then
+ echo "*ERROR*: ${removefiles_file} does not exist, specify one with -R option"
+ _error="1"
+ fi
+
if [ -d "${work_dir}" ]; then
echo "*ERROR*: work directory ${work_dir} is present, first delete it"
_error="1"
@@ -408,18 +318,19 @@ if [ "$EUID" != "0" ]; then
exit 1
fi
-while getopts '3:6:o:T:M:S:L:P:A:yvh' arg; do
+while getopts '3:6:o:T:M:S:R:L:P:A:yvh' arg; do
case "${arg}" in
3) isofile_i686="${OPTARG}" ;;
6) isofile_x86_64="${OPTARG}" ;;
o) imgname="${OPTARG}" ;;
T) case "${OPTARG}" in
- "basic"|"split"|"purge_us"|"full") profile_type="${OPTARG}" ;;
+ "basic"|"split"|"full") profile_type="${OPTARG}" ;;
*) echo; echo "*ERROR*: invalid argument in -T option: ${profile_type}"; show_help 1 ;;
esac
;;
M) isomounts_file="${OPTARG}" ;;
S) isolinuxcfg_file="${OPTARG}" ;;
+ R) removefiles_file="${OPTARG}" ;;
L) label="${OPTARG}" ;;
P) publisher="${OPTARG}" ;;
A) application="${OPTARG}" ;;
@@ -441,5 +352,21 @@ if [ "${_confirm}" != "y" ]; then
exit 1
fi
-# wiiiiiipuuuuu :)
-do_${profile_type}
+make_workspace
+iso_mount
+kernel_copy
+isolinux_copy
+squashfs_copy
+iso_umount
+isolinuxcfg_copy
+isomounts_copy
+if [ ${profile_type} = "full" ] || [ ${profile_type} = "split" ]; then
+ root_image_extract
+ if [ ${profile_type} = "full" ]; then
+ root_image_purge
+ fi
+ usrshare_make_image
+ libmodules_make_image
+ root_image_make_image
+fi
+make_iso
diff --git a/archiso2dual/removefiles.lst b/archiso2dual/removefiles.lst
new file mode 100644
index 0000000..516ff02
--- /dev/null
+++ b/archiso2dual/removefiles.lst
@@ -0,0 +1,7 @@
+# files/directories to remove from root-image.sqfs
+boot
+usr/include
+usr/share/doc
+usr/share/info
+usr/share/man
+usr/src