summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMarco Amadori <marco.amadori@gmail.com>2008-06-06 23:44:09 +0200
committerDaniel Baumann <daniel@debian.org>2011-03-09 17:48:00 +0100
commit02f0fb6ca32464adc6d6dd80878ac62bd75048ec (patch)
treecdfb6a4b32d31ecd6e070c55deba45d24fc492b3 /bin
parent41e9edcaf36bf2b7d56eee71bee80703176d111e (diff)
downloadlive-boot-02f0fb6ca32464adc6d6dd80878ac62bd75048ec.tar.gz
live-boot-02f0fb6ca32464adc6d6dd80878ac62bd75048ec.zip
live-snapshot: now supports a static keep file list.
* Included support for specifing a list of files/dirs to be explicitly kept between reboots, enabled only for the "cpio" snapshot type. Look at "/usr/share/doc/live-initramfs/examples/live-snapshot.list" for hints.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/live-snapshot62
1 files changed, 55 insertions, 7 deletions
diff --git a/bin/live-snapshot b/bin/live-snapshot
index a6550e5..b81a6af 100755
--- a/bin/live-snapshot
+++ b/bin/live-snapshot
@@ -48,13 +48,16 @@ SAFE_TMPDIR="/live"
# Permits multiple runs
MOUNTP="$(mktemp -d -p ${SAFE_TMPDIR} live-snapshot-mnt.XXXXXX)"
DEST="${MOUNTP}/live-sn.cpio.gz"
+DEF_SNAP_COW="/live/cow"
+TMP_FILELIST="${PROGRAM}.list"
# Command line defaults and declarations
-SNAP_COW="/live/cow"
+SNAP_COW="${DEF_SNAP_COW}"
SNAP_DEV=""
SNAP_OUTPUT=""
SNAP_RESYNC_STRING=""
SNAP_TYPE="cpio"
+SNAP_LIST="/etc/live-snapshot.list"
Error ()
{
@@ -312,21 +315,61 @@ Mount_device ()
esac
}
+Do_filelist ()
+{
+ # BUGS: supports only cpio.gz types right now
+ TMP_FILELIST=$1
+ if [ -f "${SNAP_LIST}" ]
+ then
+ # Generate include list
+ for entry in $(cat "${SNAP_LIST}" | grep -v '^#.*$' | grep -v '^ *$')
+ do
+ if [ -f "${entry}" ]
+ then
+ printf "%s\000" "${entry}" >> "${TMP_FILELIST}"
+ elif [ -d "${entry}" ]
+ then
+ cd /
+ find "${entry}" -print0 >> "${TMP_FILELIST}"
+ cd "${OLDPWD}"
+ fi
+ done
+
+ if [ "${SNAP_COW}" = "${DEF_SNAP_COW}" ]
+ then
+ # Relative to rootfs
+ echo "/"
+ else
+ # Mostly "/home"
+ echo "${SNAP_COW}"
+ fi
+ else
+ cd "${SNAP_COW}"
+ find . -path '*.wh.*' -prune -o -print0 >> "${TMP_FILELIST}"
+ cd "${OLDPWD}"
+ echo "${SNAP_COW}"
+ fi
+}
+
Do_snapshot ()
{
+ TMP_FILELIST=$(mktemp -p "${SAFE_TMPDIR}" "${TMP_FILELIST}.XXXXXX")
+
case "${SNAP_TYPE}" in
squashfs)
- EXCLUDE_LIST="$(mktemp -p ${SAFE_TMPDIR} live-snapshot-exclude-list.XXXXXX)"
- echo "./${EXCLUDE_LIST}" > "${EXCLUDE_LIST}"
+ echo ".${TMP_FILELIST}" > "${TMP_FILELIST}"
+ # Removing whiteheads of unionfs
cd "${SNAP_COW}"
- find . -name '*.wh.*' >> "${EXCLUDE_LIST}"
+ find . -name '*.wh.*' >> "${TMP_FILELIST}"
cd "${OLDPWD}"
- mksquashfs "${SNAP_COW}" "${DEST}" -ef "${EXCLUDE_LIST}"
- rm -f "${EXCLUDE_LIST}"
+ mksquashfs "${SNAP_COW}" "${DEST}" -ef "${TMP_FILELIST}"
;;
cpio)
- ( cd "${SNAP_COW}" && find . -path '*.wh.*' -prune -o -print0 | cpio --quiet -o0 -H newc | gzip -9c > "${DEST}" ) || exit 1
+ WORKING_DIR=$(Do_filelist "${TMP_FILELIST}")
+ cd "${WORKING_DIR}"
+ cat "${TMP_FILELIST}" | cpio --quiet -o0 -H newc | gzip -9c > "${DEST}" || exit 1
+ cd "${OLDPWD}"
;;
ext2|ext3)
@@ -339,6 +382,11 @@ Do_snapshot ()
mkfs.jffs2 --root="${SNAP_COW}" --output="${DEST}"
;;
esac
+
+ if [ -f "${TMP_FILELIST}" ]
+ then
+ rm -f "${TMP_FILELIST}"
+ fi
}
Clean ()