blob: ec244bc898d972466be8d999404dcf8684701260 (
plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
#!/bin/bash
# -*- Mode: shell-script -*-
# Copyright (C) 2000 by Chmouel Boudjnah <chmouel@mandrakesoft.com>,
# MandrakeSoft
# Redistribution of this file is permitted under the terms of the GNU
# Public License (GPL)
## description:
# Macroszification of files to be mandrake compliant, also do some check.
function usage () {
rval=$1
echo "Usage: $(basename $0) -d --help --nodiff --nocheck --clean SPEC-FILE"
echo -e "\t-d: Product only a diff don't change nothing"
echo -e '\t-o: Only change the mandir/infodir'
echo -e "\t--nocheck: Don't try do check about Prefix %configure"
echo -e "\t--clean: remove the old files after"
echo -e "\t--nodiff: I don't want to see the diff output"
echo -e "\t--help: This help"
exit $rval;
}
while [[ $1 == -* ]];do
case $1 in
-d)
only_diff=1;
shift;
;;
-o)
only_fhs=1;
shift;
;;
--nocheck)
nocheck=1;
shift;
;;
--nodiff)
nodiff=1;
shift;
;;
--clean)
clean=1;
shift;
;;
-*)
usage 0
;;
esac
done
file=$1;
if [[ ! -f $file ]];then
echo -e "Error: i really need a spec file to work\n";
usage $val;
fi
[[ -z $nocheck ]] && egrep -q "^Prefix:[[:space:]]+" $file || {
echo "sound like you don't have a Prefix set"
exit;
}
[[ -z $nocheck ]] && egrep -q "^%configure" $file && {
egrep -q "^%makeinstall" $file || {
echo "sound like you don't have a %makeinstall"
exit;
}
}
[[ -z $nocheck ]] && egrep -q "^Docdir:[[:space:]]+" $file && {
echo "You have a Docdir entry, it's not good !!"
exit;
}
mv -f $file $file.old
if [[ -z $only_fhs ]];then
cat $file.old | perl -e "
while (<>) {
s@[/]?(usr|%{[_]?prefix})/bin@%{_bindir}@g;
s@[/]?(usr|%{[_]?prefix})/man@%{_mandir}@g;
s@[/]?(usr|%{[_]?prefix})/sbin@%{_sbindir}@g;
s@[/]?(usr|%{[_]?prefix})/etc@%{_sysconfdir}@g;
s@[/]?(usr|%{[_]?prefix})/lib@%{_libdir}@g;
s@[/]?(usr|%{[_]?prefix})/share@%{_datadir}@g;
s@[/]?(usr|%{[_]?prefix})/include@%{_includedir}@g;
s@[/]?(usr|%{[_]?prefix})/info@%{_infodir}@g;
s@/etc@%{_sysconfdir}@;
s@/usr@%{prefix}@;
print;
}
" > $file
else
cat $file.old | perl -e "
while (<>) {
s@[/]?(usr|%{[_]?prefix})/man@%{_mandir}@g;
s@[/]?(usr|%{[_]?prefix})/info@%{_infodir}@g;
print;
}
" > $file
fi
if [[ -z $nodiff ]];then
diff -u $file.old $file
fi
if [[ -n $only_diff ]];then
mv -f $file.old $file
fi
if [[ -n $clean ]];then
rm -f $file.old
fi
|