From edc175938c0b6a1bb6fbf6615b4837e19d238efd Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Wed, 5 Dec 2018 15:09:51 +0100 Subject: debian: improve debian packaging Signed-off-by: Michael Olbrich --- debian/.gitignore | 26 +++++++++----------------- debian/bin/build.sh | 14 ++++++++++++++ debian/bin/gencontrol.sh | 16 ++++++++++------ debian/patches/dont-strip.patch | 15 --------------- debian/patches/series | 1 - debian/rules | 41 +++++++++++++++++++++++++++++++++-------- 6 files changed, 66 insertions(+), 47 deletions(-) create mode 100755 debian/bin/build.sh delete mode 100644 debian/patches/dont-strip.patch delete mode 100644 debian/patches/series (limited to 'debian') diff --git a/debian/.gitignore b/debian/.gitignore index e3505df..37cdd01 100644 --- a/debian/.gitignore +++ b/debian/.gitignore @@ -1,18 +1,10 @@ -/control /*.log -/oselas.toolchain-2018.02.0-aarch64-v8a-linux-gnu-gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.15-sanitized.install -/oselas.toolchain-2018.02.0-arm-1136jfs-linux-gnueabi-gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.15-sanitized.install -/oselas.toolchain-2018.02.0-arm-1136jfs-linux-gnueabihf-gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.15-sanitized.install -/oselas.toolchain-2018.02.0-arm-v4t-linux-gnueabi-gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.15-sanitized.install -/oselas.toolchain-2018.02.0-arm-v5te-linux-gnueabi-gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.15-sanitized.install -/oselas.toolchain-2018.02.0-arm-v7a-linux-gnueabi-gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.15-sanitized.install -/oselas.toolchain-2018.02.0-arm-v7a-linux-gnueabihf-gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.15-sanitized.install -/oselas.toolchain-2018.02.0-arm-v7em-eabihf-gcc-7.3.1-newlib-2.5.0-binutils-2.30.install -/oselas.toolchain-2018.02.0-arm-v7em-uclinuxeabihf-gcc-7.3.1-uclibc-ng-1.0.28-binutils-2.30-kernel-4.15-sanitized.install -/oselas.toolchain-2018.02.0-arm-v7m-eabi-gcc-7.3.1-newlib-2.5.0-binutils-2.30.install -/oselas.toolchain-2018.02.0-arm-v7m-uclinuxeabi-gcc-7.3.1-uclibc-ng-1.0.28-binutils-2.30-kernel-4.15-sanitized.install -/oselas.toolchain-2018.02.0-i586-unknown-linux-gnu-gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.15-sanitized.install -/oselas.toolchain-2018.02.0-i686-atom-linux-gnu-gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.15-sanitized.install -/oselas.toolchain-2018.02.0-mipsel-softfloat-linux-gnu-gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.15-sanitized.install -/oselas.toolchain-2018.02.0-powerpc-603e-linux-gnu-gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.15-sanitized.install -/oselas.toolchain-2018.02.0-x86-64-unknown-linux-gnu-gcc-7.3.1-glibc-2.27-binutils-2.30-kernel-4.15-sanitized.install +/.debhelper/ +/control +/debhelper-build-stamp +/files +/oselas.toolchain-20*-*.debhelper +/oselas.toolchain-20*-*.install +/oselas.toolchain-20*-*.substvars +/oselas.toolchain-20*/ +/ptxdistrc diff --git a/debian/bin/build.sh b/debian/bin/build.sh new file mode 100755 index 0000000..0bdcb86 --- /dev/null +++ b/debian/bin/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +RELEASE="$(lsb_release -c -s)" +VERSION="$(cat /etc/debian_version)" +VERSION="${VERSION%%.*}" + +if ! [[ "${VERSION}" =~ .*/sid ]]; then + git checkout debian/changelog + dch --local ~deb${VERSION}+ --distribution ${RELEASE} "Rebuild for ${RELEASE}" || exit +fi + +debian/bin/gencontrol.sh "${@}" + +dpkg-buildpackage -uc -b -nc diff --git a/debian/bin/gencontrol.sh b/debian/bin/gencontrol.sh index 66c2fe5..573d139 100755 --- a/debian/bin/gencontrol.sh +++ b/debian/bin/gencontrol.sh @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/bash -e die() { echo >&2 "$@" @@ -23,8 +23,12 @@ Bugs: mailto:bugs@pengutronix.de Build-Depends: debhelper (>= 9), libncurses-dev, python3-dev, bison, flex EOF -find ptxconfigs -maxdepth 2 -name \*.ptxconfig | -while read configfile; do +if [ $# -gt 0 ]; then + configs=( "${@}" ) +else + configs=( ptxconfigs/*.ptxconfig ) +fi +for configfile in "${configs[@]}"; do toolchain_name="$(basename "${configfile}" .ptxconfig | sed s/_/-/g)" pkg="oselas.toolchain-${toolchain_version}-${toolchain_name}" gnutriplet="$(sed -n 's/^PTXCONF_GNU_TARGET="\(.*\)"/\1/p' "$configfile")" @@ -36,18 +40,18 @@ Architecture: any Depends: \${shlibs:Depends}, \${misc:Depends} Description: OSELAS Toolchain for ${gnutriplet} -Package: oselas.toolchain-${toolchain_version}-${gnutriplet} +Package: oselas.toolchain-${toolchain_version}-${gnutriplet/_/-} Architecture: all Depends: $pkg Description: Meta package depending on latest OSELAS Toolchain for ${gnutriplet} -Package: oselas.toolchain-${toolchain_version%.*}-${gnutriplet} +Package: oselas.toolchain-${toolchain_version%.*}-${gnutriplet/_/-} Architecture: all Depends: $pkg Description: Meta package depending on latest OSELAS Toolchain for ${gnutriplet} EOF - echo "/opt/OSELAS.Toolchain-2018.02.0/${gnutriplet}" > "debian/${pkg}.install" + echo "/opt/OSELAS.Toolchain-${toolchain_version}/${gnutriplet}" > "debian/${pkg}.install" done if ! cmp -s "$newcontrol" "debian/control"; then diff --git a/debian/patches/dont-strip.patch b/debian/patches/dont-strip.patch deleted file mode 100644 index 8d80b30..0000000 --- a/debian/patches/dont-strip.patch +++ /dev/null @@ -1,15 +0,0 @@ -Description: Don't strip in post/cleanup - -Index: OSELAS.Toolchain/rules/post/cleanup.make -=================================================================== ---- OSELAS.Toolchain.orig/rules/post/cleanup.make -+++ OSELAS.Toolchain/rules/post/cleanup.make -@@ -14,7 +14,7 @@ $(STATEDIR)/world.cleanup: $(STATEDIR)/w - -wholename "$(PTXCONF_SYSROOT_CROSS)/lib/gcc" -prune -o \ - -type f -name "*.a" -print0 | xargs -0 -r rm - # # strip all host binaries -- find $(TOOLCHAIN_CLEANUP_HOST_DIRS) \ -+ : || find $(TOOLCHAIN_CLEANUP_HOST_DIRS) \ - -wholename "$(PTXCONF_SYSROOT_CROSS)/lib/gcc" -prune -o \ - -type f \( -executable -o -name "*.so*" \) -print0 \ - | xargs -0 -n1 --verbose strip --preserve-dates || true diff --git a/debian/patches/series b/debian/patches/series deleted file mode 100644 index 2c0f4b4..0000000 --- a/debian/patches/series +++ /dev/null @@ -1 +0,0 @@ -dont-strip.patch diff --git a/debian/rules b/debian/rules index 6e6d1e3..2876221 100755 --- a/debian/rules +++ b/debian/rules @@ -1,33 +1,58 @@ #!/usr/bin/make -f +PTXDIST ?= ptxdist-$(shell sed -n 's/.*PTXCONF_CONFIGFILE_VERSION="\(.*\)"$$/\1/p' fixup_ptxconfigs.sh) + +TOOLCHAINS := $(shell sed -n 's;Package: oselas.toolchain-20..\...\..-\(.*-gcc-.*\);gstate/\1.build;p' debian/control) + RULETARGETS := binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep $(RULETARGETS): %: debian/control dh $@ + debian/control: debian/bin/gencontrol.sh $(wildcard ptxconfigs/*.ptxconfig) debian/bin/gencontrol.sh -ptxdistrc: +debian/ptxdistrc: : > $@ test ! -d /ptx/src || echo 'PTXCONF_SETUP_SRCDIR="/ptx/src"' >> $@ + if [ -x /usr/lib/icecc/icecc-create-env ]; then \ + echo 'PTXCONF_SETUP_ICECC=y'; \ + echo 'PTXCONF_SETUP_ICECC_CREATE_ENV="/usr/lib/icecc/icecc-create-env"'; \ + fi >> $@ -override_dh_auto_build: ptxdistrc - PTXDIST_PTXRC=$(CURDIR)/ptxdistrc make -f build_all_v2.mk ARG="-j -q go" PTXDIST=/opt/bin/ptxdist-2018.02.0 CROSS_GDB_WITHOUT_PYTHON=n +PTXDIST_ENV := \ + PTXDIST_TOOLCHCAIN_KEEP_DEBUG=1 \ + PTXDIST_PTXRC=$(CURDIR)/debian/ptxdistrc \ + CROSS_GDB_WITHOUT_PYTHON=n -override_dh_auto_install: +override_dh_auto_build: debian/ptxdistrc + $(PTXDIST_ENV) make -f build_all_v2.mk ARG="-j -q go" PTXDIST="$(PTXDIST)" $(TOOLCHAINS) + +override_dh_auto_install-arch: mkdir -p $(CURDIR)/debian/tmp - mv inst/opt debian/tmp/opt + rm -rf $(CURDIR)/debian/tmp/opt + cp -a inst/opt $(CURDIR)/debian/tmp/ override_dh_auto_clean: dh_auto_clean - rm -rf gstate platform-* + rm -rf gstate platform-* inst/ + +EXCLUDES = \ + -Xsysroot- \ + $(foreach d,$(wildcard inst/opt/OSELAS.Toolchain-*/*/*/*/lib),-X$(subst inst,,$(d))) \ + $(foreach d,$(wildcard inst/opt/OSELAS.Toolchain-*/*/*/lib/gcc/*/*),-X$(subst inst,,$(d))) + +# don't change the permissions of target files +# the dynamic linker and glibc must remain executable +override_dh_fixperms: + dh_fixperms $(EXCLUDES) # don't strip target stuff override_dh_strip: - dh_strip -Xsysroot- $(foreach d,$(wildcard debian/tmp/opt/OSELAS.Toolchain-*/*/*/*/lib),-X$(subst debian/tmp,,$(d))) + dh_strip $(EXCLUDES) # don't use target binaries to generate dependencies override_dh_shlibdeps: - dh_shlibdeps -Xsysroot- $(foreach d,$(wildcard debian/tmp/opt/OSELAS.Toolchain-*/*/*/*/lib),-X$(subst debian/tmp,,$(d))) + dh_shlibdeps $(EXCLUDES) .PHONY: $(RULETARGETS) -- cgit v1.2.3