-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.package
executable file
·136 lines (113 loc) · 3.65 KB
/
make.package
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
set -e
set -o pipefail
export TOPDIR=$(pwd)
FIRST="$1"
SECND="$2"
shift $#
source ./make.config
source ./make.clean
if [ "$FIRST" == "help" ] || [ "$FIRST" == "--help" ] || [ "$FIRST" == "-h" ] || [ -z "$FIRST" ] || [ -z "$SECND" ]; then
${ECHOCMD} ""
${ECHOCMD} " make.package builds either a toolchain, a userland, a base system or a pkgsrc package" &&
${ECHOCMD} " category/package follows the same hierarchy as pkgsrc, for example "editors/nano"" &&
${ECHOCMD} " base system is a full linux distribution made into an image." &&
${ECHOCMD} " read over make.config carefully when building a base system." &&
${ECHOCMD} " Usage: ./make.package category/package customname" &&
${ECHOCMD} " Usage: ./make.package userland customname"
${ECHOCMD} " Usage: ./make.package base customname"
${ECHOCMD} ""
exit 0
fi
export PKGDEFAULTNAME=$SECND
echo ${PKGDEFAULTNAME} > log.pkgname
source ./make.prefix
${MKDIRCMD} sources &&
${MKDIRCMD} release
${MKDIRCMD} tmpdir &&
if [ "$FIRST" == "toolchain" ]; then
export TOOLCHAINBUILD=1
cd ./toolchain &&
${SHELL} ./make.toolchain all &&
cd ${TOPDIR} &&
./make.preparelib
exit 0
fi
if [ "$FIRST" == "userland" ]; then
if [ "$LINUXUSERLAND" == "1" ]; then
cd ./userland &&
source ./make.userland &&
unset LINUXUSERLAND
cd ${TOPDIR} &&
./make.preparelib
fi
export USERLANDBUILD=1
cd ./userland &&
source ./make.userland &&
cd ${TOPDIR} &&
./make.preparelib
exit 0
fi
if [ "$FIRST" == "kernel" ]; then
export KERNELBUILD=1
cd ./userland &&
source ./make.userland &&
cd ${TOPDIR} &&
cd ./kernel &&
source ./make.kernel &&
cd ${TOPDIR} &&
exit 0
fi
if [ "$FIRST" == "base" ]; then
export USERLANDBUILD=1
export BASEBUILD=1
cd ./userland &&
source ./make.userland &&
cd ${TOPDIR} &&
cd ./kernel &&
source ./make.kernel &&
cd ${TOPDIR} &&
source ./make.base
exit 0
fi
export CCPREFIX=$(${WHICHCMD} cc | ${XARGSCMD} ${DIRNAMECMD} | ${XARGSCMD} ${DIRNAMECMD})
export CC="${CCPREFIX}/bin/cc"
export CXX="${CCPREFIX}/bin/c++"
cd tmpdir &&
${FETCHCMD} https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.xz &&
${TARCMD} xf ${TOPDIR}/sources/pkgsrc.tar.xz --skip-old-files &&
if ${FINDCMD} pkgsrc/$FIRST &>/dev/null; then
:
else
${ECHOCMD} "Package not found. Try using ls and grep to find a package"
exit 0
fi
${MKDIRCMD} ${FINPREFIX}/sbin
if [[ "$MACHARCH" =~ .*gnu ]]; then
${CPCMD} -L ${CCPREFIX}/lib/ld-linux* ${FINPREFIX}/sbin/rtld
elif [[ "$MACHARCH" =~ .*musl ]]; then
${CPCMD} -L ${CCPREFIX}/lib/ld-musl-* ${FINPREFIX}/sbin/rtld
fi
cd pkgsrc/bootstrap &&
export CFLAGS="-Wl,--dynamic-linker=${FINPREFIX}/sbin/rtld -Wno-error"
export CXXFLAGS="-Wl,--dynamic-linker=${FINPREFIX}/sbin/rtld"
export LDFLAGS="-Wl,--dynamic-linker=${FINPREFIX}/sbin/rtld"
if [ -f /bin/bash ]; then
export SH=/bin/bash
else
export SH=/.sys/sh
fi
${RMCMD} work &&
./bootstrap --prefix=$FINPREFIX --varbase=$FINPREFIX/var --pkgdbdir=$FINPREFIX/pkgsrcdb &&
${SEDCMD} -i '/.endif/iX11_TYPE= modular' ${FINPREFIX}/etc/mk.conf &&
${SEDCMD} -i "/.endif/iMAKE_JOBS= $JOBS" ${FINPREFIX}/etc/mk.conf &&
${SEDCMD} -i "/.endif/iCXXFLAGS+= -Wl,--dynamic-linker=${FINPREFIX}/sbin/rtld -Wno-error" ${FINPREFIX}/etc/mk.conf &&
## Acceptable licenses go here.
## Mostly for those wishing to disable a license.
${SEDCMD} -i "/.endif/iACCEPTABLE_LICENSES+= vim-license" ${FINPREFIX}/etc/mk.conf
${SEDCMD} -i "/.endif/iACCEPTABLE_LICENSES+= lame-license" ${FINPREFIX}/etc/mk.conf
cd ../
cd ${FIRST} &&
${FINPREFIX}/bin/bmake install clean clean-depends &&
cd ${TOPDIR} &&
${ECHOCMD} "DONE!"
./make.preparelib