blob: c0ff684574984dc8c4744ff8ef7e4106e838b1d4 (
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
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
|
#!/usr/bin/env build
build_make_compile_cleanup()
{
ret=$?
if [ ${ret} -ne 0 ]; then
echo "error: compile failed for ${CATEGORY}/${NAME}" >&2
echo "logfile: '${PKG_LOGFILE}'" >&2
exit ${ret}
fi
exit 0
}
build_compile()
{
if [ -f "configure" ]; then
./configure --host="${CHOST}" \
--prefix="/usr" --mandir=/usr/share/man \
--docdir=/usr/share/doc \
--sysconfdir=/etc \
${CONFIG_OPTS}
fi
make ${MAKE_OPTS}
make DESTDIR="${D}" install
}
pkg_compile() { build_compile; }
build_make_compile()
{(
trap build_make_compile_cleanup 0
load_rules "${1}"
# Declare compilation variables before loading the rules as the package
# may potentially overwrite this data, in particular the toolchain data
# is usually rewritten within the toolchain/buildtools rule.
echo "compiling: ${1}"
eval "$(build-query --toolchain "${CHOST}")"
mkenv "compile"
PKG_LOGFILE="${L}/compile.log"
# pkgconfig can be a right pita...
PKG_CONFIG_LIBDIR="${SYSROOT}/usr/share/pkgconfig:${SYSROOT}/usr/lib/pkgconfig"
PKG_CONFIG_SYSROOT_DIR="${SYSROOT}"
export PKG_CONFIG_LIBDIR PKG_CONFIG_PATH
export PKG_CONFIG_SYSROOT_DIR
# Don't pass along the builder jobcontrol data to child processes
unset MAKEFLAGS
load_rules "${1}"
## Build the source and install it into the DESTDIR
# Ironically this is the heart of what the build-engine does, and yet it has
# been reduced to the simplest component of the entire system.
cd "${S}"
pkg_compile >> "${PKG_LOGFILE}" 2>&1
## Save Space!
# At this point everything important should be installed into ${D}, and
# any form of reruning the build will remove ${S} before prepping it
# for build, so we might as well gut it now. About the best option we
# could do would be to avoid gutting this when being run in --debug
# mode.
find "${S}" -delete &
##
# Generate the file index. This is done as a 0 delimited file stored
# within the destination filesystem. This allows for easy checking of
# the installed data as well as easy removal of individual binary
# packages from the sysroot.
mkdir -p "${D}/var/db/binpkgs/${CATEGORY}"
binpkg_list="$(mktemp "${T}/binpkg.XXXXXXXX")"
if [ ! -e "${binpkg_list}" ]; then
die "failed to create package inventory"
fi
cd "${D}"
for dir in man usr/man usr/share/man; do
test -d "${dir}" || continue
for file in `find "${dir}" -regex '.*[1-9]$'`; do
if test -f "${file}"; then
gzip -c -9 "${file}" > "${file}.gz" && rm "${file}"
elif test -h "${file}"; then
mv "${file}" "${file}.gz"
fi
done
wait
done
wait
find * -depth \( ! -type d \) -print0 > "${binpkg_list}"
mv "${binpkg_list}" "${D}/var/db/binpkgs/${CATEGORY}/${NAME}"
)}
if test "${BUILDER_CALL_STACK}" = '__main__'; then
simple_usage 'compile' '[all|[<category>/]<package|all>]' "$@"
build_make_compile "${@}"
fi
# vim: filetype=sh
|