File: setup-linux-dev-env.sh

package info (click to toggle)
passwordsafe 1.12.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 25,980 kB
  • sloc: cpp: 67,939; ansic: 1,696; makefile: 584; perl: 459; sh: 240; xml: 210; javascript: 40
file content (91 lines) | stat: -rwxr-xr-x 3,081 bytes parent folder | download
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
#!/bin/sh
# Silly script to setup the development pre-requisites for
# building PasswordSafe on Debian and RPM-based distros.
# Meant to be run as root or sudo'd
# Running this after cloning the git repo (or unpacking the sources)
# and you should be all set.
#
# Upgrade to this inspired by a similar script by kreyren
#
# Command overrides
if [ -z "$UNAME" ]; then
    UNAME="/usr/bin/uname"
    [ ! -x "$UNAME" ] && UNAME="/bin/uname"
fi
[ -z "$LSB_RELEASE" ] && LSB_RELEASE="/usr/bin/lsb_release"

die() {
    echo "$2"
    exit "$1"
}

# Exit on anything unexpected
set -e

# Check if we're effectively root
if [ ! "$(id -u)" = 0 ]; then
    die 1 "Run as root or under sudo"
fi

# See if we're Linux by checking the kernel
if command -v $UNAME 1>/dev/null; then
	KERNEL="$($UNAME -s)"
else
    die 2 "Could not find uname command, can't identify kernel"
fi

if [ "$KERNEL" = "Linux" ]; then
    # OK, let's see what distro we have here
    if command -v $LSB_RELEASE 1>/dev/null; then
        DISTRO="$($LSB_RELEASE -si | tr '[:upper:]' '[:lower:]')"
    elif [ -f /etc/os-release ]; then
        DISTRO="$(grep -o "^ID=.*" /etc/os-release | sed 's#^ID=##gm')"
    elif ! command -v $LSB_RELEASE 1>/dev/null && [ ! -f /etc/os-release ]; then
        die 4 "Unable to identify distribution since command '$LSB_RELEASE' and file /etc/os-release are not present"
    else
        die 5 "Failed to identify distro in $0 running logic for Linux"
    fi

    # ... and the release number
   if command -v $LSB_RELEASE 1>/dev/null; then
        RELEASE="$($LSB_RELEASE -rs | sed 's/\([0-9]\)\..*/\1/')" # integer part, e.g., 20.04 --> 20
    elif [ -f /etc/os-release ]; then
        RELEASE=$(awk -F= '/VERSION_ID/ {print $2}' /etc/os-release |sed s/\"//g)
    else
        die 6 "Unable to determine release"
    fi
else
    die 3 "Sorry, can't configure for $KERNEL systems (yet)."
fi

[ -z "$RELEASE" ] && RELEASE=0 # debian testing doesn't have a release number

# We have distro and release, let's get to work

case "$DISTRO" in
    debian|ubuntu|linuxmint)
        if test \( "$DISTRO" = "ubuntu" -a "$RELEASE" -ge 20 \) -o \( "$DISTRO" = "debian" -a  "$RELEASE" -eq 0 \) ; then
            LIBWXDEV="libwxgtk3.0-gtk3-dev"
        else
            LIBWXDEV="libwxgtk3.0-dev"
        fi
        apt-get install -qy cmake fakeroot g++ gettext git libgtest-dev \
            libcurl4-openssl-dev libqrencode-dev  libssl-dev libuuid1 \
            $LIBWXDEV libxerces-c-dev libxt-dev libxtst-dev \
            libykpers-1-dev libyubikey-dev make pkg-config uuid-dev zip \
            libmagic-dev
        # ? Do we still need this ?
        #cd /usr/src/gtest
        #mkdir build
        #cd build
        #cmake ..
    ;;
    fedora)
        dnf -y install cmake file-devel gcc-c++ git gtest-devel libXt-devel libXtst-devel \
        libcurl-devel libuuid-devel libyubikey-devel \
        make openssl-devel rpmdevtools wxGTK3-devel xerces-c-devel \
        ykpers-devel qrencode-devel
    ;;
    *) die 10 "Don't know how to setup $DISTRO release $RELEASE (yet)."
esac
exit 0