Clean up Linux build scripts

This commit is contained in:
Phil Olynyk 2020-05-04 13:20:33 -04:00
parent 23d177b31c
commit 808b8931b1
8 changed files with 236 additions and 68 deletions

0
Building/Linux/OSCAR.desktop Executable file → Normal file
View File

View File

@ -4,8 +4,10 @@ you have already compiled and linked OSCAR using qmake and make, or QtCreator.
The packages, once built, can be installed using 'dpkg i' or 'gdebi' - with either su or sudo. If you use
sudo, you will get a desktop icon installed, which must be double-clicked and trusted to see the actual icon.
The packaged file cannot be installed using apt, apt-get, or aptitude, because those programs
install from the distribution repository, but not a plan package file.
The packaged file cannot be installed using apt-get, or aptitude, because those programs
install from the distribution repository, but not a plain package file.
The package can be installed with apt or apt -F if the file name is preceded by ./ to force filename recognition.
The packaging scripts assume the following folder structure:
@ -22,6 +24,9 @@ The code to put a desktop icon in the Desktop folder, regardless of language, wa
Getting a menu item istalled is largely due to the efforts of CrimsonNape.
The mkDebian9.sh and mkUbuntu.sh scripts have been consolidated into mkDistDeb.sh and are now depreciated and will be removed. mkDistDeb.sh
has code to query which packages are available for certail libraries.
Finally, the mkRedHat.sh script has not been tested.

View File

@ -10,32 +10,32 @@ appli_name="OSCAR-test"
# binary copy flag
copy_flag=0
# Select the binary file for the goog version of QT (5.7 ou 5.9)
#echo "test the version of qt5 core version"
#### Select the binary file for the goog version of QT (5.7 ou 5.9)
####echo "test the version of qt5 core version"
###
###if [ -f "/etc/redhat-release" ]; then
### # pour mageia (red hat)
### echo "distribution : mageia (red hat)"
### Qt5_core=$(yum search -q qt5core5 | awk '{print $1}' | grep lib | sort -u)
### MajorVer_no=$(yum info $Qt5_core | grep -i "version" | awk '{print $3}' | awk -F. '{print $1}')
### MinorVer_no=$(yum info $Qt5_core | grep -i "version" | awk '{print $3}' | awk -F. '{print $2}')
###
###elif [ -f "/etc/lsb-release" ] || [ -f "/etc/debian_version" ]; then
### # pour debian
#### echo "distribution : debian"
### Qt5_core=$(dpkg -l | awk '{print $2}'| grep qt5 | grep core | awk -F: '{print $1}')
### Major_ver=$(dpkg -l | grep $Qt5_core | awk '{print $3}' | awk -F. '{print $1}')
### Minor_ver=$(dpkg -l | grep $Qt5_core | awk '{print $3}' | awk -F. '{print $2}')
###else
### echo "unknown distribution "
### exit
###fi
###
####echo "Qt5_core = '$Qt5_core'"
####echo "Major_ver = $Major_ver"
####echo "Minor_ver = $Minor_ver"
if [ -f "/etc/redhat-release" ]; then
# pour mageia (red hat)
echo "distribution : mageia (red hat)"
Qt5_core=$(yum search -q qt5core5 | awk '{print $1}' | grep lib | sort -u)
MajorVer_no=$(yum info $Qt5_core | grep -i "version" | awk '{print $3}' | awk -F. '{print $1}')
MinorVer_no=$(yum info $Qt5_core | grep -i "version" | awk '{print $3}' | awk -F. '{print $2}')
elif [ -f "/etc/lsb-release" ] || [ -f "/etc/debian_version" ]; then
# pour debian
# echo "distribution : debian"
Qt5_core=$(dpkg -l | awk '{print $2}'| grep qt5 | grep core | awk -F: '{print $1}')
Major_ver=$(dpkg -l | grep $Qt5_core | awk '{print $3}' | awk -F. '{print $1}')
Minor_ver=$(dpkg -l | grep $Qt5_core | awk '{print $3}' | awk -F. '{print $2}')
else
echo "unknown distribution "
exit
fi
#echo "Qt5_core = '$Qt5_core'"
#echo "Major_ver = $Major_ver"
#echo "Minor_ver = $Minor_ver"
if [ -x /usr/bin/update-menus ]; then update-menus; fi
##if [ -x /usr/bin/update-menus ]; then update-menus; fi
if [ ! -z "$SUDO_USER" ]; then
# find real name of the Desktop folder (Bureau for xubuntu french version)

