Deb 一键式打包脚本

Author Avatar
Mutse Young 3月 20, 2011

是夜,温故 shell, 偶有所得,遂作 post 以记之。

问:此乃何物?对曰:debian 打包利器也。

shell 脚本:

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
#
# File: mkdeb.sh
# Version: 0.11.03
# Description: this bash shell script shows how
# to generate a debian package.
#
# Created date: March 20th, 2011
# Author: mutse <yyhoo2.young@gmail.com>
# (C) 2011 Chin Foundry. All Rights Reserved.
#
echo
echo "mkdeb (chin foundry utility) 0.11.03"
echo "(C) 2011 Chin Foundry. All Rights Reserved."
echo

if [ ! -e /usr/bin/dh_make ]
then
sudo apt-get install dh-make
fi

echo "Plese choose a directory name which you want to package:"
read -p " >> " DIRNAME

echo "Please input the version of your package:"
read -p " >> " VERSION
SRCDIRNAME=$DIRNAME"-"$VERSION

if [ ! -d $DIRNAME ]
then
if [ ! -d $SRCDIRNAME ]
then
echo "$DIRNAME or $SRCDIRNAME is not exist."
exit 1
fi
fi

if [ ! -d $SRCDIRNAME ]
then
mv "$DIRNAME" "$SRCDIRNAME"
fi

TARNAME=$DIRNAME"_"$VERSION".orig.tar.gz"
tar -czvf $TARNAME $SRCDIRNAME

echo "Please input your email:"
read -p " >> " EMAIL

cd $SRCDIRNAME

USER=`id -un`
dh_make -s -e $EMAIL -f ../$TARNAME
sudo dpkg-buildpackage -rfakeroot
cd ..
sudo chown -R $USER:$USER *.deb

echo "Your debian package is generated."