summaryrefslogtreecommitdiffstats
path: root/pkgctl
blob: a54084d2f67b2ab2f22b6137492c94a1eb0a5ce8 (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
#!/bin/bash

cleanup_logs() {
	if [[ -f PKGBUILD ]]; then
		shopt -s nullglob

		dir="."
		files=("$dir/"*.log "$dir/"*.log.*)
		if [[ -f "${files[0]}" ]]; then
			mkdir -p "$dir/logs"
			mv "${files[@]}" "$dir/logs/" || return
			gzip -f "$dir/logs/"*.log "$dir/logs/"*.log.{1,2,3,4,5,6,7,8,9}
		fi
	fi
}

/usr/bin/pkgctl "$@"
exitcode=$?

if [[ "$1" == "build" ]]; then
	cleanup_logs
fi

exit "$exitcode"