forked from sabotage-linux/sabotage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutch
executable file
·74 lines (59 loc) · 2.2 KB
/
butch
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
#!/bin/sh
# wrapper script to set up environment for butch-core
# and redirects to several extension scripts
# + aliases to some commands
[ "$STAGE" = "0" ] && [ -z "$CONFIG" ] && CONFIG="$PWD/config"
[ -z "$CONFIG" ] && CONFIG=/src/config
if [ ! -e "$CONFIG" ] ; then
echo "error: $CONFIG not found"
exit 1
fi
. "$CONFIG"
BINDIR=$(dirname "$(readlink -f "$0")")
usage() {
cat << EOF >&2
butch wrapper v0.1.1
usage: $0 command package ...
------- available commands -----
list: list all installed packages
files: show all files installed by package
owner: shows which package owns a file
search: search for term in package names (grep syntax)
unlink: removes symlinks from /opt/packagename into /
relocate: creates symlinks for all files under /opt/packagename to /
relink: ==relocate
update: update all packages whose hash changed
install: download, build, relocate package(s) and all missing dependencies
build: ==install
prefetch: download package(s) and all missing dependencies
print: pretty-print the specified package
download: ==prefetch
rebuild: unlink, download, rebuild, relocate package(s), but not their dependencies
checktarballs: check if filesize of tarballs (if existent) matches packages
all download related actions are only done when needed, i.e. the tarball is missing.
examples:
butch build nano strace gdb
butch files busybox
butch owner /bin/gcc
butch unlink gettext #temporarily unlinks gettext
( do some work... for example check if package XY builds without gettext)
butch relink gettext #put it back into place
EOF
}
prog=butch-core
case $1 in
build) shift ; set -- install "$@";;
download) shift ; set -- prefetch "$@";;
list) shift; prog=butch-list;;
owner) shift; prog=butch-owner;;
files) shift; prog=butch-files;;
search) shift; prog=butch-search;;
print) shift; prog=butch-print;;
checktarballs) shift; prog=butch-checktarballs;;
unlink) shift ; prog=butch-unlink;; #remove links of pkg
relink|relocate) shift; prog=butch-relocate;; #relinks the pkg into /
update) export BUTCH_SKIPLIST=gcc3:stage0:stage0_musl:stage0_gcc:stage0_prepare:"$BUTCH_SKIPLIST" ;;
install|prefetch|rebuild) : ;;
*) usage;; # we exec anyway to get butch-core's usage info
esac
exec "$BINDIR"/$prog "$@"