View | Details | Raw Unified | Return to bug 22709
Collapse All | Expand All

(-)a/rpm-utils/buildreq (-3 / +16 lines)
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
(-)a/rpm-utils/filter_spec (+13 lines)
Lines 1-6 Link Here
1
#!/bin/awk -f
1
#!/bin/awk -f
2
#
2
#
3
# Copyright (C) 2000, 2003  Dmitry V. Levin <ldv@altlinux.org>
3
# Copyright (C) 2000, 2003  Dmitry V. Levin <ldv@altlinux.org>
4
# Copyright (C) 2010  Michael Shigorin <mike@altlinux.org>
4
#
5
#
5
# Update BuildRequires.
6
# Update BuildRequires.
6
#
7
#
Lines 33-38 function insert_reqs() Link Here
33
		printf( "# Automatically added by buildreq on %s", strftime("%a %b %d %Y") );
34
		printf( "# Automatically added by buildreq on %s", strftime("%a %b %d %Y") );
34
		if (stage != "" && stage != "c")
35
		if (stage != "" && stage != "c")
35
			printf( " (-b%s)", stage );
36
			printf( " (-b%s)", stage );
37
		if ( pruned != "" )
38
			printf( "\n# optimized out: %s", pruned);
36
		printf( "\nBuildRequires: %s\n\n", reqs );
39
		printf( "\nBuildRequires: %s\n\n", reqs );
37
		reqs = "";
40
		reqs = "";
38
	}
41
	}
Lines 48-53 function insert_reqs() Link Here
48
	}
51
	}
49
}
52
}
50
53
54
/^\# optimized out: .*$/{
55
	if ( !processed )
56
	{
57
		insert_reqs();
58
		processed = 1;
59
		found = 1;
60
		skipws = 1;
61
	}
62
}
63
51
/^BuildRequires:.*/{
64
/^BuildRequires:.*/{
52
	if ( !processed )
65
	if ( !processed )
53
	{
66
	{
(-)a/rpm-utils/packagereq (-9 / +18 lines)
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) 2006-2008  Alexey Tourbin <at@altlinux.ru>
5
# Copyright (C) 2010  Michael Shigorin <mike@altlinux.org>
4
#
6
#
5
# Generates list of package requires for given command.
7
# Generates list of package requires for given command.
6
#
8
#
Lines 60-72 packagereq comes with ABSOLUTELY NO WARRANTY, see license for details. Link Here
60
Usage: $PROG options <program> [program-args]
62
Usage: $PROG options <program> [program-args]
61
63
62
Valid options are:
64
Valid options are:
63
-o FILENAME, --output=FILENAME      filename where to write output requires;
65
-o FILENAME, --output=FILENAME      filename to write optimized requires to;
64
-e ESSENTIAL, --essential=ESSENTIAL filename where to get list of
66
-u FILENAME, --pruned=FILENAME      filename to write pruned requires to;
65
                                    essential packages;
67
-e ESSENTIAL, --essential=ESSENTIAL filename to get list of
66
-i IGNORE, --ignore=IGNORE          directory where to get list of
68
                                    essential packages from;
67
                                    packages to ignore;
69
-i IGNORE, --ignore=IGNORE          directory to get list of
68
-s SUBST, --substitute=SUBST        directory where to get package
70
                                    packages to ignore from;
69
                                    name substitution rules;
71
-s SUBST, --substitute=SUBST        directory to get package
72
                                    name substitution rules from;
70
-p PACKAGEOF, --packageof=PACKAGEOF path to PACKAGEOF;
73
-p PACKAGEOF, --packageof=PACKAGEOF path to PACKAGEOF;
71
-f FILEREQ, --filereq=FILEREQ       path to FILEREQ;
74
-f FILEREQ, --filereq=FILEREQ       path to FILEREQ;
72
-q, --quiet                         be quiet;
75
-q, --quiet                         be quiet;
Lines 83-95 EOF Link Here
83
	exit
86
	exit
84
}
87
}
85
88
86
TEMP=`getopt -n $PROG -o +o:e:f:i:p:s:r:qh -l output:,essential:,filereq:,ignore:,packageof:,substitute:,rpm:,quiet,help -- "$@"` || show_usage
89
TEMP=`getopt -n $PROG -o +o:u:e:f:i:p:s:r:qh -l output:,pruned:,essential:,filereq:,ignore:,packageof:,substitute:,rpm:,quiet,help -- "$@"` || show_usage
87
eval set -- "$TEMP"
90
eval set -- "$TEMP"
88
91
89
while :; do
92
while :; do
90
	case "$1" in
93
	case "$1" in
91
		-o|--output) shift; OUTFILE="$1"; shift
94
		-o|--output) shift; OUTFILE="$1"; shift
92
			;;
95
			;;
96
		-u|--pruned) shift; PRUNEDFILE="$1"; shift
97
			;;
93
		-e|--essential) shift; ESSENTIAL="$1"; shift
98
		-e|--essential) shift; ESSENTIAL="$1"; shift
94
			;;
99
			;;
95
		-p|--packageof) shift; PACKAGEOF="$1"; shift
100
		-p|--packageof) shift; PACKAGEOF="$1"; shift
Lines 169-174 comm -23 "$WORKDIR/deps0" "$WORKDIR/deps1" >"$WORKDIR/optimized-out" Link Here
169
REQS="$(cat "$WORKDIR/deps1" |tr '\n' ' ' |sed -e 's/ \+$//')"
174
REQS="$(cat "$WORKDIR/deps1" |tr '\n' ' ' |sed -e 's/ \+$//')"
170
printf %s\\n "$REQS" >"$OUTFILE"
175
printf %s\\n "$REQS" >"$OUTFILE"
171
176
177
if [ -n "$PRUNEDFILE" ]; then
178
	PRUNED="$(cat "$WORKDIR/optimized-out" |tr '\n' ' ' |sed -e 's/ \+$//')"
179
	printf %s\\n "$PRUNED" >"$PRUNEDFILE"
180
fi
181
172
if [ -z "$QUIET" ]; then
182
if [ -z "$QUIET" ]; then
173
	if [ -s "$WORKDIR/optimized-out" ]; then
183
	if [ -s "$WORKDIR/optimized-out" ]; then
174
		Info "optimized out:" $(cat "$WORKDIR/optimized-out")
184
		Info "optimized out:" $(cat "$WORKDIR/optimized-out")
175
- 

Return to bug 22709