aboutsummaryrefslogtreecommitdiffstats
path: root/build_linux.sh
blob: c02b73193edb6caee18bb0b4279672746ae5c199 (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
#!/usr/bin/env bash
# Copyright (C) 2022 The Qt Company Ltd.
#
# SPDX-License-Identifier: GPL-3.0-only WITH Qt-GPL-exception-1.0
#


name=licd
deploy_dir=deploy
INSTALL=false

function exit_fail {
    echo "ERROR! $1: Aborting installation"
    exit 1
}

function helptext {
    echo "Supported CLI arguments:"
    echo " --install  :  Install and run daemon after building"
    echo " --help     :  This help"
}

# Read command line options
function parse_cli_arguments {
    ret=0
    for arg in "$@"
    do
        case ${arg} in
        --install)
            INSTALL=true
          ;;
        --help)
            helptext
            exit 0
            ;;
        *)
            echo "Invalid CLI argument ${arg} given"
            helptext
            exit 1
            ;;
        esac
    done

    return ${ret}
}

parse_cli_arguments "$@"

# Create build dir (if not there)
mkdir -p build
if [ $? != 0 ]; then
    exit_fail "Failed to create build dir"
fi
cd build

# build
cmake ..
if [ $? != 0 ]; then
    exit_fail "Cmake failed"
fi

make clean
make
if [ $? != 0 ]; then
    exit_fail "Build failed"
fi

chmod +x ${name} licheck qtlicensetool/qtlicensetool mocwrapper/mocwrapper
cd ..
# Copy files for deployment dir (first create it)
mkdir -p ${deploy_dir}
if [ $? != 0 ]; then
    exit_fail "Failed to create deploy dir"
fi

cp build/${name} ${deploy_dir}/
cp build/licheck ${deploy_dir}/
cp build/qtlicensetool/qtlicensetool ${deploy_dir}/
cp build/mocwrapper/mocwrapper ${deploy_dir}/
cp ${name}.ini ${deploy_dir}/
cp linux_service_scripts/${name}.service ${deploy_dir}/
cp linux_service_scripts/installer.sh ${deploy_dir}/
cp linux_service_scripts/uninstaller.sh ${deploy_dir}/

#
# Install & start the daemon
#
if [ "${INSTALL}" == true ]; then
    cd ${deploy_dir}
    echo "Installing.... Need to be root"
    sudo sh installer.sh
fi

echo "Done."