View File

@ -10,38 +10,38 @@ appli_name="OSCAR"
# binary copy flag
copy_flag=0
# Select the binary file for the goog version of QT (5.7 ou 5.9)
echo "test the version of qt5 core version"
#### Select the binary file for the goog version of QT (5.7 ou 5.9)
###echo "test the version of qt5 core version"
###
###if [ -f "/etc/redhat-release" ]; then
### # pour mageia (red hat)
### echo "distribution : mageia (red hat)"
### nom_core=$(yum search -q qt5core5 | awk '{print $1}' | grep lib | sort -u)
### no_vermaj=$(yum info $nom_core | grep -i "version" | awk '{print $3}' | awk -F. '{print $1}')
### no_vermin=$(yum info $nom_core | grep -i "version" | awk '{print $3}' | awk -F. '{print $2}')
###
###elif [ -f "/etc/lsb-release" ] || [ -f "/etc/debian_version" ]; then
### # pour debian
### echo "distribution : debian"
### nom_core=$(dpkg -l | awk '{print $2}'| grep qt5 | grep core | awk -F: '{print $1}')
### no_vermaj=$(dpkg -l | grep $nom_core | awk '{print $3}' | awk -F. '{print $1}')
### no_vermin=$(dpkg -l | grep $nom_core | awk '{print $3}' | awk -F. '{print $2}')
###else
### echo "unknown distribution "
### exit
###fi
###
###echo "QT5_core = '$nom_core'"
###echo "Major ver = $no_vermaj"
###echo "Minor ver = $no_vermin"
if [ -f "/etc/redhat-release" ]; then
# pour mageia (red hat)
echo "distribution : mageia (red hat)"
nom_core=$(yum search -q qt5core5 | awk '{print $1}' | grep lib | sort -u)
no_vermaj=$(yum info $nom_core | grep -i "version" | awk '{print $3}' | awk -F. '{print $1}')
no_vermin=$(yum info $nom_core | grep -i "version" | awk '{print $3}' | awk -F. '{print $2}')
elif [ -f "/etc/lsb-release" ] || [ -f "/etc/debian_version" ]; then
# pour debian
echo "distribution : debian"
nom_core=$(dpkg -l | awk '{print $2}'| grep qt5 | grep core | awk -F: '{print $1}')
no_vermaj=$(dpkg -l | grep $nom_core | awk '{print $3}' | awk -F. '{print $1}')
no_vermin=$(dpkg -l | grep $nom_core | awk '{print $3}' | awk -F. '{print $2}')
else
echo "unknown distribution "
exit
fi
echo "QT5_core = '$nom_core'"
echo "Major ver = $no_vermaj"
echo "Minor ver = $no_vermin"
if [ -x /usr/bin/update-menus ]; then update-menus; fi
##if [ -x /usr/bin/update-menus ]; then update-menus; fi
if [ X_$SUDO_USER != "X_" ]; then
# find real name of the Desktop folder (Bureau for xubuntu french version)
desktop_folder_name="/home/$SUDO_USER/Desktop"
# si doesn't exist, try to find it translated name
# if doesn't exist, try to find it translated name
tmp_dir=""
if [ ! -d "$desktop_folder_name" ]; then
tmp_dir=`cat /home/$SUDO_USER/.config/user-dirs.dirs | grep XDG_DESKTOP_DIR | awk -F= '{print $2}' | awk -F\" '{print $2}' | awk -F\/ '{print $2}'`

View File

