-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_source
executable file
·41 lines (32 loc) · 887 Bytes
/
get_source
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
#!/bin/sh -eu
# Copyright 2017-2018 Yury Gribov
#
# Use of this source code is governed by MIT license that can be
# found in the LICENSE.txt file.
# Usage: get_source_pkg PKG...
# Map Debian packages to their source packages.
REL=$(lsb_release -cs)
is_good_package() {
# Skip packages which are not present in our distro
if apt-cache madison $1 | grep -q 'Unable to locate package'; then
return 1
fi
# Skip packages for which sources are missing in Trusty
if ! apt-cache madison $1 | grep -q $REL; then
return 1
fi
# # Skip virtual packages
# if apt-cache show --quiet=0 $1/$REL 2>&1 | grep -q 'No packages found'; then
# return 1
# fi
return 0
}
for p in $@; do
src=$(apt-cache showsrc $p 2>/dev/null | grep Package: | awk '{print $2}' | head -1)
if test -z "$src"; then
src=$p
fi
if is_good_package $src; then
echo $src
fi
done