summarylogtreecommitdiffstats
path: root/BUILD
blob: cab06cc91765504ae5973b8ce3f8714647091ccf (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
#! /bin/bash
#  (GPL3+) Alberto Salvia Novella (es20490446e.wordpress.com)


mainFunction () {
	updateInfoFile
	buildPackage
}


buildPackage () {
	removeBuildFiles
	echoOnError "buildPackage" "makepkg --force"
	removeBuildFiles
}


changeToThisProgramDir () {
	cd "$( dirname "${BASH_SOURCE[0]}" )"
}


echoOnError () {
	function="${1}"
	command="${2}"
    error=$(eval "${command}" 2>&1 >"/dev/null")

    if [ ${?} -ne 0 ]; then
        echo "${function}: ${error}" >&2
        exit 1
    fi
}


removeBuildFiles () {
	name=$(variableInFile "Name" "PKGBUILD")
	folders="pkg src ${name}"
	echoOnError "removeBuildFiles" "rm --recursive --force ${folders}"
}


updateInfoFile () {
	echoOnError "updateInfoFile" "makepkg --printsrcinfo > .SRCINFO"
}


variableInFile () {
	variable="${1}"
	file="${2}"

	echo $(
		source "${file}";
		eval echo \$\{${variable}\}
	)
}


changeToThisProgramDir
mainFunction