File: build-linux.sh

package info (click to toggle)
ezquake 3.6.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,920 kB
  • sloc: ansic: 180,027; sh: 324; objc: 139; tcl: 107; xml: 64; makefile: 10
file content (160 lines) | stat: -rwxr-xr-x 5,867 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
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
#!/bin/sh -e
# simple build script for linux

# ANSI color codes
RED='\e[31m'
GREEN='\e[32m'
YELLOW='\e[33m'
NC='\e[0m'

BUILD_LOG=/tmp/ezquake-build.log

SKIP_DEPS="${SKIP_DEPS:-0}"

PKGS_DEB="git cmake build-essential libsdl2-2.0-0 libsdl2-dev libjansson-dev libexpat1-dev libcurl4-openssl-dev libpng-dev libjpeg-dev libspeex-dev libspeexdsp-dev libfreetype-dev libsndfile1-dev libpcre2-dev libminizip-dev"
PKGS_RPM="pcre2-devel cmake mesa-libGL-devel SDL2-devel make gcc jansson-devel expat-devel libcurl-devel libpng-devel libjpeg-turbo-devel speex-devel speexdsp-devel freetype-devel libsndfile-devel libXxf86vm-devel minizip-devel"
PKGS_ARCH="base-devel cmake libpng libjpeg-turbo sdl2 expat libcurl-compat freetype2 speex speexdsp jansson libsndfile minizip"
PKGS_VOID="base-devel cmake SDL2-devel pcre2-devel jansson-devel expat-devel libcurl-devel libpng-devel libjpeg-turbo-devel speex-devel speexdsp-devel freetype-devel libsndfile-devel libXxf86vm-devel minizip"

CPU=$(uname -m | sed -e s/i.86/i386/ -e s/amd64/x86_64/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/alpha/axp/)

error() {
	[ ! -e $BUILD_LOG ] || cat $BUILD_LOG
	printf "${RED}[ERROR]${NC} %s\n" "$*"
	exit 1
}

step() {
	printf "${GREEN}[STEP ]${NC} %s\n" "$*"
}

info() {
	printf "[INFO ] %s\n" "$*"
}

warn() {
	printf "${YELLOW}[WARN ]${NC} %s\n" "$*"
}

install_check_deb() {
	step "Install/check dependecies (packages)..."
	info "You might be prompted to input your password as superuser privileges are required."

	info "Updating apt repo list... (running with sudo)"
	sudo apt-get update -y -qq || error "Failed to update package sources. Exiting."
	info "Checking/installing required packages... (running with sudo)"
	sudo apt-get install -y -q $PKGS_DEB >>$BUILD_LOG 2>&1 || error "Failed to install required packages. Exiting."
}

install_check_rpm() {
	step "Install/check dependecies (packages)..."
	info "You might be prompted to input your password as superuser privileges are required."
	info "Updating yum repo list... (running with sudo)"
	sudo yum clean all -yqqq && sudo yum check-update -yqqq >>$BUILD_LOG 2>&1 || error "Failed to update repo list. Exiting."
	info "Checking/installing required packages... (running with sudo)"
	sudo yum install -yq $PKGS_RPM >>$BUILD_LOG 2>&1 || error "Failed to install required packages. Exiting."
}

install_check_arch() {
	step "Install/check dependecies (packages)..."
	info "You might be prompted to input your password as superuser privileges are required."
	sudo pacman -Sy >>$BUILD_LOG 2>&1 || error "Failed to update repository cache. Exiting."
	sudo pacman -S --needed --noconfirm $PKGS_ARCH >>$BUILD_LOG 2>&1 || error "Failed to install required packages. Exiting."
}

install_check_void() {
    step "Install/check dependencies (packages)..."
    info "You might be prompted to input your password as superuser privileges are required."

    info "Updating xbps repo list... (running with sudo)"
    sudo xbps-install -Sy >>$BUILD_LOG 2>&1 || error "Failed to update package sources. Exiting."
    info "Checking/installing required packages... (running with sudo)"
    sudo xbps-install -y $PKGS_VOID >>$BUILD_LOG 2>&1 || error "Failed to install required packages. Exiting."
}

if [ -f $BUILD_LOG ];then
	rm -f $BUILD_LOG ||:
fi

[ -e CMakeLists.txt ] || error "Cannot find 'CMakeLists.txt', please run this script from the source code directory."

if [ $SKIP_DEPS -eq 0 ];then
	command -v sudo &>/dev/null || error "Could not find sudo, please install it. Exiting."

	if [ -f /etc/os-release ]; then
		. /etc/os-release || error "Failed to source os-release file"
	else
		error "Your environment isn't supported by this script. Exiting."
	fi

	[ -n "${ID}" ] || error "Your dist does not specify ID in /etc/os-release. Exiting."
	[ -n "${VERSION_ID}" ] || VERSION_ID=0
	case $ID in
		arch)
			install_check_arch
			;;
		manjaro)
			install_check_arch
			;;
		void)
			install_check_void
			;;
		linuxmint)
			[ $VERSION_ID -ge 18 ] || error "Your Linux Mint version '$VERSION_ID' is too old. Exiting."
			install_check_deb
			;;
		ubuntu)
			VERSION_ID=${VERSION_ID%.*}
			[ $VERSION_ID -ge 16 ] || error "Your Ubuntu version '$VERSION_ID' is too old. Exiting."
			install_check_deb
			;;
		devuan)
			if [ $VERSION_ID -gt 0 ] && [ $VERSION_ID -lt 4 ] ; then
				error "Your Devuan version '$VERSION_ID' is too old. Exiting."
			fi
			# Includes Devuan testing/unstable as they don't provide a VERSION_ID
			install_check_deb
			;;
		debian)
			if [ $VERSION_ID -gt 0 ] && [ $VERSION_ID -lt 8 ]; then
				error "Your Debian version '$VERSION_ID' is too old. Exiting."
			fi
			# Includes Debian testing/unstable as they don't provide a VERSION_ID
			install_check_deb
			;;
		pop)
			VERSION_ID=${VERSION_ID%.*}
			[ $VERSION_ID -ge 17 ] || error "Your Pop!_OS version '$VERSION_ID' is too old. Exiting."
			install_check_deb
			;;
		centos|rhel|fedora)
			# FIXME: Versions checks?
			install_check_rpm
			;;
		*)
			error "Your dist '$ID' isn't supported by this script. Exiting."
			;;
	esac
fi

if [ -d ".git" ]; then
	step "Checking out git submodules..."
	git submodule update --init --recursive >> $BUILD_LOG 2>&1 || error "Failed to checkout git submodules. Exiting."
fi

if [ ! -f src/qwprot/src/protocol.h ]; then
  error "Bad source code directory, not a git repository, and lacks src/qwprot/src/protocol.h." \
        "Download an official source release or checkout the official git repository."
fi

step "Configure build..."
if command -v ninja >/dev/null 2>&1; then
  GENERATOR="-G Ninja"
fi
cmake -B build "${GENERATOR}" -DCMAKE_BUILD_TYPE=Release

step "Compiling sources (this might take a while, please wait)..."
cmake --build build --parallel

printf "\n${GREEN}Build completed successfully.${NC}\n"
printf "Copy ${YELLOW}build/ezquake-linux-${CPU}${NC} into your quake directory.\n\n"