forked from curl/curl-for-win
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_pkg.sh
executable file
·119 lines (98 loc) · 3.19 KB
/
_pkg.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/sh
# Copyright (C) Viktor Szakats. See LICENSE.md
# SPDX-License-Identifier: MIT
# shellcheck disable=SC3040
set -o xtrace -o errexit -o nounset; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o pipefail
cd "$(dirname "$0")"
if [ "${_OS}" = 'mac' ]; then
tar() { gtar "$@"; }
fi
_cdo="$(pwd)"
if [ "${_NAM}" != "${_UNIPKG}" ]; then
find "${_DST}" -depth -type d -exec touch -c -r "$1" '{}' +
chmod -R a+rw-s,go-w "${_DST}"
# NOTE: Not effective on MSYS2:
find "${_DST}" -name '*.a' -exec chmod a-x '{}' +
find "${_DST}" \( -name '*.exe' -o -name '*.dll' \) -exec chmod a+x '{}' +
# First, merge this package into the unified package
unipkg="${_UNIPKG}"
{
[ -d "${_DST}/bin" ] && rsync --archive --update "${_DST}/bin" "${unipkg}"
[ -d "${_DST}/include" ] && rsync --archive --update "${_DST}/include" "${unipkg}"
if [ "${_NAM}" = 'libssh2' ]; then
mkdir -p "${unipkg}/dep/${_NAM}"
rsync --archive --update "${_DST}/docs" "${unipkg}/dep/${_NAM}"
fi
[ -d "${_DST}/lib" ] && rsync --archive --update "${_DST}/lib" "${unipkg}"
if [ "${_NAM}" = 'curl' ]; then
cp -f -p "${_DST}"/*.* "${unipkg}"
rsync --archive --update "${_DST}/docs" "${unipkg}"
else
_NAM_DEP="${unipkg}/dep/${_NAM}"
mkdir -p "${_NAM_DEP}"
cp -f -p "${_DST}"/*.* "${_NAM_DEP}"
fi
}
fi
create_pkg() {
arch_ext="$2"
if [ "${_NAM}" != "${_UNIPKG}" ]; then
_suf="${_FLAV}"
else
_suf='' # _FLAV already added, do not add it a second time
fi
# Alter filename for non-release packages
if [ "${_BRANCH#*main*}" != "${_BRANCH}" ]; then
if [ "${PUBLISH_PROD_FROM}" != "${_OS}" ]; then
_suf="${_suf}-built-on-${_OS}"
fi
else
_suf="${_suf}-test-built-on-${_OS}"
fi
_pkg="${_OUT}${_suf}${arch_ext}"
_FLS="$(dirname "$0")/_files"
(
cd "${_DST}/.."
case "${_OS}" in
win) find "${_BAS}" -exec attrib +A -R '{}' \;
esac
find "${_BAS}" -type f | sort > "${_FLS}"
rm -f "${_cdo}/${_pkg}"
case "${arch_ext}" in
.tar.xz) TZ=UTC tar --create \
--format=ustar \
--owner=0 --group=0 --numeric-owner \
--files-from "${_FLS}" | xz > "${_cdo}/${_pkg}";;
.zip) TZ=UTC zip --quiet -9 --strip-extra \
--names-stdin - < "${_FLS}" > "${_cdo}/${_pkg}";;
esac
touch -c -r "$1" "${_cdo}/${_pkg}"
)
rm -f "${_FLS}"
# <filename>: <size> bytes <YYYY-MM-DD> <HH:MM>
case "${_OS}" in
bsd|mac) TZ=UTC stat -f '%N: %z bytes %Sm' -t '%Y-%m-%d %H:%M' "${_pkg}";;
*) TZ=UTC stat --format='%n: %s bytes %y' "${_pkg}";;
esac
openssl dgst -sha256 "${_pkg}" | sed 's/^SHA256/SHA2-256/g' | tee -a hashes.txt
# Sign releases only
if [ -z "${_suf}" ]; then
./_sign-pkg.sh "${_pkg}"
fi
}
if [ "${_NAM}" != "${_UNIPKG}" ]; then
ver="${_VER}"
url=''
[ "${#ver}" -ge 32 ] && ver="$(printf '%.8s' "${ver}")"
namver="${_NAM} ${ver}"
[ -f "${_NAM}/__url__.txt" ] && url=" $(cat "${_NAM}/__url__.txt")"
echo "${namver}${url}" >> "${_UNIMFT}"
echo "${namver}${url}" >> "${_URLS}"
if ! grep -q -a -F "${namver}" -- "${_BLD}"; then
echo "${namver}" >> "${_BLD}"
fi
else
create_pkg "$1" '.tar.xz'
create_pkg "$1" '.zip'
fi
rm -r -f "${_DST:?}"