-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_debs.sh
executable file
·154 lines (119 loc) · 2.89 KB
/
build_debs.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
151
152
153
154
#!/bin/bash
# set -e
CONFIG_FILE=$BUILD_DIR/$1
APP_NAME=$2
# SHORT_HASH=$(echo $TRAVIS_COMMIT | cut -c1-8)
# echo $SHORT_HASH
if [ -z $CONFIG_FILE ]
then
echo "No Config File Specified"
exit 1
fi
if [ -z $APP_NAME ]
then
echo "No App Name Specified"
exit 1
fi
echo "Using $CONFIG_FILE to build $APP_NAME"
REPO_URL=$(cat $CONFIG_FILE | jq -r .repoUrl)
echo Repo: $REPO_URL
PACKAGE_NAME=$(cat $CONFIG_FILE | jq -r .packageName)
echo Package: $PACKAGE_NAME
VERSION=$(cat $CONFIG_FILE | jq -r .packageVersion)
echo Version: $VERSION
PACKAGE_URL=$REPO_URL/$PACKAGE_NAME
echo Package url: $PACKAGE_URL
# setup functions
functions=$(dirname $0)/functions.sh
echo $functions
source $functions
echo "Working on Branch: ${BRANCH}"
if [ -z "${BRANCH}"]
then
PACKAGE_APP_NAME=$APP_NAME
else
if [ "${BRANCH}" != "master" ]
then
PACKAGE_APP_NAME=$APP_NAME-$BRANCH
else
PACKAGE_APP_NAME=$APP_NAME
fi
fi
# standard deb package prep
init_tmp
# download package if need be
if [ $(needs_download) -ne "0" ]
then
download_pkg
pre_extract_commands
if [ $(is_zip) -ne "0" ]
then
unpack
extract_data
extract_control
else
rm -rf zip_data/*
unpack_zip
fi
fi
# if you need to run various commands for cleaning, creating files/dirs
# or other types of commands, this is where you'd run them
pre_config_commands
has_configs=$( jq -r ".configs | length " < $CONFIG_FILE )
echo "This app has configs: $has_configs"
if [ $( jq -r ".configs | length " < $CONFIG_FILE ) > 0 ]
then
cp_configs $CONFIG_FILE $APP_NAME
fi
cd ..
echo "repacking debian package"
# BRANCH_NAME=$(git branch | grep \* | cut -d ' ' -f2)
FPM_CMD="fpm -s dir -t deb -n ${PACKAGE_APP_NAME} -v ${VERSION}"
pre_install
if [ -f preinst ]
then
FPM_CMD=$FPM_CMD" --before-install preinst"
fi
post_install
if [ -f postinst ]
then
FPM_CMD=$FPM_CMD" --after-install postinst "
fi
post_remove
if [ -f prerm ]
then
FPM_CMD=$FPM_CMD" --after-remove prerm"
fi
if [ -f postrm ]
then
FPM_CMD=$FPM_CMD" --after-remove postrm"
fi
script_name=$(upstart_script)
if [ -n "$script_name" ]
then
FPM_CMD=$FPM_CMD" --deb-upstart $script_name"
fi
if [ $( jq -r ".pre_dependencies | length " < $CONFIG_FILE ) > 0 ]
then
FPM_CMD=$FPM_CMD" $(pkg_pre_dependencies $CONFIG_FILE $APP_NAME) "
fi
if [ $( jq -r ".dependencies | length " < $CONFIG_FILE ) > 0 ]
then
FPM_CMD=$FPM_CMD" $(pkg_dependencies $CONFIG_FILE $APP_NAME) "
fi
if [ $(is_zip) -ne "0" ]
then
FPM_CMD=$FPM_CMD" -a amd64 tmp/data/=/"
else
FPM_CMD=$FPM_CMD" -a amd64 tmp/zip_data/=/"
fi
echo $FPM_CMD
rm $PACKAGE_APP_NAME*.deb || echo "no deb $APP_NAME package in $(pwd)"
eval $FPM_CMD
if [ ! -z "${APT_REPO_DIR}"]
then
rm ${APT_REPO_DIR}/*.deb || echo "no deb packages in build/*.deb"
mkdir ${APT_REPO_DIR} || echo "build directory already created"
mv *.deb ${APT_REPO_DIR}
fi
cleanup;