/usr/bin/uec2roottar is in maas-cluster-controller 1.5.4+bzr2294-0ubuntu1.2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #!/bin/sh
TEMP_D=""
MP=""
Usage() {
cat <<EOF
Usage: ${0##*/} uec-tarball [output]
Supports converting from uec tarball or raw unpartitioned disk image.
EOF
}
error() { echo "$(date -R):" "$@" 1>&2; }
fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
cleanup() {
[ -z "$MP" ] || umount "$MP"
[ -z "$TEMP_D" -o ! -d "$TEMP_D" ] || rm -Rf "${TEMP_D}";
}
[ "$1" = "-h" -o "$1" = "--help" ] && { Usage; exit 0; }
[ $# -eq 1 -o $# -eq 2 ] || { Usage 1>&2; exit 1; }
[ -f "$1" ] || { Usage 1>&2; error "$1: not a file"; exit 1; }
[ "$(id -u)" = "0" ] || fail "must be root"
TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX") || fail "failed mktemp"
trap cleanup EXIT
uec="$1"
output=${2}
if $(LANG=C file "$uec" | grep -qi "filesystem data"); then
[ -n "$output" ] || output="${uec%.img}-root.tar.gz";
img="$uec"
else
[ -n "$output" ] || output="${uec%.tar.gz}-root.tar.gz";
error "extracting *.img from ${uec}"
tar -C ${TEMP_D} --wildcards "*.img" -Sxvzf "$uec" ||
fail "failed extract $uec"
img=""
for cand in "${TEMP_D}/"*.img; do
[ -z "$img" ] || fail "multiple .img files in $uec"
[ -f "$cand" ] && img="$cand"
done
[ -n "$img" ] || fail "failed to find image in $uec"
fi
error "converting ${img} to ${output}"
mkdir "${TEMP_D}/mp" && mount -o ro "$img" "${TEMP_D}/mp" &&
MP="$TEMP_D/mp" || fail "failed to mount $img"
error "copying contents of ${img#${TEMP_D}/} in ${uec} to ${output}"
tar -C "$MP" -cpSzf "${output}" --numeric-owner . ||
fail "failed to create ${output}"
error "finished. wrote to ${output}"
exit 0
|