summaryrefslogtreecommitdiff
path: root/util/meson_aux/skeletonmm-tarball.sh
diff options
context:
space:
mode:
Diffstat (limited to 'util/meson_aux/skeletonmm-tarball.sh')
-rwxr-xr-xutil/meson_aux/skeletonmm-tarball.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/util/meson_aux/skeletonmm-tarball.sh b/util/meson_aux/skeletonmm-tarball.sh
new file mode 100755
index 0000000..c36f126
--- /dev/null
+++ b/util/meson_aux/skeletonmm-tarball.sh
@@ -0,0 +1,25 @@
+#!/bin/bash -e
+
+# External command, intended to be called with custom_target() in meson.build
+
+# skeletonmm-tarball.sh <source_dir> <output_file> <input_files...>
+
+source_dir="$1"
+output_file="$2"
+shift; shift
+
+# These options don't contain filenames, and thus no spaces that
+# must be preserved in the call to tar.
+tar_options="--create --dereference --old-archive --file=-"
+
+case "$output_file" in
+ *.xz)
+ ( cd "$source_dir"; tar $tar_options "$@" ) | xz --to-stdout --extreme >"$output_file"
+ ;;
+ *.gz)
+ ( cd "$source_dir"; tar $tar_options "$@" ) | gzip --to-stdout --best --no-name >"$output_file"
+ ;;
+ *) echo "Error: Unknown filetype, $output_file"
+ exit 1
+ ;;
+esac