forked from emacsattic/ibus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-dist.sh
executable file
·150 lines (118 loc) · 2.79 KB
/
make-dist.sh
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
# Copyright (c) 2010 and onwards, S. Irie
# This program is distributed under the MIT Licence.
EL_DEV="ibus-dev.el"
EL_MAIN="ibus.el"
DBGREGEXP="^;*\t* *(ibus-log\b"
FILES=("ibus-el-agent" "README" "doc" "debian")
PACKAGE="ibus-el"
VERSION=$(sed -n 's/^(defconst ibus-mode-version "\(.*\)")$/\1/p' $EL_DEV)
# Command line options =================
DCH="no"
DEBUILD="no"
BLDTYPE="deb"
NATIVE="yes"
BLDFLAGS=""
while getopts :hcbSpnu OPTION
do
case $OPTION in
h)
echo "usage: $0 [OPTION]..."
echo " -c edit debian/changelog"
echo " -b build deb package"
echo " -S build source package"
echo " -p build deb package using pbuilder"
echo " -n build deb package as a non-native one"
echo " -u add -us -uc options to debuild"
echo " -h display this help and exit"
exit
;;
c)
DCH="yes"
;;
b)
DEBUILD="yes"
;;
S)
if [ "$BLDTYPE" == "pbuild" ]; then
echo "$0: options -p and -S can't be used together." >&2
exit 1
fi
DEBUILD="yes"
BLDTYPE="src"
;;
p)
if [ "$BLDTYPE" == "src" ]; then
echo "$0: options -S and -p can't be used together." >&2
exit 1
fi
DEBUILD="yes"
BLDTYPE="pbuild"
;;
n)
NATIVE="no"
;;
u)
BLDFLAGS="${BLDFLAGS} -us -uc"
;;
?)
echo "$0: invalid option -- $OPTARG" >&2
echo "Try \`$0 -h' for more information." >&2
exit 1
;;
esac
done
# Paths ================================
WORKDIR="v${VERSION}"
ARCHDIR="${WORKDIR}/${PACKAGE}-${VERSION}"
ARCHFILE="${ARCHDIR}.tar.gz"
ARDEBDIR="${ARCHDIR}/debian"
ORIGARCH="${WORKDIR}/${PACKAGE}_${VERSION}.orig.tar.gz"
CURRDIR="$PWD"
# Locate files =========================
rm -rfv $WORKDIR
mkdir -pv $ARCHDIR
if [ "$DBGREGEXP" == "" ]; then
cp -pv $EL_DEV ${ARCHDIR}/${EL_MAIN}
else
echo "comment out debug codes in $EL_DEV -> ${ARCHDIR}/${EL_MAIN}"
sed "s/\(${DBGREGEXP}\)/;#\1/" $EL_DEV > ${ARCHDIR}/${EL_MAIN}
fi
for i in ${FILES[@]}; do
cp -rpv $i $ARCHDIR
done
for i in $(find $ARCHDIR -regex '.*\(~\|\.~[0-9]+~\)'); do
rm -fv $i # Delete backup files
done
# Edit changelog =======================
if [ "$DCH" == "yes" ]; then
cd $ARDEBDIR
dch -v ${VERSION}
cd $CURRDIR
cp -pv --backup=t ${ARDEBDIR}/changelog debian/changelog
fi
# Create archive =======================
echo "create archive $ARCHFILE"
cd $WORKDIR
tar cvzf $(basename $ARCHFILE) $(basename $ARCHDIR)
cd $CURRDIR
# Build deb package ===================
if [ ! "$DEBUILD" == "yes" ]; then
exit 0
fi
if [ "$NATIVE" == "no" ]; then
cp -pv $ARCHFILE $ORIGARCH
fi
cd $ARCHDIR
case $BLDTYPE in
deb)
debuild ${BLDFLAGS}
;;
src)
debuild -S ${BLDFLAGS}
;;
pbuild)
debuild -S ${BLDFLAGS} && sudo pbuilder build ../*.dsc
;;
esac
cd $CURRDIR