-
Notifications
You must be signed in to change notification settings - Fork 25
/
package.sh
executable file
·105 lines (88 loc) · 2.54 KB
/
package.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
#!/bin/bash
# configurations
var_version=0.1.1
# discover BASEDIR
#BASEDIR=`dirname "$0"`/.. # located on ROOT_DIR/bin
BASEDIR=`dirname "$0"`/. # located on ROOT_DIR
BASEDIR=`(cd "$BASEDIR"; pwd)`
ls -l "$0" | grep -e '->' > /dev/null 2>&1
if [ $? = 0 ]; then
#this is softlink
_PWD=`pwd`
_EXEDIR=`dirname "$0"`
cd "$_EXEDIR"
_BASENAME=`basename "$0"`
_REALFILE=`ls -l "$_BASENAME" | sed 's/.*->\ //g'`
BASEDIR=`dirname "$_REALFILE"`/..
BASEDIR=`(cd "$BASEDIR"; pwd)`
cd "$_PWD"
fi
# os type detection function
ostype () {
local OSNAME="`uname`"
case $OSNAME in
'Linux')
OSNAME='Linux'
cat /etc/*-release | grep -i 'CentOS' > /dev/null
if [ $? -eq 0 ];
then
OSNAME='CentOS'
else
cat /etc/*-release | grep -i 'Ubuntu' > /dev/null
if [ $? -eq 0 ];
then
OSNAME='Ubuntu'
fi
fi
;;
'FreeBSD')
OSNAME='FreeBSD'
alias ls='ls -G'
;;
'WindowsNT')
OSNAME='Windows'
;;
'Darwin')
OSNAME='Mac'
;;
'SunOSNAME')
OSNAME='Solaris'
;;
'AIX') ;;
*) ;;
esac
echo "$OSNAME"
}
#
# working area
#
var_chdir=target/autorest4db-$var_version
var_prefix=/usr/local/autorest4db
var_after_install=$BASEDIR/src/main/assembly/share/after_install.sh
var_target='deb'
var_osname="$(ostype)"
case $var_osname in
'Mac')
var_target='osxpkg'
;;
'Ubuntu') # Ubuntu apt-get deb
var_target='deb'
;;
'CentOS') # CentOS yum rpm
var_target='rpm'
;;
'*')
var_target='deb'
;;
esac
# gen after_install.sh
# package description
pk_url="https://github.com/downgoon/autorest4db"
pk_vendor="downgoon"
pk_maintainer="downgoon@qq.com"
pk_category="web"
pk_description="automatically generate a RESTful API of your database (sqlite3 or mysql) in runtime."
echo "packaging ..."
echo fpm -f --verbose -s dir -t $var_target --deb-no-default-config-files --deb-auto-config-files -n autorest4db -v $var_version -C $var_chdir --package $BASEDIR --prefix $var_prefix --after-install $var_after_install --url "$pk_url" --vendor "$pk_vendor" --category "$pk_category" --description "$pk_description" --maintainer="$pk_maintainer"
# package (deb format)
exec fpm -f --verbose -s dir -t $var_target --deb-no-default-config-files --deb-auto-config-files -n autorest4db -v $var_version -C $var_chdir --package $BASEDIR --prefix $var_prefix --after-install $var_after_install --url "$pk_url" --vendor "$pk_vendor" --category "$pk_category" --description "$pk_description" --maintainer="$pk_maintainer"