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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# Activate full hardening build flags
export DEB_BUILD_MAINT_OPTIONS := hardening=+all
include /usr/share/dpkg/default.mk
##############################################################################
TESTSUITE_ENV = SKIP_KNOWN_BUGS=y VERBOSE=y
# always run tests in UTF8 mode to verify unicode support
TESTSUITE_ENV += LANG=C.UTF-8 LC_ALL=C.UTF-8
TESTSUITE_ENV += SKIP_INTERNET_TESTS=y
# Required for testsuite/taskset.tests
TESTSUITE_ENV += SHELL='sh -e'
# build directory
b = debian/build
# which flavours to build
flavours = deb static udeb
ifneq (${DEB_HOST_GNU_TYPE},${DEB_BUILD_GNU_TYPE})
export CROSS_COMPILE = ${DEB_HOST_GNU_TYPE}-
endif
# We filter the following from CFLAGS:
# -Werror=format-security
# because busybox uses constructs like
# bb_error_msg_and_die(bb_msg_memory_exhausted);
# in several places, and gcc complains because bb_msg_memory_exhausted is an
# extern.
#
# -O2
# to use the optimization setting from busybox's configuration and build
# system, causing it to use -Os. This reduces built binaries' size
# considerably, making it easier to fit on space constrained systems.
CFLAGS := $(filter-out -Werror=format-security -O2, ${CFLAGS})
# Avoid Kconfig outputting the timestamp into generated configuration files. We
# use this to compare against the configuration files in debian/config/pkg for
# builds on Linux so that we can detect upstream configuration changes (e.g.
# added applets).
export KCONFIG_NOTIMESTAMP=1
%:
dh $@
##############################################################################
override_dh_auto_configure: $(patsubst %,${b}/%/.stamp-setup, ${flavours})
${b}/%/.stamp-setup: DIR = ${b}/$*
${b}/%/.stamp-setup:
rm -rf ${DIR}
mkdir -p ${DIR}
cp -a -l $(filter-out debian ${b}, $(wildcard *)) ${DIR}
# Generate the .config file. First variable assignment wins.
# Several steps..
# 1, rm it just in case
rm -f ${DIR}/.config
# 2, put any arch-specific overrides so they will have higher precedence
# should be empty for linux
cat debian/config/os/${DEB_HOST_ARCH_OS} > ${DIR}/.config
# 3, on non-linux platform, disable all config symbols
# which select PLATFORM_LINUX.
# Configuration information is stored in source files and in Config.src,
# so we have to generate Config.in files first, -- done by gen_build_files.
${MAKE} -C ${DIR} gen_build_files \
SKIP_STRIP=y \
BB_EXTRA_VERSION="${DEB_VENDOR} ${DEB_VERSION}" \
CONFIG_EXTRA_CFLAGS='${CFLAGS} ${CPPFLAGS}' \
CONFIG_EXTRA_LDFLAGS='${CFLAGS} ${LDFLAGS}' \
V=1
ifneq (linux,${DEB_HOST_ARCH_OS})
find ${DIR} -name Config.in -exec \
awk '$$1 == "config" { conf = $$2 } \
$$1 == "select" && $$2 == "PLATFORM_LINUX" \
{ print "CONFIG_" conf "=n"; }' \
{} + \
| sort -u >> ${DIR}/.config
endif
# 4, use the flavour-specific base config file.
cat debian/config/pkg/$* >> ${DIR}/.config
# 5, sort out the resulting mess using oldconfig Kbuild machinery
yes "" | ${MAKE} -C ${DIR} oldconfig V=1
# 6, on linux platform only, compare the re-generated config to the shipped
# config in the package in order to catch new/changed upstream options.
ifeq (linux,${DEB_HOST_ARCH_OS})
cmp debian/config/pkg/$* ${DIR}/.config
endif
ln -s .config $@
##############################################################################
override_dh_auto_build: $(patsubst %,${b}/%/.stamp-build, ${flavours})
${b}/%/.stamp-build: DIR = ${b}/$*
${b}/%/.stamp-build:
dh_auto_build -- -C ${DIR} all \
SKIP_STRIP=y \
BB_EXTRA_VERSION="${DEB_VENDOR} ${DEB_VERSION}" \
CONFIG_EXTRA_CFLAGS='${CFLAGS} ${CPPFLAGS}' \
CONFIG_EXTRA_LDFLAGS='${CFLAGS} ${LDFLAGS}' \
V=1
ln -sf busybox $@
##############################################################################
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
# we run testsuite only for main flavour
test-dep := ${b}/deb/.stamp-test
else
test-dep :=
endif
override_dh_auto_test: ${test-dep}
${b}/%/.stamp-test: DIR = ${b}/$*
${b}/%/.stamp-test:
@echo ======== running testsuite in ${DIR} ========
# mdev testsuite requires chroot which does not work as non-root user
rm -f ${DIR}/testsuite/mdev.tests
# disable or fix some failing tests
if [ -f debian/testsuite-${DEB_HOST_ARCH_OS}.diff ] && \
! [ -f ${DIR}/.tests-fixed ]; then \
( cd ${DIR} && patch -p1 && touch .tests-fixed; ) \
< debian/testsuite-${DEB_HOST_ARCH_OS}.diff ; \
fi
cd ${DIR}/testsuite && ${TESTSUITE_ENV} ./runtest -v
touch $@
##############################################################################
override_dh_auto_clean:
dh_auto_clean
rm -rf ${b}
##############################################################################
override_dh_auto_install: $(patsubst %,${b}/%/.stamp-install, ${flavours})
${b}/%/.stamp-install: DIR = ${b}/$*
${b}/%/.stamp-install:
$(MAKE) -C ${DIR} install \
SKIP_STRIP=y \
BB_EXTRA_VERSION="${DEB_VENDOR} ${DEB_VERSION}" \
CONFIG_EXTRA_CFLAGS='${CFLAGS} ${CPPFLAGS}' \
CONFIG_EXTRA_LDFLAGS='${CFLAGS} ${LDFLAGS}' \
V=1
touch $@
##############################################################################
override_dh_installman:
dh_installman -pbusybox ${b}/deb/docs/busybox.1
dh_installman -pbusybox-static ${b}/static/docs/busybox.1
override_dh_install:
rm -f ${b}/udeb/_install/sbin/init
dh_install
dh_install -pbusybox ${b}/deb/busybox /bin
dh_install -pbusybox debian/tree/busybox/* /
dh_install -pbusybox-static ${b}/static/busybox /bin
dh_install -pbusybox-udeb ${b}/udeb/_install/* /
override_dh_installdocs:
dh_installdocs
dh_installdocs -pbusybox docs/syslog.conf.txt docs/mdev.txt
dh_installdocs -pbusybox-static docs/syslog.conf.txt docs/mdev.txt
override_dh_installexamples:
dh_installexamples -pbusybox-static examples/mdev* examples/udhcp
override_dh_installinit:
dh_installinit -pbusybox-syslogd
dh_installinit -pbusybox-syslogd --name=busybox-klogd
ifeq (linux,$(DEB_HOST_ARCH_OS))
# udhcpc
# udhcpd
dh_installinit -pudhcpd --onlyscripts
endif
override_dh_gencontrol:
# after shlibdeps finished, grab ${shlibs:Depends} from busybox package
# and transform it into Built-Using field (also dpkg-query bug #588505)
if [ -f debian/busybox.substvars ]; then \
pkgs=$$(sed -n -e's/([^)]*)//g' -e's/,//g' -e's/^shlibs:Depends=//p' debian/busybox.substvars); \
srcs=; for p in $$pkgs; do \
srcs="$$srcs $$(dpkg-query -f '$${source:Package} (= $${source:Version}),' -W $$p)"; \
done ; \
echo "built-using=$$srcs" >> debian/busybox-static.substvars ; \
fi
dh_gencontrol
|