2 # Copyright (C) 2014 Ian Kelling
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 if [[ -f /etc
/fedora-release
]]; then
19 elif [[ -e /etc
/os-release
]]; then
20 sed -rn 's/^ID=(.*)/\1/p' /etc
/os-release
28 echo `distro-name``debian-archive`
34 local policy
="${1:-$(apt-cache policy)}"
38 # c = component (licensing component)
39 # l = label (Debian{,-Security,-Updates})
40 { for archive
in stable testing unstable
; do
41 # print priority + archive name. priority is in
42 # the previous line after finding the archive.
43 read -rd '' expression
<<EOF ||:
44 /o=Debian,a=$archive,.*l=Debian,c=main/{x;s/^ *([-0-9]+).*/\1 $archive/p;q};h
46 echo "$policy" |
sed -rn "$expression"
48 } |
sort -rn |
head -n1 |
grep -oE "\w+$"
53 [[ $
(debian-archive
) == testing
]]
55 # I only do testing or stable.
57 [[ $
(debian-archive
) == stable
]]
62 local policy
="$(apt-cache policy)"
63 archive
=$
(debian-archive
"$policy")
64 echo "$policy" |
sed -rn "s/^.*a=$archive,n=([a-z]+).*/\1/p;T;q"
67 [[ $
(distro-name
) == fedora
]]
70 [[ $
(distro-name
) == debian
]]
73 [[ $
(distro-name
) == arch
]]
76 isdeb
() { command -v apt-get
&>/dev
/null
; }
78 [[ $
(distro-name
) == ubuntu
]]