Skip to content

Commit 851aa5e

Browse files
committed
Add distfile source type to sources files
1 parent 1452a8f commit 851aa5e

File tree

123 files changed

+438
-437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+438
-437
lines changed

download-distfiles.sh

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,7 @@
77
# Optional arguments: Mirrors
88

99
download_source() {
10-
local distfiles=${1}
11-
local url=${2}
12-
shift 2
13-
case $url in
14-
'git://'*)
15-
url=${1}
16-
shift
17-
;;
18-
esac
19-
local checksum=${1}
20-
local fname=${2}
21-
# Default to basename of url if not given
22-
fname=${fname:-$(basename "${url}")}
10+
local distfiles=${1} url=${2} fname=${4}
2311
if [ "${fname}" = "_" ]; then
2412
echo "ERROR: ${url} must have a filename specified"
2513
exit 1
@@ -36,25 +24,37 @@ download_source() {
3624
}
3725

3826
check_source() {
27+
local distfiles=${1} checksum=${3} fname=${4}
28+
local dest_path=${distfiles}/${fname}
29+
echo "${checksum} ${dest_path}" | sha256sum -c
30+
}
31+
32+
do_action() {
33+
local action=${1}
34+
shift
3935
local distfiles=${1}
40-
local url=${2}
41-
shift 2
42-
case $url in
43-
'git://'*)
36+
shift
37+
local type=${1}
38+
shift
39+
local url=${1}
40+
shift
41+
case $type in
42+
"g" | "git")
4443
url=${1}
4544
shift
4645
;;
4746
esac
4847
local checksum=${1}
49-
local fname=${2}
48+
shift
49+
local fname=${1}
50+
5051
# Default to basename of url if not given
5152
fname=${fname:-$(basename "${url}")}
5253

53-
local dest_path=${distfiles}/${fname}
54-
echo "${checksum} ${dest_path}" | sha256sum -c
54+
$action "${distfiles}" "${url}" "${checksum}" "${fname}"
5555
}
5656

