Lines 1-6
Link Here
|
1 |
#!/bin/sh -e |
1 |
#!/bin/sh -e |
2 |
# |
2 |
# |
3 |
# Copyright (C) 2000-2006 Dmitry V. Levin <ldv@altlinux.org> |
3 |
# Copyright (C) 2000-2006 Dmitry V. Levin <ldv@altlinux.org> |
|
|
4 |
# Copyright (C) 2007 Alexey Tourbin <at@altlinux.ru> |
5 |
# Copyright (C) 2010 Michael Shigorin <mike@altlinux.org> |
4 |
# |
6 |
# |
5 |
# Generates and adds/updates BuildRequires tag in specfiles. |
7 |
# Generates and adds/updates BuildRequires tag in specfiles. |
6 |
# |
8 |
# |
Lines 30-35
DEFSTAGE=c
Link Here
|
30 |
STAGE= |
32 |
STAGE= |
31 |
RPMARG="--nodeps --define '__buildreqs 1' --define '__nprocs 1'" |
33 |
RPMARG="--nodeps --define '__buildreqs 1' --define '__nprocs 1'" |
32 |
NEWTERM=dumb |
34 |
NEWTERM=dumb |
|
|
35 |
PRUNED= |
36 |
PRUNEDREQS= |
33 |
|
37 |
|
34 |
Info() |
38 |
Info() |
35 |
{ |
39 |
{ |
Lines 74-79
Valid options are:
Link Here
|
74 |
-t TERM, --term=TERM redefine TERM variable; |
78 |
-t TERM, --term=TERM redefine TERM variable; |
75 |
--trace-file=FILE trace the usage of FILE; |
79 |
--trace-file=FILE trace the usage of FILE; |
76 |
--trace-package=PACKAGE trace the usage of PACKAGE files; |
80 |
--trace-package=PACKAGE trace the usage of PACKAGE files; |
|
|
81 |
-u, --pruned add pruned requires as a comment; |
77 |
-h, --help show this text. |
82 |
-h, --help show this text. |
78 |
|
83 |
|
79 |
Default file with list of essential packages is $ESSENTIAL. |
84 |
Default file with list of essential packages is $ESSENTIAL. |
Lines 89-95
EOF
Link Here
|
89 |
exit |
94 |
exit |
90 |
} |
95 |
} |
91 |
|
96 |
|
92 |
TEMP=`getopt -n $PROG -o b:e:f:i:p:r:t:h -l essential:,filereq:,ignore:,packagereq:,rpm:,args:,define:,reset-args,term:,trace-file:,trace-package:,help -- "$@"` || show_usage |
97 |
TEMP=`getopt -n $PROG -o b:e:f:i:p:r:t:uh -l essential:,filereq:,ignore:,packagereq:,rpm:,args:,define:,reset-args,term:,trace-file:,trace-package:,pruned,help -- "$@"` || show_usage |
93 |
eval set -- "$TEMP" |
98 |
eval set -- "$TEMP" |
94 |
|
99 |
|
95 |
TRACE_FILES= |
100 |
TRACE_FILES= |
Lines 129-134
while :; do
Link Here
|
129 |
export TRACE_PACKAGES |
134 |
export TRACE_PACKAGES |
130 |
shift |
135 |
shift |
131 |
;; |
136 |
;; |
|
|
137 |
-u|--pruned) PRUNED=1; shift |
138 |
;; |
132 |
-h|--help) show_help |
139 |
-h|--help) show_help |
133 |
;; |
140 |
;; |
134 |
--) shift; break |
141 |
--) shift; break |
Lines 142-153
done
Link Here
|
142 |
[ "$#" -ge 1 ] || show_usage 'Insufficient arguments.' |
149 |
[ "$#" -ge 1 ] || show_usage 'Insufficient arguments.' |
143 |
|
150 |
|
144 |
REQFILE="$(mktemp -t "$PROG.XXXXXXXXXX")" |
151 |
REQFILE="$(mktemp -t "$PROG.XXXXXXXXXX")" |
|
|
152 |
PRUNEDFILE="$(mktemp -t "$PROG.XXXXXXXXXX")" |
145 |
|
153 |
|
146 |
exit_handler() |
154 |
exit_handler() |
147 |
{ |
155 |
{ |
148 |
local rc=$? |
156 |
local rc=$? |
149 |
trap - EXIT |
157 |
trap - EXIT |
150 |
rm -f -- "$REQFILE" |
158 |
rm -f -- "$REQFILE" "$PRUNEDFILE" |
151 |
exit $rc |
159 |
exit $rc |
152 |
} |
160 |
} |
153 |
|
161 |
|
Lines 164-173
for SPEC in "$@"; do
Link Here
|
164 |
else |
172 |
else |
165 |
SPEC_STAGE="$STAGE" |
173 |
SPEC_STAGE="$STAGE" |
166 |
fi |
174 |
fi |
|
|
175 |
if [ -z "$PRUNED" ]; then |
176 |
grep -q '^# optimized out: ' -- "$SPEC" && PRUNED=1 |
177 |
fi |
167 |
eval \ |
178 |
eval \ |
168 |
"$(Quote "TERM=$NEWTERM")" \ |
179 |
"$(Quote "TERM=$NEWTERM")" \ |
169 |
"$(Quote "$PACKAGEREQ")" \ |
180 |
"$(Quote "$PACKAGEREQ")" \ |
170 |
-o "$(Quote "$REQFILE")" \ |
181 |
-o "$(Quote "$REQFILE")" \ |
|
|
182 |
-u "$(Quote "$PRUNEDFILE")" \ |
171 |
-e "$(Quote "$ESSENTIAL")" \ |
183 |
-e "$(Quote "$ESSENTIAL")" \ |
172 |
-i "$(Quote "$IGNORE")" \ |
184 |
-i "$(Quote "$IGNORE")" \ |
173 |
-f "$(Quote "$FILEREQ")" \ |
185 |
-f "$(Quote "$FILEREQ")" \ |
Lines 175-181
for SPEC in "$@"; do
Link Here
|
175 |
TMPFILE="$(mktemp -t "$PROG.XXXXXXXXXX")" |
187 |
TMPFILE="$(mktemp -t "$PROG.XXXXXXXXXX")" |
176 |
: >"$TMPFILE" |
188 |
: >"$TMPFILE" |
177 |
REQS="$(cat "$REQFILE" |xargs echo -n)" |
189 |
REQS="$(cat "$REQFILE" |xargs echo -n)" |
178 |
LC_ALL=C /usr/share/buildreqs/filter_spec -v "reqs=$REQS" "stage=$SPEC_STAGE" <"$SPEC" >>"$TMPFILE" |
190 |
[ -n "$PRUNED" ] && PRUNEDREQS="$(cat "$PRUNEDFILE" |xargs echo -n)" |
|
|
191 |
LC_ALL=C /usr/share/buildreqs/filter_spec -v "reqs=$REQS" "pruned=$PRUNEDREQS" "stage=$SPEC_STAGE" <"$SPEC" >>"$TMPFILE" |
179 |
if ! cmp -s "$SPEC" "$TMPFILE"; then |
192 |
if ! cmp -s "$SPEC" "$TMPFILE"; then |
180 |
cat "$TMPFILE" >"$SPEC" |
193 |
cat "$TMPFILE" >"$SPEC" |
181 |
fi |
194 |
fi |