|
164
by Jamie Strandboge
copy_sppa_to_repos: |
1 |
#!/bin/bash
|
|
1
by Kees Cook
initial re-check-in |
2 |
#
|
|
247
by Marc Deslauriers
- package-tools/check-source-package: update to new-style maintainer line |
3 |
# Copyright 2007-2011 (C) Jamie Strandboge <jamie@strandboge.com>
|
|
1
by Kees Cook
initial re-check-in |
4 |
# License: GPLv2
|
5 |
#
|
|
6 |
# Requires UCT to be set to ubuntu-cve-tracker
|
|
7 |
#
|
|
8 |
# Usage:
|
|
9 |
# copy_sppa_to_repos foo
|
|
10 |
# copy_sppa_to_repos --arch "i386,amd64,lpia" foo
|
|
11 |
#
|
|
12 |
# Kernel examples:
|
|
|
24
by Kees Cook
update for kernel versions that currently exist |
13 |
# $UST/repo-tools/copy_sppa_to_repos --re 'linux-(headers|image).*-[0-9]+(|-686|(-amd64)?-generic|-common)_' linux-source-2.6.15
|
|
1
by Kees Cook
initial re-check-in |
14 |
# $UST/repo-tools/copy_sppa_to_repos --re 'linux-(headers|image)-2.*-[0-9]+(|-amd64|-686|(-amd64)?-generic|-common)_' linux
|
15 |
#
|
|
16 |
# Kernel ABI-tracked examples:
|
|
|
24
by Kees Cook
update for kernel versions that currently exist |
17 |
# $UST/repo-tools/copy_sppa_to_repos --re 'linux-restricted-modules.*(-686|-generic|-common)' linux-restricted-modules{,-2.6.15,-2.6.24}
|
|
38
by Kees Cook
adjust examples to include karmic |
18 |
# $UST/repo-tools/copy_sppa_to_repos --re 'linux-.*(-686|-generic|-common)' linux-backports-modules-2.6.{15,24,27,28,31}
|
|
24
by Kees Cook
update for kernel versions that currently exist |
19 |
# $UST/repo-tools/copy_sppa_to_repos --re 'linux-(ubuntu|headers).*(-686|-generic|-common)' linux-ubuntu-modules-2.6.24
|
|
1
by Kees Cook
initial re-check-in |
20 |
# $UST/repo-tools/copy_sppa_to_repos linux-meta
|
21 |
#
|
|
22 |
# By default i386 and amd64 binaries are downloaded. Use ARCH to download
|
|
23 |
# others.
|
|
24 |
||
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
25 |
set -e
|
26 |
||
|
1
by Kees Cook
initial re-check-in |
27 |
ustconf="$HOME/.ubuntu-security-tools.conf" |
28 |
if [ -s "$ustconf" ]; then |
|
29 |
. "$ustconf"
|
|
30 |
else
|
|
31 |
echo "Could not find '$ustconf'" >&2 |
|
32 |
exit 1
|
|
33 |
fi
|
|
34 |
||
|
161
by Marc Deslauriers
- copy_sppa_to_repos: add help and debug options |
35 |
help() { |
36 |
cat << EOM
|
|
37 |
Usage: copy_sppa_to_repos [options]
|
|
38 |
||
39 |
Options:
|
|
|
168
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: add --source-changes-dir and clean up some |
40 |
-h, --help Show this help message and exit
|
41 |
--ppa=PERSON[/PPA] Which PPA to use (default is 'ubuntu-security/ppa')
|
|
|
574
by Jamie Strandboge
update repo-tools/copy_sppa_to_repos to use --distribution for supporting |
42 |
--distribution=DIST Which alternative distribution to use (eg,
|
43 |
'ubuntu-rtm')
|
|
|
168
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: add --source-changes-dir and clean up some |
44 |
-a, --arch=ARCH[,ARCH...] Limit to comma-separated list of archs
|
45 |
--re=RE Only include those matching this regular expression
|
|
46 |
--batch Limit number of matches when working around
|
|
47 |
LP #302116
|
|
48 |
--start-index Specify starting count when working around
|
|
49 |
LP #302116
|
|
50 |
--include-devel Include development release
|
|
|
529
by jdstrand
repo-tools/copy_sppa_to_repos: update help message for recent sis-changes |
51 |
--include-debug Include *.udeb, -dbg, -dbgsym, and -locale packages
|
|
636
by Tyler Hicks
copy_sppa_to_repos: add the ability to download from eol releases |
52 |
--include-eol Include end of life releases
|
|
168
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: add --source-changes-dir and clean up some |
53 |
--release=SERIES Limit to a specific set of comma-separate releases
|
54 |
--source-changes-dir=DIR Specify a directory with source.changes files
|
|
|
606
by Steve Beattie
repo-tools/copy_sppa_to_repos: add --source option |
55 |
--source Include package sources
|
|
357
by Steve Beattie
document copy_sppa_to_repos --force-binaries option and make |
56 |
--force-binaries Force binary download over existing packages
|
|
168
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: add --source-changes-dir and clean up some |
57 |
--debug Show debug output
|
|
161
by Marc Deslauriers
- copy_sppa_to_repos: add help and debug options |
58 |
EOM
|
59 |
exit 0
|
|
60 |
}
|
|
61 |
||
|
636
by Tyler Hicks
copy_sppa_to_repos: add the ability to download from eol releases |
62 |
OPTS=`getopt -o a:,h,f,r: --long ppa:,distribution:,arch:,re:,batch:,force-binaries,include-devel,include-debug,include-eol,release:,start-index:,source-changes-dir:,source,help,debug -n "$0" -- "$@"` |
|
1
by Kees Cook
initial re-check-in |
63 |
eval set -- "$OPTS" |
64 |
||
65 |
batch="" |
|
66 |
index="" |
|
67 |
arch="$ARCH" |
|
68 |
ppa="" |
|
|
574
by Jamie Strandboge
update repo-tools/copy_sppa_to_repos to use --distribution for supporting |
69 |
distribution="" |
|
1
by Kees Cook
initial re-check-in |
70 |
re="" |
71 |
include_devel="" |
|
|
284
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: add --include-debug arg |
72 |
include_debug="" |
|
636
by Tyler Hicks
copy_sppa_to_repos: add the ability to download from eol releases |
73 |
include_eol="" |
|
151
by Jamie Strandboge
copy_sppa_to_repos: update to use --release if specified |
74 |
release="" |
|
161
by Marc Deslauriers
- copy_sppa_to_repos: add help and debug options |
75 |
debug="" |
|
165
by Jamie Strandboge
copy_sppa_to_repos: |
76 |
force_binaries="" |
|
168
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: add --source-changes-dir and clean up some |
77 |
source_changes_dir="" |
|
606
by Steve Beattie
repo-tools/copy_sppa_to_repos: add --source option |
78 |
get_source="" |
|
1
by Kees Cook
initial re-check-in |
79 |
while true ; do |
80 |
case "$1" in |
|
81 |
# workaround for bug #302116
|
|
82 |
--batch) batch="--batch $2"; shift 2 ;; |
|
83 |
--start-index) index="--start-index $2"; shift 2 ;; |
|
|
161
by Marc Deslauriers
- copy_sppa_to_repos: add help and debug options |
84 |
-h|--help) help ;; |
|
165
by Jamie Strandboge
copy_sppa_to_repos: |
85 |
-f|--force-binaries) force_binaries="yes" ; shift 1;; |
|
161
by Marc Deslauriers
- copy_sppa_to_repos: add help and debug options |
86 |
--debug) debug="--debug"; shift 1 ;; |
|
1
by Kees Cook
initial re-check-in |
87 |
-a|--arch) arch="$2"; shift 2 ;; |
88 |
--ppa) ppa="--ppa $2"; shift 2 ;; |
|
|
574
by Jamie Strandboge
update repo-tools/copy_sppa_to_repos to use --distribution for supporting |
89 |
--distribution) distribution="--distribution $2"; shift 2 ;; |
|
1
by Kees Cook
initial re-check-in |
90 |
--re) re="--re $2"; shift 2 ;; |
91 |
--include-devel) include_devel="--include-devel" ; shift 1 ;; |
|
|
284
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: add --include-debug arg |
92 |
--include-debug) include_debug="--include-debug" ; shift 1 ;; |
|
636
by Tyler Hicks
copy_sppa_to_repos: add the ability to download from eol releases |
93 |
--include-eol) include_eol="--include-eol" ; shift 1 ;; |
94 |
-r|--release) release="--release $2"; include_devel="--include-devel"; include_eol="--include-eol"; shift 2;; |
|
|
168
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: add --source-changes-dir and clean up some |
95 |
--source-changes-dir) source_changes_dir="$2"; shift 2 ;; |
|
606
by Steve Beattie
repo-tools/copy_sppa_to_repos: add --source option |
96 |
--source) get_source="true"; shift 1 ;; |
|
1
by Kees Cook
initial re-check-in |
97 |
--) shift ; break ;; |
98 |
*) echo "Unknown option '$1'" ; exit 1 ;; |
|
99 |
esac
|
|
100 |
done
|
|
101 |
pkgs="$@" |
|
102 |
||
103 |
# Set up defaults
|
|
104 |
if [ -z "$arch" ]; then |
|
105 |
arch="i386,amd64" |
|
106 |
fi
|
|
107 |
if [ -z "$pkgs" ]; then |
|
108 |
if [ -z "$SRCPKG" ]; then |
|
109 |
echo "Please export SRCPKG. Eg:" >&2 |
|
110 |
echo 'SRCPKG=$(echo "srcpkg1 srcpkg2...")' >&2 |
|
111 |
exit 1
|
|
112 |
else
|
|
113 |
pkgs="$SRCPKG" |
|
114 |
fi
|
|
115 |
fi
|
|
116 |
||
|
119
by Jamie Strandboge
add a little note on what is being downloaded, and for which archs |
117 |
echo "Downloading: $pkgs ($arch)" |
118 |
||
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
119 |
err="" |
120 |
||
|
168
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: add --source-changes-dir and clean up some |
121 |
tmpdir_changes="" |
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
122 |
echo "Changes:" |
|
168
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: add --source-changes-dir and clean up some |
123 |
if [ -d "$source_changes_dir" ]; then |
124 |
tmpdir_changes="$source_changes_dir" |
|
125 |
echo "Using cached files in '$source_changes_dir':" |
|
126 |
ls -1 "$source_changes_dir"
|
|
127 |
else
|
|
|
311
by Steve Beattie
give the temporary directories in copy_sppa_to_repos more unique names than tmp.XXXXXXXXXX |
128 |
tmpdir_changes=`mktemp -d copy_sppa_to_repo-changes.XXXXXXXXXXXXXX --tmpdir` |
|
636
by Tyler Hicks
copy_sppa_to_repos: add the ability to download from eol releases |
129 |
$UCT/scripts/sis-changes $release $include_devel $include_eol $debug $ppa $distribution $batch $index --action changes --arch $arch --download $tmpdir_changes --force-download $pkgs || { |
|
168
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: add --source-changes-dir and clean up some |
130 |
echo "" |
131 |
echo "Error downloading changes. Leaving '$tmpdir_changes'." |
|
132 |
exit 1
|
|
133 |
}
|
|
134 |
fi
|
|
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
135 |
|
136 |
echo "" |
|
137 |
echo "Binaries:" |
|
|
311
by Steve Beattie
give the temporary directories in copy_sppa_to_repos more unique names than tmp.XXXXXXXXXX |
138 |
tmpdir_binaries=`mktemp -d copy_sppa_to_repo-binaries.XXXXXXXXXXXXXX --tmpdir` |
|
607
by Steve Beattie
repo-tools/copy_sppa_to_repos: use a separate temporary directory for |
139 |
[ -n "${get_source}" ] && tmpdir_sources=`mktemp -d copy_sppa_to_repo-sources.XXXXXXXXXXXXXX --tmpdir` |
|
165
by Jamie Strandboge
copy_sppa_to_repos: |
140 |
bin_pkgs= |
141 |
have_pkgs= |
|
142 |
if [ -n "$force_binaries" ]; then |
|
143 |
bin_pkgs="$pkgs" |
|
144 |
else
|
|
145 |
for p in $pkgs ; do |
|
|
256
by Jamie Strandboge
add repo-tools/ur-update-all |
146 |
for i in `ls -1 $tmpdir_changes/${p}_*_source.changes` ; do |
|
165
by Jamie Strandboge
copy_sppa_to_repos: |
147 |
version=`egrep '^Version: ' $i | cut -d ' ' -f 2 | sed 's/^[0-9]:\(.*\)/\1/g'` |
148 |
dist=`egrep '^Distribution: ' $i | cut -d ' ' -f 2 | cut -d '-' -f 1` |
|
149 |
if ls ${package_tools_repo_base}/${dist}/*${version}*.deb >/dev/null 2>&1 ; then |
|
|
169
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: calculate already downloaded packages correctly. doy |
150 |
echo "$have_pkgs" | grep -q -v " $p/$dist" && { |
|
165
by Jamie Strandboge
copy_sppa_to_repos: |
151 |
echo "Found '$p/$dist'" |
|
169
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: calculate already downloaded packages correctly. doy |
152 |
have_pkgs="$have_pkgs $p/$dist" |
|
165
by Jamie Strandboge
copy_sppa_to_repos: |
153 |
}
|
154 |
else
|
|
|
256
by Jamie Strandboge
add repo-tools/ur-update-all |
155 |
if [ -z "$bin_pkgs" ]; then |
156 |
bin_pkgs="$p " |
|
157 |
else
|
|
158 |
echo "$bin_pkgs" | grep -q -v "$p " && bin_pkgs="$bin_pkgs$p " |
|
159 |
fi
|
|
|
165
by Jamie Strandboge
copy_sppa_to_repos: |
160 |
fi
|
161 |
done
|
|
162 |
done
|
|
163 |
if [ -n "$have_pkgs" ]; then |
|
164 |
if [ -n "$bin_pkgs" ]; then |
|
|
168
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: add --source-changes-dir and clean up some |
165 |
echo "" |
|
165
by Jamie Strandboge
copy_sppa_to_repos: |
166 |
echo "Proceeding to download only (use '--force-binaries' to override):" |
167 |
echo "$bin_pkgs" |
|
168 |
else
|
|
169 |
echo "" |
|
|
181
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: give a more helpful message when we find |
170 |
echo "Found existing binaries with the same version. Exiting" |
171 |
echo "(use '--source-changes-dir $tmpdir_changes --force-binaries' to override)" |
|
|
169
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: calculate already downloaded packages correctly. doy |
172 |
#rm -rf "$tmpdir_changes" "$tmpdir_binaries"
|
|
165
by Jamie Strandboge
copy_sppa_to_repos: |
173 |
exit 0
|
174 |
fi
|
|
175 |
fi
|
|
176 |
fi
|
|
177 |
||
|
636
by Tyler Hicks
copy_sppa_to_repos: add the ability to download from eol releases |
178 |
$UCT/scripts/sis-changes $release $include_devel $include_debug $include_eol $debug $ppa $distribution $batch $index --action binaries --arch $arch --download $tmpdir_binaries --force-download $re $bin_pkgs || { |
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
179 |
echo "" |
|
606
by Steve Beattie
repo-tools/copy_sppa_to_repos: add --source option |
180 |
echo "Error downloading binary packages. Leaving '$tmpdir_changes' and '$tmpdir_binaries'." |
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
181 |
exit 1
|
182 |
}
|
|
|
145
by Jamie Strandboge
umt: fix matching for picking the best default arch when choosing a chroot |
183 |
|
|
606
by Steve Beattie
repo-tools/copy_sppa_to_repos: add --source option |
184 |
if [ -n "${get_source}" ] ; then |
|
636
by Tyler Hicks
copy_sppa_to_repos: add the ability to download from eol releases |
185 |
$UCT/scripts/sis-changes $release $include_devel $include_debug $include_eol $debug $ppa $distribution $batch $index --action source --download $tmpdir_sources --force-download --fetch-orig $re $bin_pkgs || { |
|
606
by Steve Beattie
repo-tools/copy_sppa_to_repos: add --source option |
186 |
echo "" |
187 |
echo "Error downloading source packages. Leaving '$tmpdir_changes' and '$tmpdir_binaries'." |
|
188 |
exit 1
|
|
189 |
}
|
|
190 |
fi
|
|
191 |
||
|
1
by Kees Cook
initial re-check-in |
192 |
dists_to_update="" |
|
145
by Jamie Strandboge
umt: fix matching for picking the best default arch when choosing a chroot |
193 |
for i in $tmpdir_changes/*_source.changes ; do |
|
1
by Kees Cook
initial re-check-in |
194 |
version=`egrep '^Version: ' $i | cut -d ' ' -f 2 | sed 's/^[0-9]:\(.*\)/\1/g'` |
195 |
dist=`egrep '^Distribution: ' $i | cut -d ' ' -f 2 | cut -d '-' -f 1` |
|
196 |
mkdir -p ${package_tools_repo_base}/${dist} |
|
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
197 |
|
|
169
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: calculate already downloaded packages correctly. doy |
198 |
downloaded_binaries=`ls $tmpdir_binaries/*${version}*` || true |
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
199 |
if [ -n "$downloaded_binaries" ]; then |
200 |
cp $tmpdir_changes/*${version}* ${package_tools_repo_base}/${dist} || err="yes" |
|
201 |
cp $tmpdir_binaries/*${version}* ${package_tools_repo_base}/${dist} || err="yes" |
|
|
607
by Steve Beattie
repo-tools/copy_sppa_to_repos: use a separate temporary directory for |
202 |
if [ -n "${get_source}" ] ; then |
|
694
by Tyler Hicks
copy_sppa_to_repos: Don't copy source files into unrelated release dirs |
203 |
dcmd cp $tmpdir_sources/*${version}*.dsc ${package_tools_repo_base}/${dist} || err="yes" |
|
607
by Steve Beattie
repo-tools/copy_sppa_to_repos: use a separate temporary directory for |
204 |
fi
|
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
205 |
else
|
206 |
echo "No binaries in '$tmpdir_binaries'. Skipping copy to ${package_tools_repo_base}." |
|
207 |
err="yes" |
|
208 |
fi
|
|
|
1
by Kees Cook
initial re-check-in |
209 |
|
|
145
by Jamie Strandboge
umt: fix matching for picking the best default arch when choosing a chroot |
210 |
if [ -z "$dists_to_update" ] || echo "$dists_to_update" | grep -qv "$dist" ; then |
211 |
dists_to_update="$dists_to_update $dist" |
|
212 |
fi
|
|
|
1
by Kees Cook
initial re-check-in |
213 |
chmod go+r ${package_tools_repo_base}/${dist}/* |
214 |
done
|
|
215 |
||
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
216 |
if [ -z "$err" ]; then |
217 |
for dist in $dists_to_update ; do |
|
|
169
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: calculate already downloaded packages correctly. doy |
218 |
$UST/repo-tools/update_repo $dist || { |
|
172
by Kees Cook
add missed double-quote |
219 |
echo "Error with 'update_repo $dist'" >&2 |
|
169
by Jamie Strandboge
repo-tools/copy_sppa_to_repos: calculate already downloaded packages correctly. doy |
220 |
err="yes" |
221 |
}
|
|
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
222 |
done
|
223 |
fi
|
|
|
1
by Kees Cook
initial re-check-in |
224 |
|
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
225 |
if [ -n "$err" ]; then |
226 |
echo "" |
|
227 |
echo -n "Errors found. " |
|
228 |
rmdir "$tmpdir_changes" 2>/dev/null || /bin/echo -e "Leaving files in:\n $tmpdir_changes (changes)" |
|
229 |
rmdir "$tmpdir_binaries" 2>/dev/null || echo " $tmpdir_binaries (binaries)" |
|
|
607
by Steve Beattie
repo-tools/copy_sppa_to_repos: use a separate temporary directory for |
230 |
[ -n "${get_source}" ] && rmdir "${tmpdir_sources}" 2>/dev/null || echo " ${tmpdir_sources} (sources)" |
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
231 |
exit 1
|
232 |
fi
|
|
|
607
by Steve Beattie
repo-tools/copy_sppa_to_repos: use a separate temporary directory for |
233 |
echo rm -rf ${tmpdir_binaries} ${tmpdir_changes} ${tmpdir_sources} |
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
234 |
rm -rf $tmpdir_binaries $tmpdir_changes |
|
607
by Steve Beattie
repo-tools/copy_sppa_to_repos: use a separate temporary directory for |
235 |
if [ -n "${get_source}" ] ; then |
236 |
rm -rf "${tmpdir_sources}" |
|
237 |
fi
|
|
|
164
by Jamie Strandboge
copy_sppa_to_repos: |
238 |