disk="/dev/$(lsblk -ndo pkname $(findmnt -n -o SOURCE /))"
if [ ! -b "${disk}" ]; then
- swulog "Error: disk \"${disk}\" not found"
- return 1
+ log_err "Error: disk \"${disk}\" not found"
fi
update_dev="${disk}${next_part}"
if [ ! -b "${update_dev}" ]; then
- swulog "Error: destination partition \"${update_dev}\" not found"
- return 1
+ log_err "Error: destination partition \"${update_dev}\" not found"
fi
echo "${update_dev}"
# Create temporary mount point:
mnt_point=$(mktemp -q -d /tmp/swupdate-mount.XXXXXX)
if [ ${?} -ne 0 ]; then
- swulog "Error: cannot create temporary file"
- exit 1
+ log_err "Error: cannot create temporary file"
fi
# Mount update partition:
do_preinst()
{
update_dev=$(get_destination_partition_device)
- swulog "Reformat destination partition: ${update_dev}"
+ log_info "Reformat destination partition: ${update_dev}"
label="$(blkid -s LABEL -o value ${update_dev})"
mount_destination_partition
# Perform migration of selected files/folders...
- swulog "migrating existing data..."
+ log_info "migrating existing data..."
# Migrate files:
for f in ${SWU_PRESERVE_FILES}; do
if [ ! -f ${f} ]; then
- swulog "warning: missing source file: ${f} (skipping)"
+ log_warn "warning: missing source file: ${f} (skipping)"
continue
fi
# The destination folder need to be created in your new SWU archive
# with the proper ownership and permissions (can be empty)
if [ ! -d ${dst_folder} ]; then
- swulog "warning: missing destination folder for file: ${f} (skipping)"
+ log_warn "warning: missing destination folder for file: ${f} (skipping)"
continue
fi
# Migrate folders:
for d in ${SWU_PRESERVE_FOLDERS}; do
if [ ! -d ${d} ]; then
- swulog "warning: missing source folder: ${d} (skipping)"
+ log_warn "warning: missing source folder: ${d} (skipping)"
continue
fi
do_postinst
;;
*)
- swulog "unsupported install mode: \"${1}\""
- exit 1
+ log_err "unsupported install mode: \"${1}\""
;;
esac
trap 'catch $?' EXIT
+# Arg1: log message/string
+log_info() {
+ printf "$(basename ${0}): ${*}\n"
+}
+
+log_warn() {
+ printf >&2 "$(basename ${0}): ${*}\n"
+}
+
+log_err() {
+ printf >&2 "$(basename ${0}): ${*}\n"
+ exit 1
+}
+
catch()
{
if [ "$1" != "0" ]; then
fi
}
-# Arg1: log message/string
-swulog()
-{
- echo "$(basename ${0}): ${1}"
-}
-
FSTYPE="ext4"
-swulog "arguments = \"${*}\""
+log_info "arguments = \"${*}\""
if [ $# -lt 2 ]; then
exit 1;