blob: abd27a99382453094c379c628e23e2a5f69b9ca8 (
plain)
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
|
#!/bin/sh
#
# unpack-debian-sources - unpack all Debian packages in a Debian
# repository
#
# Usage: unpack-debian-sources MIRROR SUITE [SECTION]...
#
# where MIRROR is the URL to a Debian mirror site, SUITE is the release,
# and SECTION is a section within the release. For example:
#
# unpacke-debian-sources http://ftp.debian.org/debian etch main contrib
#
# If SECTION is missing, it defaults to "main contrib non-free"
set -e
die()
{
echo "$@" 1>&2
exit 1
}
fetch()
{
wget -q -O - "$1"
}
parse_sources()
{
awk '
/^Directory:/ {
if (dir && paths) print dir, paths
dir = $2
paths = ""
}
/^Files:/ { infiles = 1; next }
infiles && /^ / { paths = paths " " $NF }
infiles && (NF == 0 || /^[^ ]/) { infiles = 0 }
'
}
showiferror()
{
local temp="$(mktemp)"
if ! "$@" > "$temp" 2>&1
then
cat "$temp"
rm -f "$temp"
exit 1
fi
rm -f "$temp"
}
unpack_dsc()
{
(
cd "$1"
dsc="$(ls *.dsc)"
showiferror dpkg-source -x *.dsc
)
}
[ "$2" = "" ] && die "Usage: $0 MIRROR SUITE [SECTION]..."
mirror="$1"
suite="$2"
shift 2
sections="$@"
gpghome="$(mktemp -d)"
export GNUPGHOME="$gpghome"
for section in $sections
do
sources="$mirror/dists/$suite/$section/source/Sources.bz2"
sources_tmp="$(mktemp)"
fetch "$sources" | bunzip2 > "$sources_tmp"
num_packages=$(parse_sources < "$sources_tmp" | wc -l)
n=0
parse_sources < "$sources_tmp" |
while read dir paths
do
n=$(expr $n + 1)
if [ ! -d "$dir" ]
then
printf "$n/$num_packages: $dir\n"
temp="$(mktemp -d)"
for path in $paths
do
fetch "$mirror/$dir/$path" > "$temp/$path"
done
unpack_dsc "$temp"
for path in $paths
do
rm "$temp/$path"
done
mkdir -p "$dir" # Create parent dirs
rmdir "$dir" # Remove tail dir
mv "$temp"/* "$dir" # Move the _single_ dir, which has the src
fi
done
done
|