File: get-orig-source

package info (click to toggle)
wpa 2%3A2.7%2Bgit20190128%2B0c1e29f-6%2Bdeb10u3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 20,332 kB
  • sloc: ansic: 352,944; cpp: 5,196; makefile: 3,662; python: 3,142; sh: 1,532; php: 957; xml: 54; perl: 48
file content (106 lines) | stat: -rwxr-xr-x 2,932 bytes parent folder | download
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
#!/bin/sh
set -e

if [ -n "${1}" ]; then
	CURDIR="${1}"
else
	echo "ERROR: not called with \$(CURDIR) parameter" >&2
	exit 1
fi

# parse versions
if [ -n "${2}" ]; then
	VERSION="${2}"
else
	VERSION="$(dpkg-parsechangelog -l${CURDIR}/debian/changelog | sed -ne 's,^Version: *\([0-9]*:\)\?\(.*\)$,\2,p')"
fi

DEB_VER="$(echo ${VERSION} | sed 's,\-[0-9a-z\~\.]*,,')"
UP_VER="$(echo ${DEB_VER} | sed 's,\~,\-,g')"
SNAPDATE="$(echo ${DEB_VER} | sed 's/.*[+~]git\([0-9]*\).*/\1/')"

case "${UP_VER}" in
*[+-]git[0-9\.]*+*)
	UP_VER_TAG="$(echo $UP_VER | sed 's,.*[+-]git[0-9\.]*+,,')"
	;;
*)
	UP_VER_TAG="hostap_$(echo $UP_VER | sed -e 's,\.,_,g' -e 's,\-,_,g')"
	;;
esac

# set upstream (git-) Vcs
UP_VCS="git://w1.fi/srv/git/hostap.git"
if dpkg --compare-versions "${DEB_VER}" lt "2~"; then
	UP_VCS="git://w1.fi/srv/git/hostap-1.git"
fi

# write to ../{,_}tarballs/, if it exists - ../ otherwise
if [ -d "${CURDIR}/../tarballs" ]; then
	ORIG_TARBALL="${CURDIR}/../tarballs/wpa_${DEB_VER}.orig.tar.xz"
elif [ -d "${CURDIR}/../_tarballs" ]; then
	ORIG_TARBALL="${CURDIR}/../_tarballs/wpa_${DEB_VER}.orig.tar.xz"
else
	ORIG_TARBALL="${CURDIR}/../wpa_${DEB_VER}.orig.tar.xz"
fi

# don't overwrite existing tarballs
if [ -e "${ORIG_TARBALL}" ]; then
	echo "ERROR: don't overwrite existing ${ORIG_TARBALL}" >&2
	exit 2
fi

TEMP_SOURCE="$(mktemp -d --tmpdir wpa-orig-source.XXXXXXXXXX)"
if [ "$?" -ne 0 ] || [ -z "${TEMP_SOURCE}" ] || [ ! -d "${TEMP_SOURCE}" ]; then
	echo "ERROR: failed to create temporary working directory" >&2
	exit 3
fi

# clone upstream git repository
echo "clone ${UP_VCS}:"
git clone "${UP_VCS}" "${TEMP_SOURCE}"
if [ "$?" -ne 0 ] || [ ! -d "${TEMP_SOURCE}" ]; then
	echo "ERROR: cloning ${UP_VCS} failed" >&2
	rm -rf "${TEMP_SOURCE}"
	exit 4
fi

# add CONTRIBUTIONS for wpa 2.2~
# (it's available since 2.0~, but only gets included in 2.2~)
if dpkg --compare-versions "${DEB_VER}" ge "2.2~"; then
	CONTRIBUTIONS="CONTRIBUTIONS"
fi

# add Hotspot 2.0 OSU server for wpa 2.2~
if dpkg --compare-versions "${DEB_VER}" ge "2.2~"; then
	HS20="hs20"
elif dpkg --compare-versions "${DEB_VER}" ge "2.1+" && [ "${SNAPDATE}" -ge "20140526" ]; then
	HS20="hs20"
fi

# add drop patches/ for wpa 2.6~, it's no longer available.
if dpkg --compare-versions "${DEB_VER}" ge "2.6~"; then
	PATCHES=""
elif dpkg --compare-versions "${DEB_VER}" ge "2.5+" && [ "${SNAPDATE}" -ge "20160108" ]; then
	PATCHES=""
else
	PATCHES="patches"
fi

# create new upstream tarball
cd "${TEMP_SOURCE}" && \
	git archive \
		--format=tar \
		--prefix="wpa-${UP_VER}/" \
		"${UP_VER_TAG}" \
			README COPYING $CONTRIBUTIONS $PATCHES src wpa_supplicant hostapd $HS20 | \
				xz -c6 > "${ORIG_TARBALL}"
if [ "$?" -ne 0 ] || [ ! -e "${ORIG_TARBALL}" ]; then
	echo "ERROR: failure to create ${ORIG_TARBALL}" >&2
	rm -rf "${TEMP_SOURCE}"
	exit 5
else
	echo "SUCCESS: New upstream tarball has been saved at ${ORIG_TARBALL}"
	rm -rf "${TEMP_SOURCE}"
	exit 0
fi