-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_fields
executable file
·90 lines (71 loc) · 1.87 KB
/
add_fields
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
#!/bin/sh
orig="$1"
dest="$2"
pkg=`basename $orig .debdesc`
cp "$orig" "$dest"
version="1"
if grep -q '^Version:' $orig ; then
version=`cat $orig | grep '^Version:' | cut -d: -f2`
grep -v "^Version:" $dest > $dest.tmp
mv $dest.tmp $dest
fi
echo "Version: $version~dev`date +%Y%m%d`.`date +%H%M%S`" >> "$dest"
echo "Architecture: all" >> "$dest"
to_copy=`cat $dest | grep "^Copy: " | sed -e 's/Copy: //'`
files_mapping () {
if [ -d "./$pkg/files" ] ; then
files_path="./$pkg/files"
else
files_path="./$pkg"
fi
echo "$to_copy" | while read f ; do
echo " $files_path/$f"
done
}
diffable_files () {
[ -d $pkg/diff/ ] || return
cd $pkg/diff/
find -type f -name '*.orig' | sed -e 's#^\./##' | sed -e 's/\.orig$//'
}
patch_file_local () {
f=$1
echo "./$pkg/diff/$f.diff"
}
patch_file_install_dir () {
d=`dirname $1`
echo "/usr/share/$pkg/patches/$d/"
}
diffable=`diffable_files`
patch_mapping () {
for f in $diffable ; do
patch=`patch_file_local $f`
patch_inst_dir=`patch_file_install_dir $f`
diff -u $pkg/diff/$f.orig $pkg/diff/$f | sed -e "s#$pkg/diff##" > "$patch"
echo " $patch $patch_inst_dir"
done
}
if [ -n "$to_copy" ] || [ -n "$diffable" ] ; then
echo -n "Files:" >> "$dest"
[ -n "$to_copy" ] && echo "`files_mapping`" >> "$dest"
[ -n "$diffable" ] && echo "`patch_mapping`" >> "$dest"
echo >> "$dest"
fi
if [ -n "$diffable" ] ; then
echo "Pre-Depends: patch" >> "$dest"
echo "File: postinst" >> "$dest"
echo " #!/bin/sh -e" >> "$dest"
for f in $diffable ; do
echo " patch -p0 -i /usr/share/$pkg/patches/$f.diff" >> "$dest"
done
echo >> "$dest"
echo "File: prerm" >> "$dest"
echo " #!/bin/sh -e" >> "$dest"
for f in $diffable ; do
echo " patch -R -p0 -i /usr/share/$pkg/patches/$f.diff" >> "$dest"
done
echo >> "$dest"
fi
grep -v "^Copy:" "$dest" > "$dest.tmp"
mv "$dest.tmp" "$dest"
grep -v "^Diff:" "$dest" > "$dest.tmp"
mv "$dest.tmp" "$dest"