forked from curl/curl-for-win
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
_pack.sh
executable file
·76 lines (59 loc) · 1.76 KB
/
_pack.sh
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh -x
# Copyright 2014-2019 Viktor Szakats <https://vsz.me/>
# See LICENSE.md
cd "$(dirname "$0")" || exit
# Detect host OS
case "$(uname)" in
*_NT*) os='win';;
Linux*) os='linux';;
Darwin*) os='mac';;
*BSD) os='bsd';;
esac
# Map tar to GNU tar, if it exists (e.g. on macOS)
command -v gtar >/dev/null && alias tar=gtar
_cdo="$(pwd)"
_fn="${_DST}/BUILD-README.txt"
cat << EOF > "${_fn}"
Visit the project page for details about these builds and the list of changes:
${_URL}
EOF
unix2dos -k "${_fn}"
touch -c -r "$1" "${_fn}"
_fn="${_DST}/BUILD-HOMEPAGE.url"
cat << EOF > "${_fn}"
[InternetShortcut]
URL=${_URL}
EOF
unix2dos -k "${_fn}"
touch -c -r "$1" "${_fn}"
find "${_DST}" -depth -type d -exec touch -c -r "$1" '{}' \;
# NOTE: This isn't effective on MSYS2
find "${_DST}" \( -name '*.exe' -or -name '*.dll' -or -name '*.a' \) -exec chmod a-x {} +
create_pack() {
arch_ext="$2"
_LST="$(dirname "$0")/_files"
(
cd "${_DST}/.." || exit
case "${os}" in
win) find "${_BAS}" -exec attrib +A -R {} \;
esac
find "${_BAS}" -type f | sort > "${_LST}"
rm -f "${_cdo}/${_BAS}${arch_ext}"
case "${arch_ext}" in
.tar.xz) tar -c -T "${_LST}" \
--owner=0 --group=0 --numeric-owner --mode=go=rX,u+rw,a-s \
| xz > "${_cdo}/${_BAS}${arch_ext}";;
.zip) zip -q -9 -X -@ - < "${_LST}" > "${_cdo}/${_BAS}${arch_ext}";;
# Requires: p7zip (MSYS2, Homebrew, Linux rpm), p7zip-full (Linux deb)
.7z) 7z a -bd -r -mx "${_cdo}/${_BAS}${arch_ext}" "@${_LST}" >/dev/null;;
esac
touch -c -r "$1" "${_cdo}/${_BAS}${arch_ext}"
)
}
create_pack "$1" '.tar.xz'
create_pack "$1" '.zip'
ver="${_NAM} ${_VER}"
if ! grep -q -F "${ver}" "${_BLD}"; then
echo "${ver}" >> "${_BLD}"
fi
rm -f -r "${_DST:?}"