aboutsummaryrefslogtreecommitdiff
path: root/appimage/make-dist.sh
blob: bd637278578bedc9933878c94c1a3a9f3951f7f3 (plain)
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash

#APP_VER=0.0.1
APP_NAME=qtmips
SRC_DIR=/home/fanda/proj/qtmips
QT_DIR=/home/fanda/programs/qt5/5.14.1/gcc_64
WORK_DIR=/tmp/_distro/qtmips

APP_IMAGE_TOOL=/home/fanda/programs/appimagetool-x86_64.AppImage

help() {
	echo "Usage: make-dist.sh [ options ... ]"
	echo "required options: src-dir, qt-dir, work-dir, image-tool"
	echo -e "\n"
	echo "avaible options"
	echo "    --app-name <name>        custom application name, ie: my-qe-test"
	echo "    --app-version <version>  application version, ie: 1.0.0"
	echo "    --src-dir <path>         quickbox project root dir, *.pro file is located, ie: /home/me/quickbox"
	echo "    --qt-dir <path>          QT dir, ie: /home/me/qt5/5.13.1/gcc_64"
	echo "    --work-dir <path>        directory where build files and AppImage will be created, ie: /home/me/quickevent/AppImage"
	echo "    --image-tool <path>      path to AppImageTool, ie: /home/me/appimagetool-x86_64.AppImage"
	echo "    --no-clean               do not rebuild whole project when set to 1"
	echo -e "\n"
	echo "example: make-dist.sh --src-dir /home/me/qtmips --qt-dir /home/me/qt5/5.13.1/gcc_64 --work-dir /home/me/qtmips/AppImage --image-tool /home/me/appimagetool-x86_64.AppImage"
	exit 0
}

error() {
	echo -e "\e[31m${1}\e[0m"
}

while [[ $# -gt 0 ]]
do
key="$1"
# echo key: $key
case $key in
	--app-name)
	APP_NAME="$2"
	shift # past argument
	shift # past value
	;;
	--app-version)
	APP_VER="$2"
	shift # past argument
	shift # past value
	;;
	--qt-dir)
	QT_DIR="$2"
	shift # past argument
	shift # past value
	;;
	--src-dir)
	SRC_DIR="$2"
	shift # past argument
	shift # past value
	;;
	--work-dir)
	WORK_DIR="$2"
	shift # past argument
	shift # past value
	;;
	--image-tool)
	APP_IMAGE_TOOL="$2"
	shift # past argument
	shift # past value
	;;
	--no-clean)
	NO_CLEAN=1
	shift # past value
	;;
	-h|--help)
	shift # past value
	help
	;;
	*)    # unknown option
	echo "ignoring argument $1"
	shift # past argument
	;;
esac
done

if [ ! -d $SRC_DIR ]; then
   	error "invalid source dir, use --src-dir <path> to specify it\n"
	help
fi
if [ ! -d $QT_DIR ]; then
	error "invalid QT dir, use --qt-dir <path> to specify it\n"
	help
fi
if [ ! -f $APP_IMAGE_TOOL ]; then
	error "invalid path to AppImageTool, use --image=tool <path> to specify it\n"
	help
fi
if [ ! -x $APP_IMAGE_TOOL ]; then
	error "AppImageTool file must be executable, use chmod +x $APP_IMAGE_TOOL\n"
	help
fi


if [ -z $APP_VER ]; then
	APP_VER=`grep APP_VERSION $SRC_DIR/quickevent/app/quickevent/src/appversion.h | cut -d\" -f2`
	echo "Distro version not specified, deduced from source code: $APP_VER" >&2
	#exit 1
fi

echo APP_VER: $APP_VER
echo APP_NAME: $APP_NAME
echo SRC_DIR: $SRC_DIR
echo WORK_DIR: $WORK_DIR
echo NO_CLEAN: $NO_CLEAN

if [ -z $USE_SYSTEM_QT ]; then
	QT_LIB_DIR=$QT_DIR/lib
	QMAKE=$QT_DIR/bin/qmake
	DISTRO_NAME=$APP_NAME-$APP_VER-linux64
else
	QT_DIR=/usr/lib/i386-linux-gnu/qt5
	QT_LIB_DIR=/usr/lib/i386-linux-gnu
	QMAKE=/usr/bin/qmake
	DISTRO_NAME=$APP_NAME-$APP_VER-linux32
fi

echo QT_DIR: $QT_DIR

