[SCM] debian-live branch, master, updated. 1.130.1-3-38-g256a921

Daniel Baumann daniel at debian.org
Mon Jun 16 13:59:04 UTC 2008


The following commit has been merged in the master branch:
commit 7cfbc2ac160156a26783d9a9bd1430c08d5478c9
Author: Marco Amadori <marco.amadori at gmail.com>
Date:   Fri Jun 6 23:44:09 2008 +0200

    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.
    
    Signed-off-by: Marco Amadori <marco.amadori at gmail.com>

diff --git a/Makefile b/Makefile
index 30af16d..ed1af45 100644
--- a/Makefile
+++ b/Makefile
@@ -40,7 +40,7 @@ install: test build
 	cp -r COPYING docs/* $(DESTDIR)/usr/share/doc/live-initramfs
 
 	mkdir -p $(DESTDIR)/usr/share/doc/live-initramfs/examples
-	cp -r conf/live.conf $(DESTDIR)/usr/share/doc/live-initramfs/examples
+	cp -r conf/* $(DESTDIR)/usr/share/doc/live-initramfs/examples
 
 	# Installing manpages
 	set -e; for MANPAGE in manpages/*.en.1; \
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 ()
diff --git a/conf/live-snapshot.list b/conf/live-snapshot.list
new file mode 100644
index 0000000..30fe29d
--- /dev/null
+++ b/conf/live-snapshot.list
@@ -0,0 +1,18 @@
+# /etc/live-snapshot resync list example
+#
+# If this file is present, each uncommented not empty line will be parsed when
+# running live-snapshot and included in target snapshot.
+#
+# The syntax for the line is just a full file or directory pathname.
+# Those files and directories, and only those will be included on automatic persistence handling.
+
+# Include itself for reuse
+/etc/live-snapshot.list
+
+# Include networking setups
+/etc/network/interfaces
+/etc/resolv.conf
+/etc/hosts
+
+# Include the whole Desktop directory of the default user
+/home/user/Desktop
diff --git a/manpages/live-snapshot.en.1.txt b/manpages/live-snapshot.en.1.txt
index fdca25b..f57413d 100644
--- a/manpages/live-snapshot.en.1.txt
+++ b/manpages/live-snapshot.en.1.txt
@@ -77,6 +77,14 @@ show usage and exit
 
 output version information and exit
 
+Files
+-----
+
+  /etc/live-snapshot.list
+
+This optional file, if present changes the behaviour of live-snapshot, only files and directories listed there are included (integrally) in the snapshot.
+Beware, it is an experimental feature that only works for cpio targets now.
+
 See also
 --------
 
diff --git a/manpages/live-snapshot.it.1.txt b/manpages/live-snapshot.it.1.txt
index 3892bed..fd1ac04 100644
--- a/manpages/live-snapshot.it.1.txt
+++ b/manpages/live-snapshot.it.1.txt
@@ -83,6 +83,15 @@ mostra l'utilizzo ed esce
 
 da informazioni sulla versione ed esce
 
+Files
+-----
+
+  /etc/live-snapshot.list
+
+Facoltativo, se presente cambia completamente il funzionamento di live-snapshot; solo i files e le directory elencate verranno effettivamente inclusi nello snapshot.
+Attenzione, e` una funzionalita` sperimentale che funziona attualmente solo con gli snapshot di tipo "cpio".
+
+
 See also
 --------
 
diff --git a/scripts/live b/scripts/live
index ee363c3..e211263 100755
--- a/scripts/live
+++ b/scripts/live
@@ -875,7 +875,7 @@ try_snap ()
 			fi
 		else
 			# cpio.gz snapshot
-			if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio -i -u -d 2>/dev/null)
+			if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1)
 			then
 				log_warning_msg "Impossible to include the ${snapfile} Snapshot"
 				return 1

-- 
debian-live



More information about the debian-live-changes mailing list