|
@@ -1,167 +0,0 @@
|
1
|
|
-#!/bin/bash
|
2
|
|
-
|
3
|
|
-ffoo import core
|
4
|
|
-
|
5
|
|
-
|
6
|
|
-guess_pkgnames() {
|
7
|
|
- #
|
8
|
|
- # Guess interesting names from a folder of RPMs
|
9
|
|
- #
|
10
|
|
- ls "$1" \
|
11
|
|
- | grep rpm\$ \
|
12
|
|
- | sed -e 's/-[0-9].*$//' \
|
13
|
|
- | sort \
|
14
|
|
- | uniq
|
15
|
|
-}
|
16
|
|
-
|
17
|
|
-
|
18
|
|
-guess_rtag() {
|
19
|
|
- #
|
20
|
|
- # Guess release tag from uname
|
21
|
|
- #
|
22
|
|
- uname -r | sed -e 's/^[.0-9-]*//; s/\..*$//'
|
23
|
|
-}
|
24
|
|
-
|
25
|
|
-
|
26
|
|
-guess_rtag_word() {
|
27
|
|
- #
|
28
|
|
- # Guess "word" part of release tag from uname
|
29
|
|
- #
|
30
|
|
- # Use guess_rtag and parse out the "word" part,
|
31
|
|
- # e.g. el from el6 or fc from fc18
|
32
|
|
- #
|
33
|
|
- echo $(guess_rtag) | sed -e 's/[0-9]*$//'
|
34
|
|
-}
|
35
|
|
-
|
36
|
|
-
|
37
|
|
-guess_rtag_num() {
|
38
|
|
- #
|
39
|
|
- # Guess "numeric" part of release tag from uname
|
40
|
|
- #
|
41
|
|
- # Use guess_rtag and parse out the "numeric" part,
|
42
|
|
- # e.g. 6 from el6 or 18 from fc18
|
43
|
|
- #
|
44
|
|
- echo $(guess_rtag) | sed -e 's/^[a-z]*//'
|
45
|
|
-}
|
46
|
|
-
|
47
|
|
-
|
48
|
|
-installed_versions() {
|
49
|
|
- #
|
50
|
|
- # For every prefix, print installed versions
|
51
|
|
- #
|
52
|
|
- cat - \
|
53
|
|
- | while read name;
|
54
|
|
- do rpm -qa "$name*";
|
55
|
|
- done \
|
56
|
|
- | sort \
|
57
|
|
- | uniq
|
58
|
|
-}
|
59
|
|
-
|
60
|
|
-
|
61
|
|
-nvc_parse() {
|
62
|
|
- #
|
63
|
|
- # Parse NVC and print element they asked for
|
64
|
|
- #
|
65
|
|
- local what="$1"
|
66
|
|
- local nvc="$2"
|
67
|
|
- test -n "$nvc" || what=USAGE # just provoke the * case
|
68
|
|
- local arch="${nvc##*.}"
|
69
|
|
- local rest="${nvc%%.$arch}"
|
70
|
|
- local release="${rest##*-}"
|
71
|
|
- local rest="${rest%%-$release}"
|
72
|
|
- local version="${rest##*-}"
|
73
|
|
- local name="${rest%-*}"
|
74
|
|
- case $what in
|
75
|
|
- arch)
|
76
|
|
- echo $arch
|
77
|
|
- ;;
|
78
|
|
- release)
|
79
|
|
- echo $release
|
80
|
|
- ;;
|
81
|
|
- version)
|
82
|
|
- echo $version
|
83
|
|
- ;;
|
84
|
|
- name)
|
85
|
|
- echo $name
|
86
|
|
- ;;
|
87
|
|
- *)
|
88
|
|
- usage_is "arch|release|version|name NVC"
|
89
|
|
- return 1
|
90
|
|
- esac
|
91
|
|
-}
|
92
|
|
-
|
93
|
|
-
|
94
|
|
-save_repo_for() {
|
95
|
|
- #
|
96
|
|
- # Fetch a repo for given target/release
|
97
|
|
- #
|
98
|
|
- # Find out release, take target and from repo_uris.ini,
|
99
|
|
- # choose correct repo URI, finally saving the repo file
|
100
|
|
- # to /etc/yum.repos.d
|
101
|
|
- #
|
102
|
|
- local target=$1
|
103
|
|
- local rtag_word=$(guess_rtag_word)
|
104
|
|
- local uri=$(iniread -s $rtag_word -k $target repo_uris.ini)
|
105
|
|
- think "adding repo for $target"
|
106
|
|
- debug -v target rtag_word uri
|
107
|
|
- case "$uri" in
|
108
|
|
- INCLUDED)
|
109
|
|
- ;;
|
110
|
|
- NONE)
|
111
|
|
- warn "no repo available for $target"
|
112
|
|
- return 1
|
113
|
|
- ;;
|
114
|
|
- *)
|
115
|
|
- pushd /etc/yum.repos.d/ >/dev/null
|
116
|
|
- wget -q "$uri"
|
117
|
|
- popd >/dev/null
|
118
|
|
- ;;
|
119
|
|
- esac
|
120
|
|
-}
|
121
|
|
-
|
122
|
|
-
|
123
|
|
-yum_preerase() {
|
124
|
|
- #
|
125
|
|
- # Read package names from stdin and pre-erase them
|
126
|
|
- #
|
127
|
|
- local pkg
|
128
|
|
- for pkg in "$@";
|
129
|
|
- do
|
130
|
|
- if rpm -q "$pkg" &> /dev/null;
|
131
|
|
- then
|
132
|
|
- think "pre-erasing $pkg"
|
133
|
|
- yum -q -y erase "$pkg"
|
134
|
|
- fi
|
135
|
|
- done
|
136
|
|
-}
|
137
|
|
-
|
138
|
|
-
|
139
|
|
-yum_install() {
|
140
|
|
- #
|
141
|
|
- # Mindlessly and silently install anything
|
142
|
|
- #
|
143
|
|
- yum -q -y install "$@" 2>&1 | mute_known yum
|
144
|
|
-}
|
145
|
|
-
|
146
|
|
-
|
147
|
|
-yum_install_if_needed() {
|
148
|
|
- #
|
149
|
|
- # yum_install unless it's already installed
|
150
|
|
- #
|
151
|
|
- local pkgs="$(select_args word $@)"
|
152
|
|
- local opts="$(select_args opt $@)"
|
153
|
|
- local pkg
|
154
|
|
- debug -v pkgs opts
|
155
|
|
- for pkg in $pkgs;
|
156
|
|
- do
|
157
|
|
- rpm -q $pkg >& /dev/null || yum_install $opts $pkg;
|
158
|
|
- done
|
159
|
|
-}
|
160
|
|
-
|
161
|
|
-
|
162
|
|
-yum_update() {
|
163
|
|
- #
|
164
|
|
- # Mindlessly and silently update anything
|
165
|
|
- #
|
166
|
|
- yum -q -y update "$@" 2>&1 | mute_known yum
|
167
|
|
-}
|