@ -1,8 +0,0 @@
#! /bin/bash
#
mv /opt/tempDir /opt/OSCAR
ln -s /opt/OSCAR/OSCAR /usr/bin/OSCAR
cp /opt/OSCAR/OSCAR.desktop /home/$SUDO_USER/Desktop
chown $SUDO_USER:$SUDO_USER /home/$SUDO_USER/Desktop/OSCAR.desktop
chmod a+x /home/$SUDO_USER/Desktop/OSCAR.desktop
#

View File

@ -30,7 +30,7 @@ pre_rem="rm_usrbin.sh"
post_rem="clean_rm.sh"
# build folder (absolute path is better)
build_folder="/home/$USER/OSCAR/build"
if [[ -n ${PRERELEASE} && ${RC} ]] ; then
if [[ -n ${PRERELEASE} && -z ${RC} ]] ; then
appli_name=${appli_name}-test
post_inst="ln_usrbin-test.sh"
pre_rem="rm_usrbin-test.sh"

177
Building/Linux/mkDistDeb.sh Executable file
View File

@ -0,0 +1,177 @@
#! /bin/bash
# First parameter is optional
#
function getPkg () {
unset PKGNAME
unset PKGVERS
while read stat pkg ver other ;
do
if [[ ${stat} == "ii" ]] ; then
PKGNAME=`awk -F: '{print $1}' <<< ${pkg}`
PKGVERS=`awk -F. '{print $1 "." $2}' <<< ${ver}`
break
fi ;
done <<< $(dpkg -l | grep $1)
}
ITERATION=$1
if [ -z ${ITERATION} ]; then
ITERATION="1"
fi
SRC=/home/$USER/OSCAR/OSCAR-code/oscar
VERSION=`awk '/#define VERSION / { gsub(/"/, "", $3); print $3 }' ${SRC}/VERSION`
if [[ ${VERSION} == *-* ]]; then
# Use ~ for prerelease information so that it sorts correctly compared to release
# versions. See https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
IFS="-" read -r VERSION PRERELEASE <<< ${VERSION}
if [[ ${PRERELEASE} == *rc* ]]; then
RC=1
fi
VERSION="${VERSION}~${PRERELEASE}"
fi
GIT_REVISION=`awk '/#define GIT_REVISION / { gsub(/"/, "", $3); print $3 }' ${SRC}/git_info.h`
echo Version: ${VERSION}
# application name
appli_name="OSCAR"
pre_inst="tst_user.sh"
post_inst="ln_usrbin.sh"
pre_rem="rm_usrbin.sh"
post_rem="clean_rm.sh"
# build folder (absolute path is better)
build_folder="/home/$USER/OSCAR/build"
if [[ -n ${PRERELEASE} && -z ${RC} ]] ; then
appli_name=${appli_name}-test
post_inst="ln_usrbin-test.sh"
pre_rem="rm_usrbin-test.sh"
post_rem="clean_rm-test.sh"
fi
# temporary folder (absolute path is better)
temp_folder="/home/$USER/tmp_deb_${appli_name}/"
# destination folder in the .deb file
dest_folder="/usr/"
# the .deb file mustn't exist (or fpm must have -f parameter to force the creation)
archi_tmp=$(lscpu | grep -i architecture | awk -F: {'print $2'} | tr -d " ")
if [ "$archi_tmp" = "x86_64" ];then
archi="amd64"
else
archi="unknown"
fi
deb_file="${appli_name}_${VERSION}-${ITERATION}_$archi.deb"
getPkg libqt5core
qtver=$PKGVERS
getPkg libdouble
dblPkg=$PKGNAME
echo "QT version " $qtver
echo "DblConv package " $dblPkg
# if deb file exists, fatal error
if [ -f "./$deb_file" ]; then
echo "destination file (./$deb_file) exists. fatal error"
exit
fi
# clean folders need to create the package
if [ -d "${temp_folder}" ]; then
rm -r ${temp_folder}
fi
mkdir ${temp_folder}
if [ ! -d "${temp_folder}" ]; then
echo "Folder (${temp_folder}) not created : fatal error."
exit
fi
chmod 0755 ${temp_folder}
# save current value of umask (for u=g and not g=o)
current_value=$(umask)
umask 022
mkdir ${temp_folder}/bin
mkdir ${temp_folder}/share
mkdir ${temp_folder}/share/${appli_name}
mkdir ${temp_folder}/share/doc
share_doc_folder="${temp_folder}/share/doc/${appli_name}"
mkdir ${share_doc_folder}
mkdir ${temp_folder}/share/icons
mkdir ${temp_folder}/share/icons/hicolor
mkdir ${temp_folder}/share/icons/hicolor/48x48
mkdir ${temp_folder}/share/icons/hicolor/48x48/apps
mkdir ${temp_folder}/share/icons/hicolor/scalable
mkdir ${temp_folder}/share/icons/hicolor/scalable/apps
mkdir ${temp_folder}/share/applications
# must delete debug symbol in OSCAR binary file
# --- V1
strip -s -o ${temp_folder}/bin/${appli_name} ${build_folder}/oscar/OSCAR
#old code : cp ${build_folder}/oscar/OSCAR ${temp_folder}/bin
# 2>/dev/null : errors does not appear : we don't care about them
cp -r ${build_folder}/oscar/Help ${temp_folder}/share/${appli_name} 2>/dev/null
cp -r ${build_folder}/oscar/Html ${temp_folder}/share/${appli_name} 2>/dev/null
cp -r ${build_folder}/oscar/Translations ${temp_folder}/share/${appli_name} 2>/dev/null
cp ./${appli_name}.png ${temp_folder}/share/icons/hicolor/48x48/apps/${appli_name}.png
cp ./${appli_name}.svg ${temp_folder}/share/icons/hicolor/scalable/apps/${appli_name}.svg
cp ./${appli_name}.desktop ${temp_folder}/share/applications/${appli_name}.desktop
echo "Copyright 2019-2020 oscar-team.org <oscar@oscar-team.org>" > $share_doc_folder/copyright
changelog_file="$share_doc_folder/changelog"
#automatic changelog as a bad name
# need to generate one and say fpm to use it instead of create one
# it seems that it needs both of them...
# creation of the changelog.Debian.gz
echo "$appli_name (${VERSION}-${ITERATION}) whatever; urgency=medium" > $changelog_file
echo "" >> $changelog_file
echo " * Package created with FPM." >> $changelog_file
echo "" >> $changelog_file
echo " -- oscar-team.org <oscar@oscar-team.org>" >> $changelog_file
gzip --best $changelog_file
description='Open Source CPAP Analysis Reporter\n<extended description needed to be filled with the right value>'
# trick for dummies : need to use echo -e to take care of \n (cariage return to slip description and extra one
description=$(echo -e $description)
# restore umask value
umask $current_value
# create the .deb file (litian test show juste a warning with a man that doesn't exists : don't care about that)
fpm --input-type dir --output-type deb \
--prefix ${dest_folder} \
--before-install ${pre_inst} \
--after-install ${post_inst} \
--before-remove ${pre_rem} \
--after-remove ${post_rem} \
--name ${appli_name} --version ${VERSION} --iteration ${ITERATION} \
--category misc \
--deb-priority optional \
--maintainer " -- oscar-team.org <oscar@oscar-team.org>" \
--license GPL-v3 \
--vendor oscar-team.org \
--description "$description" \
--url https://sleepfiles.com/OSCAR \
--deb-no-default-config-files \
--depends $dblPkg \
--depends libpcre16-3 \
--depends qttranslations5-l10n \
--depends 'libqt5core5a > $qtver' \
--depends libqt5serialport5 \
--depends libqt5xml5 \
--depends libqt5network5 \
--depends libqt5gui5 \
--depends libqt5widgets5 \
--depends libqt5opengl5 \
--depends libqt5printsupport5 \
--depends libglu1-mesa \
--depends libgl1 \
--depends libc6 \
--no-deb-generate-changes \
-C ${temp_folder} \
.

View File

@ -1,6 +0,0 @@
#! /bin/bash
#
mv /opt/OSCAR /opt/tempDir
rm /usr/bin/OSCAR
rm /home/$SUDO_USER/Desktop/OSCAR.desktop
#