57-
walk_manifest_sources () {
57+
walk_manifest_sources() {
5858
local action=$1
5959
local manifest_entry=
6060
local entry=
@@ -68,7 +68,7 @@ walk_manifest_sources () {
6868
while read -r line; do
6969
# This is intentional - we want to split out ${line} into separate arguments.
7070
# shellcheck disable=SC2086
71-
$action distfiles ${line}
71+
do_action $action distfiles ${line}
7272
done < "./steps/${entry}/sources"
7373
;;
7474
esac

lib/generator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,16 +366,16 @@ def get_source_manifest(cls, pre_network=False):
366366
for source in sources.readlines():
367367
source = source.strip().split(" ")
368368

369-
if source[0].startswith("git://"):
370-
source = source[1:]
369+
if source[0] == "g" or source[0] == "git":
370+
source[1:] = source[2:]
371371

372-
if len(source) > 2:
373-
file_name = source[2]
372+
if len(source) > 3:
373+
file_name = source[3]
374374
else:
375375
# Automatically determine file name based on URL.
376-
file_name = os.path.basename(source[0])
376+
file_name = os.path.basename(source[1])
377377

378-
entry = (source[1], directory, source[0], file_name)
378+
entry = (source[2], directory, source[1], file_name)
379379
if entry not in entries:
380380
entries.append(entry)
381381

mirror.sh

Lines changed: 112 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -59,127 +59,128 @@ checksum_file() {
5959
}
6060

6161
do_file() {
62+
type=${1}
63+
shift
6264
uri=${1}
65+
shift
6366
echo "${uri}"
6467

65-
if echo "${uri}" | grep -qE "^https?://"; then
66-
# HTTP file
67-
checksum=${2}
68-
filename=${3}
69-
if [ "${filename}" = "" ]; then
70-
filename=$(basename "${uri}")
71-
fi
72-
73-
# Check if the file is already downloaded & the checksum is the same
74-
dest_file=${dest}/${filename}
75-
if [ -e "${dest_file}" ]; then
76-
existing_checksum=$(checksum_file "${dest_file}")
77-
if [ "${checksum}" = "${existing_checksum}" ]; then
78-
# There is nothing we need to do here
79-
return
68+
case $type in
69+
f | file)
70+
# HTTP file
71+
checksum=${1}
72+
shift
73+
filename=${1}
74+
if [ "${filename}" = "" ]; then
75+
filename=$(basename "${uri}")
8076
fi
81-
fi
82-
83-
# Attempt up to 3 times
84-
retries=3
85-
matching=no
86-
while [ "${retries}" -gt 0 ]; do
87-
download_file "${uri}" "${dest}/${filename}"
88-
my_checksum=$(checksum_file "${dest_file}")
89-
if [ "${checksum}" = "${my_checksum}" ]; then
90-
matching="yes"
91-
break
77+
78+
# Check if the file is already downloaded & the checksum is the same
79+
dest_file=${dest}/${filename}
80+
if [ -e "${dest_file}" ]; then
81+
existing_checksum=$(checksum_file "${dest_file}")
82+
if [ "${checksum}" = "${existing_checksum}" ]; then
83+
# There is nothing we need to do here
84+
return
85+
fi
86+
fi
87+
88+
# Attempt up to 3 times
89+
retries=3
90+
matching=no
91+
while [ "${retries}" -gt 0 ]; do
92+
download_file "${uri}" "${dest}/${filename}"
93+
my_checksum=$(checksum_file "${dest_file}")
94+
if [ "${checksum}" = "${my_checksum}" ]; then
95+
matching="yes"
96+
break
97+
fi
98+
retries=$((retries - 1))
99+
if [ "${retries}" -gt 0 ]; then
100+
echo "${uri}: checksum did not match, trying again"
101+
rm "${dest}/${filename}"
102+
fi
103+
sleep 1
104+
done
105+
106+
if [ "${matching}" = "no" ]; then
107+
echo "${uri}: checksums do not match"
108+
exit 1
109+
fi
110+
;;
111+
g | git)
112+
# Creating a tarball from a git repository
113+
repo=${uri%~*}
114+
outdir=${state}/git/${repo#*://}
115+
reference=${uri##*~}
116+
117+
http_src=${1}
118+
shift
119+
checksum=${1}
120+
shift
121+
tarball=${1:-$(basename "${http_src}")}
122+
if [ "${tarball}" = "_" ]; then
123+
echo "${uri}: ERROR! Must have tarball name if no http source."
124+
exit 1
92125
fi
93-
retries=$((retries - 1))
94-
if [ "${retries}" -gt 0 ]; then
95-
echo "${uri}: checksum did not match, trying again"
96-
rm "${dest}/${filename}"
126+
tarball=${dest}/${tarball}
127+
128+
# Check if tarball already generated + matches checksum
129+
if [ -e "${tarball}" ]; then
130+
existing_checksum=$(checksum_file "${tarball}")
131+
if [ "${existing_checksum}" = "${checksum}" ]; then
132+
return
133+
fi
134+
rm "${tarball}"
97135
fi
98-
sleep 1
99-
done
100-
101-
if [ "${matching}" = "no" ]; then
102-
echo "${uri}: checksums do not match"
103-
exit 1
104-
fi
105-
elif echo "${uri}" | grep -qE "^git://"; then
106-
# Creating a tarball from a git repository
107-
108-
# Very unfortunately, different sites have different rules.
109-
uri_path=${uri#git://}
110-
# GitHub does not have git:// protocol support
111-
if echo "${uri}" | grep -Eq "^git://github.com"; then
112-
uri=https://${uri_path}
113-
fi
114-
repo=${uri%~*}
115-
outdir=${state}/git/${repo#*://}
116-
reference=${uri##*~}
117-
118-
http_src=${2}
119-
checksum=${3}
120-
tarball=${4:-$(basename "${http_src}")}
121-
if [ "${tarball}" = "_" ]; then
122-
echo "${uri}: ERROR! Must have tarball name if no http source."
123-
exit 1
124-
fi
125-
tarball=${dest}/${tarball}
126-
127-
# Check if tarball already generated + matches checksum
128-
checksum=${3}
129-
if [ -e "${tarball}" ]; then
130-
existing_checksum=$(checksum_file "${tarball}")
131-
if [ "${existing_checksum}" = "${checksum}" ]; then
132-
return
136+
137+
# Clone the repository, or update it if needed
138+
if [ ! -e "${outdir}" ]; then
139+
mkdir -p "$(dirname "${outdir}")"
140+
git clone "${repo}" "${outdir}"
141+
elif ! git_ref_exists "${outdir}" "${reference}" ; then
142+
(
143+
cd "${outdir}" || exit
144+
git pull
145+
git submodule update --init --recursive
146+
)
147+
fi
148+
149+
# Sanity check: the reference we want exists
150+
if ! git_ref_exists "${outdir}" "${reference}"; then
151+
echo "${reference} not found in ${repo} (${outdir})"
152+
exit 1
133153
fi
134-
rm "${tarball}"
135-
fi
136-
137-
# Clone the repository, or update it if needed
138-
if [ ! -e "${outdir}" ]; then
139-
mkdir -p "$(dirname "${outdir}")"
140-
git clone "${repo}" "${outdir}"
141-
elif ! git_ref_exists "${outdir}" "${reference}" ; then
154+
155+
# Generate the prefix for the tarball
156+
prefix_ref=${reference}
157+
# All git repositories we already use remove "v"s from the beginning
158+
# of branch/tag names in the tarball prefix
159+
if echo "${reference}" | grep -Eq "^v[0-9]"; then
160+
prefix_ref=$(echo "${reference}" | sed "s/^v//")
161+
fi
162+
prefix=$(basename "${repo}" | sed "s/.git$//")-${prefix_ref}
163+
142164
(
143165
cd "${outdir}" || exit
144-
git pull
145-
git submodule update --init --recursive
166+
# Some versions of git by default use the internal gzip
167+
# implementation, others use external gzip; standardize this
168+
# -n is used for older versions of git that record gzip creation
169+
# date/time
170+
git config tar.tar.gz.command "gzip -n"
171+
# -T1 avoids non-determinism due to threading
172+
# This may not be correct for forges other than Savannah
173+
git config tar.tar.xz.command "xz -T1"
174+
git archive "${reference}" -o "${tarball}" --prefix "${prefix}/"
146175
)
147-
fi
148-
149-
# Sanity check: the reference we want exists
150-
if ! git_ref_exists "${outdir}" "${reference}"; then
151-
echo "${reference} not found in ${repo} (${outdir})"
152-
exit 1
153-
fi
154-
155-
# Generate the prefix for the tarball
156-
prefix_ref=${reference}
157-
# All git repositories we already use remove "v"s from the beginning
158-
# of branch/tag names in the tarball prefix
159-
if echo "${reference}" | grep -Eq "^v[0-9]"; then
160-
prefix_ref=$(echo "${reference}" | sed "s/^v//")
161-
fi
162-
prefix=$(basename "${repo}" | sed "s/.git$//")-${prefix_ref}
163-
164-
(
165-
cd "${outdir}" || exit
166-
# Some versions of git by default use the internal gzip
167-
# implementation, others use external gzip; standardize this
168-
# -n is used for older versions of git that record gzip creation
169-
# date/time
170-
git config tar.tar.gz.command "gzip -n"
171-
# -T1 avoids non-determinism due to threading
172-
# This may not be correct for forges other than Savannah
173-
git config tar.tar.xz.command "xz -T1"
174-
git archive "${reference}" -o "${tarball}" --prefix "${prefix}/"
175-
)
176-
177-
my_checksum=$(sha256sum "${tarball}" | cut -d' ' -f1)
178-
if [ "${my_checksum}" != "${checksum}" ]; then
179-
echo "${uri}: generated tarball does not match checksum"
180-
exit 1
181-
fi
182-
fi
176+
177+
my_checksum=$(sha256sum "${tarball}" | cut -d' ' -f1)
178+
if [ "${my_checksum}" != "${checksum}" ]; then
179+
echo "${uri}: generated tarball does not match checksum"
180+
exit 1
181+
fi
182+
;;
183+
esac
183184
}
184185

185186
for src in steps/*/sources; do

steps/autoconf-2.52/sources

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://mirrors.kernel.org/gnu/autoconf/autoconf-2.52.tar.bz2 4681bcbb9c9298c506f6405a7deb62c54fc3b339d3239a8f36a5df83daaec94f
1+
f https://mirrors.kernel.org/gnu/autoconf/autoconf-2.52.tar.bz2 4681bcbb9c9298c506f6405a7deb62c54fc3b339d3239a8f36a5df83daaec94f

steps/autoconf-2.53/sources

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://mirrors.kernel.org/gnu/autoconf/autoconf-2.53.tar.bz2 6b217a064c6d06603d50a3ad05129aef9435367810c10894210b8dad965d2306
1+
f https://mirrors.kernel.org/gnu/autoconf/autoconf-2.53.tar.bz2 6b217a064c6d06603d50a3ad05129aef9435367810c10894210b8dad965d2306

steps/autoconf-2.54/sources

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://mirrors.kernel.org/gnu/autoconf/autoconf-2.54.tar.bz2 a74aea954f36c7beeb6cc47b96a408c3e04e7ad635f614e65250dbcd8ec0bd28
1+
f https://mirrors.kernel.org/gnu/autoconf/autoconf-2.54.tar.bz2 a74aea954f36c7beeb6cc47b96a408c3e04e7ad635f614e65250dbcd8ec0bd28

steps/autoconf-2.55/sources

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://mirrors.kernel.org/gnu/autoconf/autoconf-2.55.tar.bz2 f757158a04889b265203eecd8ca92568e2a67c3b9062fa6bff7a0a6efd2244ac
1+
f https://mirrors.kernel.org/gnu/autoconf/autoconf-2.55.tar.bz2 f757158a04889b265203eecd8ca92568e2a67c3b9062fa6bff7a0a6efd2244ac

steps/autoconf-2.57/sources

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://mirrors.kernel.org/gnu/autoconf/autoconf-2.57.tar.bz2 e1035aa2c21fae2a934d1ab56c774ce9d22717881dab8a1a5b16d294fb793489
1+
f https://mirrors.kernel.org/gnu/autoconf/autoconf-2.57.tar.bz2 e1035aa2c21fae2a934d1ab56c774ce9d22717881dab8a1a5b16d294fb793489

steps/autoconf-2.59/sources

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://mirrors.kernel.org/gnu/autoconf/autoconf-2.59.tar.bz2 f0cde70a8f135098a6a3e85869f2e1cc3f141beea766fa3d6636e086cd8b90a7
1+
f https://mirrors.kernel.org/gnu/autoconf/autoconf-2.59.tar.bz2 f0cde70a8f135098a6a3e85869f2e1cc3f141beea766fa3d6636e086cd8b90a7

steps/autoconf-2.61/sources

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://mirrors.kernel.org/gnu/autoconf/autoconf-2.61.tar.bz2 93a2ceab963618b021db153f0c881a2de82455c1dc7422be436fcd5c554085a1
1+
f https://mirrors.kernel.org/gnu/autoconf/autoconf-2.61.tar.bz2 93a2ceab963618b021db153f0c881a2de82455c1dc7422be436fcd5c554085a1

0 commit comments

Comments
 (0)