forked from openSUSE/obs-service-format_spec_file
-
Notifications
You must be signed in to change notification settings - Fork 0
/
format_spec_file
58 lines (51 loc) · 1.14 KB
/
format_spec_file
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# just a wrapper for the perl script.
while test $# -gt 0; do
case $1 in
*-outdir)
MYOUTDIR="$2"
shift
;;
*-specfile)
MYSPECFILES="$MYSPECFILES $2"
shift
;;
*)
echo Unknown parameter $1.
echo 'Usage: this service only accepts the --outdir and --specfile parameters.'
exit 1
;;
esac
shift
done
RETURN=0
if [ -z "$MYSPECFILES" ]; then
MYSPECFILES=`echo *.spec`
fi
if [ -z "$MYOUTDIR" ]; then
MYOUTDIR=`pwd`
fi
for i in $MYSPECFILES; do
if [ "$i" == '*.spec' ]; then
echo "WARNING: no spec file found"
exit 0
fi
if [ "$i" != "${i##*/}" ]; then
# no path separators, please ("security" issue)
echo "$i: illegal filename"
exit 1
fi
if /usr/lib/obs/service/format_spec_file.files/prepare_spec "$i" > "$MYOUTDIR/$i.$$"; then
# remove all file files which are indendical to committed files
# be carefull for the case that $MYOUDIR is local dir
if cmp -s "$i" "$MYOUTDIR/$i.$$"; then
rm "$MYOUTDIR/$i.$$"
else
mv "$MYOUTDIR/$i.$$" "$MYOUTDIR/$i"
fi
else
rm "$MYOUTDIR/$i.$$"
RETURN=1
fi
done
exit $RETURN