66set -e
77# set -v
88
9- APT=
9+ PACKAGE_TOOL=apt
10+ PACKAGE=
1011APT_UPDATE=0
1112BASE_LIBS=0
1213DEFAULT_LIBS=0
1314QT=0
1415RabbitCommon=0
1516
1617usage_long () {
17- echo " $0 [--install=<install directory>] [--source=<source directory>] [--tools=<tools directory>] [--build=<build directory>] [--apt =<'lib1 lib2 ...'>] [--apt_update=[0|1]] [--base[=0|1]] [--default[=0|1]] [--qt[=0|1]] [--rabbitcommon[=0|1]]"
18+ echo " $0 [--install=<install directory>] [--source=<source directory>] [--tools=<tools directory>] [--build=<build directory>] [--package =<'package1 package2 ...'>] [--package-tool=<apt|dnf >] [--apt_update=[0|1]] [--base[=0|1]] [--default[=0|1]] [--qt[=0|1]] [--rabbitcommon[=0|1]]"
1819 echo " Directory:"
1920 echo " --install: Set install directory"
2021 echo " --source: Set source directory"
@@ -24,27 +25,12 @@ usage_long() {
2425 echo " --base: Install the base libraries with apt"
2526 echo " --default: Install the default dependency libraries that comes with the system"
2627 echo " --apt_update: Update system"
27- echo " --apt: Install package with apt"
28+ echo " --package-tool: Package install tool, apk or dnf"
29+ echo " --package: Install package"
2830 echo " --qt: Install QT"
2931 echo " --rabbitcommon: Install RabbitCommon"
3032}
3133
32- usage () {
33- echo " $0 [-i <install directory>] [-s <source directory>] [-t <tools directory>] [-b <build directory>] [-a <'lib1 lib2 ...'>] [apt_update] [base] [default] [qt] [rabbitcommon]"
34- echo " Directory:"
35- echo " -i: Set install directory"
36- echo " -s: Set source directory"
37- echo " -t: Set tools directory"
38- echo " -b: set build directory"
39- echo " Depend:"
40- echo " base: Install then base libraries with apt"
41- echo " default: Install the default dependency libraries that comes with the system"
42- echo " apt_update: Update system"
43- echo " -a: Install package with apt"
44- echo " qt: Install QT"
45- echo " rabbitcommon: Install RabbitCommon"
46- }
47-
4834# [如何使用getopt和getopts命令解析命令行选项和参数](https://zhuanlan.zhihu.com/p/673908518)
4935# [【Linux】Shell命令 getopts/getopt用法详解](https://blog.csdn.net/arpospf/article/details/103381621)
5036if command -V getopt > /dev/null; then
@@ -55,7 +41,7 @@ if command -V getopt >/dev/null; then
5541 # 后面没有冒号表示没有参数。后跟有一个冒号表示有参数。跟两个冒号表示有可选参数。
5642 # -l 或 --long 选项后面是可接受的长选项,用逗号分开,冒号的意义同短选项。
5743 # -n 选项后接选项解析错误时提示的脚本名字
58- OPTS=help,install:,source:,tools:,build:,apt :,apt_update::,base::,default::,qt::,rabbitcommon::
44+ OPTS=help,install:,source:,tools:,build:,package:,package-tool :,apt_update::,base::,default::,qt::,rabbitcommon::
5945 ARGS=` getopt -o h -l $OPTS -n $( basename $0 ) -- " $@ " `
6046 if [ $? != 0 ]; then
6147 echo " exec getopt fail: $? "
@@ -87,8 +73,12 @@ if command -V getopt >/dev/null; then
8773 BUILD_DIR=$2
8874 shift 2
8975 ;;
90- --apt)
91- APT=$2
76+ --package)
77+ PACKAGE=$2
78+ shift 2
79+ ;;
80+ --package-tool)
81+ PACKAGE_TOOL=$2
9282 shift 2
9383 ;;
9484 --apt_update)
@@ -150,30 +140,6 @@ if command -V getopt >/dev/null; then
150140 ;;
151141 esac
152142 done
153- else
154- echo " getopt is not exits"
155- if [ $# -eq 0 ]; then
156- usage
157- else
158- for i in " $@ " ; do
159- case " $i " in
160- " apt_update" ) APT_UPDATE=1;;
161- " base" ) BASE_LIBS=1;;
162- " default" ) DEFAULT_LIBS=1;;
163- " qt" ) QT=1;;
164- " rabbitcommon" ) RabbitCommon=1;;
165- esac
166- done
167- while getopts :i:s:t: opt; do
168- case $opt in
169- i) INSTALL_DIR=$OPTARG ;;
170- s) SOURCE_DIR=$OPTARG ;;
171- t) TOOLS_DIR=$OPTARG ;;
172- b) BUILD_DIR=$OPTARG ;;
173- a) APT=$OPTARG ;;
174- esac
175- done
176- fi
177143fi
178144
179145# store repo root as variable
@@ -220,34 +186,49 @@ if [ $APT_UPDATE -eq 1 ]; then
220186 apt-get upgrade -y
221187fi
222188
223- if [ -n " $APT " ]; then
224- apt install -y -q $APT
189+ if [ -n " $PACKAGE " ]; then
190+ ${PACKAGE_TOOL} install -y -q $PACKAGE
225191fi
226192
227193if [ $BASE_LIBS -eq 1 ]; then
228194 echo " Install base libraries ......"
229- apt install -y -q build-essential \
230- git cmake gcc g++ debhelper fakeroot graphviz gettext \
231- xserver-xorg-input-mouse xserver-xorg-input-kbd \
232- libglu1-mesa-dev libpulse-mainloop-glib0
233- if [ -z " $SerialPortAssistant_VERSION " ]; then
234- apt install -y -q xvfb xpra
195+ if [ " $PACKAGE_TOOL " = " apt" ]; then
196+ apt install -y -q build-essential \
197+ git cmake gcc g++ debhelper fakeroot graphviz gettext \
198+ xserver-xorg-input-mouse xserver-xorg-input-kbd \
199+ libglu1-mesa-dev libpulse-mainloop-glib0
200+ if [ -z " $SerialPortAssistant_VERSION " ]; then
201+ apt install -y -q xvfb xpra
202+ fi
203+ # Base dependency
204+ apt install -y -q libssl-dev libcrypt-dev libicu-dev zlib1g-dev
205+ # RabbitCommon dependency
206+ apt install -y -q libcmark-dev cmark
207+ # AppImage
208+ apt install -y -q libfuse-dev libfuse3-dev
209+ fi
210+
211+ if [ " $PACKAGE_TOOL " = " dnf" ]; then
212+ dnf install -y make git rpm-build rpmdevtools gcc-c++ util-linux \
213+ automake autoconf libtool gettext gettext-autopoint \
214+ cmake desktop-file-utils appstream appstream-util curl wget
235215 fi
236- # Base dependency
237- apt install -y -q libssl-dev libcrypt-dev libicu-dev zlib1g-dev
238- # RabbitCommon dependency
239- apt install -y -q libcmark-dev cmark
240- # AppImage
241- apt install -y -q libfuse-dev libfuse3-dev
242216fi
243217
244218if [ $DEFAULT_LIBS -eq 1 ]; then
245219 echo " Install default dependency libraries ......"
246- # Qt6
247- apt-get install -y -q qmake6 qt6-tools-dev qt6-tools-dev-tools \
248- qt6-base-dev qt6-base-dev-tools qt6-qpa-plugins \
249- libqt6svg6-dev qt6-l10n-tools qt6-translations-l10n \
250- qt6-scxml-dev qt6-multimedia-dev libqt6serialport6-dev
220+ if [ " $PACKAGE_TOOL " = " apt" ]; then
221+ # Qt6
222+ apt-get install -y -q qmake6 qt6-tools-dev qt6-tools-dev-tools \
223+ qt6-base-dev qt6-base-dev-tools qt6-qpa-plugins \
224+ libqt6svg6-dev qt6-l10n-tools qt6-translations-l10n \
225+ qt6-scxml-dev qt6-multimedia-dev libqt6serialport6-dev
226+ fi
227+ if [ " $PACKAGE_TOOL " = " dnf" ]; then
228+ dnf install -y qt6-qttools-devel qt6-qtbase-devel qt6-qtmultimedia-devel \
229+ qt6-qt5compat-devel qt6-qtmultimedia-devel qt6-qtscxml-devel \
230+ qt6-qtserialport-devel qt6-qtsvg-devel
231+ fi
251232fi
252233
253234if [ $QT -eq 1 ]; then
@@ -272,6 +253,10 @@ if [ $RabbitCommon -eq 1 ]; then
272253 pushd " $SOURCE_DIR "
273254 if [ ! -d RabbitCommon ]; then
274255 git clone https://github.com/KangLin/RabbitCommon.git
256+ else
257+ cd RabbitCommon
258+ git pull
259+ cd ..
275260 fi
276261 popd
277262fi
0 commit comments