summaryrefslogtreecommitdiffstats
path: root/satellit_installer/includes/10-install_packages.inc
blob: 66edbb3dc450162f5b28cc199eb9bae1ba303322 (plain) (blame)
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
#!/bin/bash

install_package() {
	# These stacked ifs are just a stopgap until proper trapping.
	local PACKAGE="$1"
	echo "# Installing package $PACKAGE... "
	apt-get $INSTALLOPTIONS install "${PACKAGE}" && return 0
	echo
	echo "# Could not install package $PACKAGE - Error number $ERR!"
	echo "# Trying an apt-get update..."
	if ! apt-get update; then
		echo
		perror "apt-get update failed. Abort."
	fi
	echo "# Retrying installing package $PACKAGE... "
	apt-get $INSTALLOPTIONS install "${PACKAGE}" && return 0
	perror "Could not install $PACKAGE. Giving up."
}

install_packages() {
	local PACKAGE
	local NEEDED_PACKAGES="$2"
	local INSTALLOPTIONS=

	echo "#"
	echo "# Installing packages. This may take a while."
	echo "#"

	case "$1" in
	NOREC)	INSTALLOPTIONS="-qq -y --no-install-recommends"
		;;
	RECOM)	INSTALLOPTIONS="-qq -y"
		;;
	esac
	for PACKAGE in $NEEDED_PACKAGES; do
		install_package "$PACKAGE"
	done
}

# install_files <module_name>
install_files() {
	local dir="${BASEDIR}/static_files/${1}"
	[ -d "$dir" ] || perror "static files for module $1 not found"
	tar -cpP --owner=root --group=root --transform "s,^\(./\)*${dir}/*,," "$dir" | tar -xp -C /
	local ps=( ${PIPESTATUS[*]} )
	[ "${ps[0]}" != 0 ] && perror "tarcopy: Read failed"
	[ "${ps[1]}" != 0 ] && perror "tarcopy: Write failed"
	return 0
}