diff --git a/misc/repack.sh b/misc/repack.sh index 7a8f9a6..c77d741 100755 --- a/misc/repack.sh +++ b/misc/repack.sh @@ -3,32 +3,42 @@ APP_VERSION="${1:-$(git describe --tags --always)}" -for exe in prepare/*/um-*.exe; do - name="$(basename "$exe" .exe)-$APP_VERSION" - new_exe="$(dirname "$exe")/um.exe" - mv "$exe" "$new_exe" +pack() { + local is_windows=0 + local suffix="" + if [[ "$1" == *.exe ]]; then + suffix=".exe" + is_windows=1 + fi - echo "archiving ${new_exe}..." - zip -Xqj9 "dist/${name}.zip" "$new_exe" - rm -f "$new_exe" -done + local exe_dir="$(dirname "$1")" + local archive_name="$(basename "$1" ".exe")-${APP_VERSION}${suffix}" + local exe_name="um${suffix}" -for exe in prepare/*/um-*; do - name="$(basename "$exe")-$APP_VERSION" - new_exe="$(dirname "$exe")/um" - mv "$exe" "$new_exe" + echo "archiving ${exe_name}..." - echo "archiving ${new_exe}..." - tar \ - --sort=name --format=posix \ - --pax-option=exthdr.name=%d/PaxHeaders/%f \ - --pax-option=delete=atime,delete=ctime \ - --clamp-mtime --mtime='1970-01-01T00:00:00Z' \ - --numeric-owner --owner=0 --group=0 \ - --mode=0755 \ - -c -C "$(dirname "$exe")" um | - gzip -9 >"dist/${name}.tar.gz" - rm -f "$exe" + # Prepare metadata + cp README.md LICENSE "$exe_dir" + mv "$1" "${exe_dir}/${exe_name}" + + if [[ "$is_windows" == 1 ]]; then + zip -Xqj9 "dist/${archive_name}.zip" "${exe_name}" README.md LICENSE + else + tar \ + --sort=name --format=posix \ + --pax-option=exthdr.name=%d/PaxHeaders/%f \ + --pax-option=delete=atime,delete=ctime \ + --clamp-mtime --mtime='1970-01-01T00:00:00Z' \ + --numeric-owner --owner=0 --group=0 \ + --mode=0755 \ + -c -C "$exe_dir" "${exe_name}" README.md LICENSE | + gzip -9 >"dist/${archive_name}.tar.gz" + fi + rm -rf "$exe_dir" +} + +for exe in prepare/*/um*; do + pack "$exe" done pushd dist