[or-cvs] r11613: More general approach to chosing which files to copy. (incognito/trunk/root_overlay/usr/sbin)
double at seul.org
double at seul.org
Mon Sep 24 19:41:15 UTC 2007
Author: double
Date: 2007-09-24 15:41:15 -0400 (Mon, 24 Sep 2007)
New Revision: 11613
Modified:
incognito/trunk/root_overlay/usr/sbin/create-usb
Log:
More general approach to chosing which files to copy.
Modified: incognito/trunk/root_overlay/usr/sbin/create-usb
===================================================================
--- incognito/trunk/root_overlay/usr/sbin/create-usb 2007-09-24 18:18:38 UTC (rev 11612)
+++ incognito/trunk/root_overlay/usr/sbin/create-usb 2007-09-24 19:41:15 UTC (rev 11613)
@@ -115,16 +115,18 @@
# Main script:
-# Required files
-IMAGE="image.squashfs"
-REQUIRED_FILES="isolinux/isolinux.cfg isolinux/vesamenu.c32 isolinux/splash.png isolinux/gentoo isolinux/gentoo.igz ${IMAGE}"
-COPY_FILES="livecd README.txt readme.html isolinux/isolinux.cfg isolinux/vesamenu.c32 isolinux/splash.png isolinux/*.msg isolinux/gentoo isolinux/gentoo.igz ${IMAGE}"
-
# Root of the Live CD
if [[ -z "${MEDIAROOT}" ]]; then
MEDIAROOT="/mnt/cdrom"
fi
+# Required files
+IMAGE="image.squashfs"
+REQUIRED_FILES="isolinux/isolinux.cfg isolinux/vesamenu.c32 isolinux/splash.png isolinux/gentoo isolinux/gentoo.igz ${IMAGE}"
+EXCLUDE="System.map-gentoo|isolinux.bin|boot.cat|kernels.msg"
+COPY_FILES=$( find ${MEDIAROOT} ! -type d | egrep -v "$EXCLUDE" | sed "s|${MEDIAROOT}/||g" )
+DIRS=$( find ${MEDIAROOT} -type d | egrep -v "$EXCLUDE" | sed "s|${MEDIAROOT}/||g" | sed "s|isolinux|syslinux|g")
+
# Find the dialog command
DIALOG="$(which Xdialog 2>/dev/null)"
if [ -z "${DIALOG}" -o -z "${DISPLAY}" ]; then
@@ -171,7 +173,7 @@
MEDIAFREE="$(df -k -P "${MTPT}" | tail -n 1 | awk '{ print $4 }')"
# Account for files that will be overwritten
for FILE in ${COPY_FILES}; do
- for FP in $(ls ${MTPT}/$(basename ${FILE}) 2>/dev/null); do
+ for FP in $(ls ${MTPT}/${FILE} 2>/dev/null); do
MEDIAFREE=$(( ${MEDIAFREE}+$(stat --format=%s ${FP})/1024 ))
done
done
@@ -190,15 +192,20 @@
exit 1
fi
+# Create directories
+for DIR in ${DIRS}; do
+ mkdir -p "${MTPT}/${DIR}" 2>/dev/null
+done
+
# Copy files
-TOTAL=8
+TOTAL=$( echo $FILES | wc -w )
CURRENT=0
for FILE in ${COPY_FILES}; do
FP="${MEDIAROOT}/${FILE}"
if [[ -r "${FP}" ]]; then
- cp -v "${FP}" "${MTPT}/$(basename ${FILE//isolinux/syslinux})"
+ cp -v "${FP}" "${MTPT}/${FILE//isolinux/syslinux}"
else
- cp -v ${FP} "${MTPT}"
+ cp -v ${FP} "${MTPT}/${FILE//isolinux/syslinux}"
fi
ERR=$?
if [[ $? -ne 0 ]]; then
@@ -209,7 +216,7 @@
export FAILED=1
exit 1
fi
- echo $(( (${CURRENT}*100)/${TOTAL} ))
+ [[ "${TOTAL}" -gt 0 ]] && echo $(( (${CURRENT}*100)/${TOTAL} ))
CURRENT=$(( ${CURRENT}+1 ))
done | ${DIALOG} --progress "Copying files" 0 ${DEFAULT_WIDTH}
More information about the tor-commits
mailing list