-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild-deb.sh
executable file
·102 lines (72 loc) · 2.28 KB
/
build-deb.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
#!/bin/bash -e
APP_NAME="moltaqa-lib"
APP_VERSION="1.0b1"
APP_DIR_NAME="${APP_NAME}-${APP_VERSION}"
APP_FILES="moltaqa-lib.pro Doxyfile share bin src test"
TEMP_DIR="temp-build-deb"
RPM_TEMP_DIR="rpm-temp-dir"
OUTPUT_DIR="dist"
SOURCE_ARCHIVE="${APP_NAME}-${APP_VERSION}.tar.gz"
SOURCE_ARCHIVE_ORIG="${APP_NAME}_${APP_VERSION}.orig.tar.gz"
if [ -n "$WORKSPACE" ];
then
SOURCE_DIR="$WORKSPACE"
else
SOURCE_DIR=`pwd`
fi
TEMP_DIR_PATH=$SOURCE_DIR/$TEMP_DIR
cd $SOURCE_DIR
echo "********************************"
echo " Package: $APP_NAME"
echo " Version: $APP_VERSION"
echo "********************************"
echo "[*] Remove temp dir: $TEMP_DIR"
rm -rf $TEMP_DIR
echo "[*] Create temp directories"
mkdir $TEMP_DIR
mkdir -p $TEMP_DIR/$OUTPUT_DIR
mkdir -p $TEMP_DIR/$RPM_TEMP_DIR
echo "[*] Create source archive: $SOURCE_ARCHIVE"
tar -zcf $TEMP_DIR/$SOURCE_ARCHIVE $APP_FILES
echo "[*] Create orign archive: $SOURCE_ARCHIVE_ORIG"
cp $TEMP_DIR/$SOURCE_ARCHIVE $TEMP_DIR/$SOURCE_ARCHIVE_ORIG
echo "[*] Create application directory: $APP_DIR_NAME"
mkdir $TEMP_DIR/$APP_DIR_NAME
echo "[*] Copy files to application dir"
cp -fr $APP_FILES debian .git $TEMP_DIR/$APP_DIR_NAME
echo "[*] Enter application directory"
cd $TEMP_DIR/$APP_DIR_NAME
echo "[*] Start building deb"
if [ -n $WORKSPACE ];
then
debuild -us -uc
else
debuild
fi
cd $TEMP_DIR_PATH
echo "[*] Convert to rpm"
cd $RPM_TEMP_DIR
fakeroot alien --to-rpm ../*.deb
cd $TEMP_DIR_PATH
cp *.deb $OUTPUT_DIR
cp $RPM_TEMP_DIR/*.rpm $OUTPUT_DIR
echo "[*] Create archives"
cd $TEMP_DIR_PATH/$APP_DIR_NAME/debian/moltaqa-lib/
mv -v usr $APP_DIR_NAME
cp -v $TEMP_DIR_PATH/$APP_DIR_NAME/bin/moltaqa-lib.run $APP_DIR_NAME/bin
tar -zcf $TEMP_DIR_PATH/$OUTPUT_DIR/$APP_DIR_NAME.tar.gz $APP_DIR_NAME
#tar -jcf $TEMP_DIR_PATH/$OUTPUT_DIR/$APP_DIR_NAME.tar.bz2 *
echo "[*] Rename files"
cd $TEMP_DIR_PATH/$OUTPUT_DIR
mv -v *.deb "$APP_DIR_NAME.deb"
mv -v *.rpm "$APP_DIR_NAME.rpm"
echo "[*] Create md5 sums"
md5sum -b * > MD5SUMS
mkdir -p "$SOURCE_DIR/$OUTPUT_DIR/$APP_DIR_NAME"
cp -rv $TEMP_DIR_PATH/$OUTPUT_DIR/* "$SOURCE_DIR/$OUTPUT_DIR/$APP_DIR_NAME"
echo "[*] Generated files in $SOURCE_DIR/$OUTPUT_DIR/$APP_DIR_NAME"
cat $SOURCE_DIR/$OUTPUT_DIR/$APP_DIR_NAME/MD5SUMS
echo "[*] Remove build directory"
cd $SOURCE_DIR
rm -fr $TEMP_DIR
echo "[*] Done"