/
mkpkg
executable file
·78 lines (63 loc) · 1.6 KB
/
mkpkg
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
#!/bin/bash
# Copyright (c) 2017, The MesaLock Linux Project Contributors
# All rights reserved.
#
# This work is licensed under the terms of the BSD 3-Clause License.
# For a copy, see the LICENSE file.
set -e
trap 'echo "[-] ERROR: $BASH_SOURCE:$LINENO $BASH_COMMAND" >&2' ERR
export MAKEFLAGS=-j$(nproc)
workdir="$(pwd)"
buildroot="$workdir/build"
pkgrepobase="$(dirname $workdir)/packages"
VERBOSE=false
mkpkg() {
category="$(dirname $1)"
pkgrepo="$pkgrepobase/$category"
prepare() { :; }
build() { :; }
package() { :; }
. "$pkgrepobase/$1/BUILD"
srcdir="$buildroot/src/$pkgname"
builddir="$buildroot/bld/$pkgname"
pkgdir="$buildroot/pkg/$pkgname"
outdir="$buildroot/out"
rm -rf "$srcdir" "$builddir" "$pkgdir"
mkdir -p "$srcdir" "$builddir" "$pkgdir" "$outdir"
echo "[+] $1: start"
for f in prepare build package; do
echo "[+] $1: $f"
if [ "$2" == true ]; then
cd "$buildroot" && "$f"
else
cd "$buildroot" && "$f" > /dev/null 2>&1
fi
done
echo "[+] $1: tar and zip"
tar cfJ "$outdir/$pkgname.tar.xz" -C "$pkgdir" .
echo "[+] $1: done"
}
check_env() {
rustup show
}
while true; do
case "$1" in
-v | --verbose ) VERBOSE=true; shift ;;
* ) break ;;
esac
done
if [ "$VERBOSE" == true ]; then
flag="-v"
fi
if [[ "$#" -eq 0 ]] ; then
echo '[+] mkpkg: build all packages'
check_env
for category in core community core-testing community-testing; do
ls "$pkgrepobase/$category" | parallel --ungroup "-j$(nproc)" ./mkpkg $flag $category/{}
done
else
check_env
for pkg in "$@"; do
mkpkg "$pkg" "$VERBOSE"
done
fi