BUILD_DIR=$WORK_DIR/_build
DIST_DIR=$WORK_DIR/$DISTRO_NAME
DIST_LIB_DIR=$DIST_DIR/lib
DIST_BIN_DIR=$DIST_DIR/bin

if [ -z $NO_CLEAN ]; then
	echo removing directory $WORK_DIR
	rm -r $BUILD_DIR
	mkdir -p $BUILD_DIR
fi

cd $BUILD_DIR
$QMAKE $SRC_DIR/qtmips.pro CONFIG+=release CONFIG+=force_debug_info CONFIG+=separate_debug_info -r -spec linux-g++
make -j8
if [ $? -ne 0 ]; then
	echo "Make Error" >&2
	exit 1
fi

rm -r $DIST_DIR
mkdir -p $DIST_DIR

# rsync -av --exclude '*.debug' $BUILD_DIR/lib/ $DIST_LIB_DIR
# echo rsync -av $BUILD_DIR/qtmips_gui/qtmips_gui $DIST_BIN_DIR
rsync -av $BUILD_DIR/qtmips_gui/qtmips_gui $DIST_BIN_DIR/

#rsync -a --exclude '*.debug'v $QT_DIR/lib/libicu* $DIST_LIB_DIR

rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5Core.so* $DIST_LIB_DIR
rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5Gui.so* $DIST_LIB_DIR
rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5Widgets.so* $DIST_LIB_DIR
rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5XmlPatterns.so* $DIST_LIB_DIR
rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5Network.so* $DIST_LIB_DIR
rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5Sql.so* $DIST_LIB_DIR
rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5Xml.so* $DIST_LIB_DIR
rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5Qml.so* $DIST_LIB_DIR
# rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5Quick.so* $DIST_LIB_DIR
rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5Svg.so* $DIST_LIB_DIR
# rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5Script.so* $DIST_LIB_DIR
# rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5ScriptTools.so* $DIST_LIB_DIR
rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5PrintSupport.so* $DIST_LIB_DIR
# rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5SerialPort.so* $DIST_LIB_DIR
rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5DBus.so* $DIST_LIB_DIR
# rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5Multimedia.so* $DIST_LIB_DIR
rsync -av --exclude '*.debug' $QT_LIB_DIR/libQt5XcbQpa.so* $DIST_LIB_DIR

rsync -av --exclude '*.debug' $QT_LIB_DIR/libicu*.so* $DIST_LIB_DIR

rsync -av --exclude '*.debug' $QT_DIR/plugins/platforms/ $DIST_BIN_DIR/platforms
rsync -av --exclude '*.debug' $QT_DIR/plugins/printsupport/ $DIST_BIN_DIR/printsupport

mkdir -p $DIST_BIN_DIR/imageformats
rsync -av --exclude '*.debug' $QT_DIR/plugins/imageformats/libqjpeg.so $DIST_BIN_DIR/imageformats/
rsync -av --exclude '*.debug' $QT_DIR/plugins/imageformats/libqsvg.so $DIST_BIN_DIR/imageformats/

# mkdir -p $DIST_BIN_DIR/sqldrivers
# rsync -av --exclude '*.debug' $QT_DIR/plugins/sqldrivers/libqsqlite.so $DIST_BIN_DIR/sqldrivers/
# rsync -av --exclude '*.debug' $QT_DIR/plugins/sqldrivers/libqsqlpsql.so $DIST_BIN_DIR/sqldrivers/

# mkdir -p $DIST_BIN_DIR/audio
# rsync -av --exclude '*.debug' $QT_DIR/plugins/audio/ $DIST_BIN_DIR/audio/

# mkdir -p $DIST_BIN_DIR/QtQuick/Window.2
# rsync -av --exclude '*.debug' $QT_DIR/qml/QtQuick/Window.2/ $DIST_BIN_DIR/QtQuick/Window.2
# rsync -av --exclude '*.debug' $QT_DIR/qml/QtQuick.2/ $DIST_BIN_DIR/QtQuick.2

# tar -cvzf $WORK_DIR/$DISTRO_NAME.tgz  -C $WORK_DIR ./$DISTRO_NAME

rsync -av $SRC_DIR/appimage/QtMips.AppDir/* $DIST_DIR/

ARCH=x86_64 $APP_IMAGE_TOOL $DIST_DIR $WORK_DIR/$APP_NAME-${APP_VER}-x86_64.AppImage