From 0bea398a111b96a11e7f72906439a9a489c0a488 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Thu, 31 May 2018 10:56:31 +0200 Subject: [debian] complete overhaul of debian package generation Make use of modern packaging tools. The most visible benefits are automatic generation of debug packages and meta packages depending on the current toolchain. --- debian/.gitignore | 18 ++++++++ debian/bin/gencontrol.sh | 65 +++++++++++++++++++++++++++ debian/changelog | 5 +++ debian/compat | 1 + debian/patches/dont-strip.patch | 15 +++++++ debian/patches/series | 1 + debian/rules | 33 ++++++++++++++ debian/source/format | 1 + debian/source/options | 0 debian/watch | 3 ++ rules/image-toolchain-deb.in | 3 -- rules/image-toolchain-deb.make | 33 -------------- scripts/make_deb.sh | 97 ----------------------------------------- 13 files changed, 142 insertions(+), 133 deletions(-) create mode 100644 debian/.gitignore create mode 100755 debian/bin/gencontrol.sh create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/patches/dont-strip.patch create mode 100644 debian/patches/series create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100644 debian/source/options create mode 100644 debian/watch delete mode 100644 rules/image-toolchain-deb.in delete mode 100644 rules/image-toolchain-deb.make delete mode 100755 scripts/make_deb.sh diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 0000000..e3505df --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1,18 @@ +/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 diff --git a/debian/bin/gencontrol.sh b/debian/bin/gencontrol.sh new file mode 100755 index 0000000..66c2fe5 --- /dev/null +++ b/debian/bin/gencontrol.sh @@ -0,0 +1,65 @@ +#!/bin/sh -e + +die() { + echo >&2 "$@" + return 1 +} + +# This script assumes to have CWD = toplevel of OSELAS.Toolchain +test -f debian/changelog || die "debian/changelog not found" +test "$(dpkg-vendor --query Vendor)" = "Debian" || die "This script only works on Debian" + +toolchain_version=$(dpkg-parsechangelog -SVersion | sed -e 's/-[^-]*$//') +newcontrol=$(mktemp debian/control.XXXXXXXXX) +trap 'rm -v -- "$newcontrol"' INT QUIT EXIT + +cat > "$newcontrol" << EOF +Source: oselas.toolchain +Section: devel +Priority: optional +Maintainer: PTXdist Devevelopers +Homepage: https://www.pengutronix.de/software/toolchain.html +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 + 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")" + + cat >> "$newcontrol" << EOF + +Package: $pkg +Architecture: any +Depends: \${shlibs:Depends}, \${misc:Depends} +Description: OSELAS Toolchain for ${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} +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" +done + +if ! cmp -s "$newcontrol" "debian/control"; then + mv "$newcontrol" "debian/control" + trap '' INT QUIT EXIT + + echo >&2 debian/control was updated successfully. + echo >&2 Nevertheless return failure here to eventually abort + echo >&2 building because the debian/control must not change + echo >&2 during a build. + + exit 1 +else + touch "debian/control" +fi diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..3f47365 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +oselas.toolchain (2018.02.0-0ptx2) unstable; urgency=medium + + * Initial packaging of OSELAS.Toolchain using debhelper + + -- Uwe Kleine-König Wed, 30 May 2018 11:27:03 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/patches/dont-strip.patch b/debian/patches/dont-strip.patch new file mode 100644 index 0000000..8d80b30 --- /dev/null +++ b/debian/patches/dont-strip.patch @@ -0,0 +1,15 @@ +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 new file mode 100644 index 0000000..2c0f4b4 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +dont-strip.patch diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..6e6d1e3 --- /dev/null +++ b/debian/rules @@ -0,0 +1,33 @@ +#!/usr/bin/make -f + +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: + : > $@ + test ! -d /ptx/src || echo 'PTXCONF_SETUP_SRCDIR="/ptx/src"' >> $@ + +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 + +override_dh_auto_install: + mkdir -p $(CURDIR)/debian/tmp + mv inst/opt debian/tmp/opt + +override_dh_auto_clean: + dh_auto_clean + rm -rf gstate platform-* + +# 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))) + +# 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))) + +.PHONY: $(RULETARGETS) diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/source/options b/debian/source/options new file mode 100644 index 0000000..e69de29 diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..e586ed3 --- /dev/null +++ b/debian/watch @@ -0,0 +1,3 @@ +version=3 + +https://public.pengutronix.de/oselas/toolchain/OSELAS.Toolchain-(.*).tar.bz2 diff --git a/rules/image-toolchain-deb.in b/rules/image-toolchain-deb.in deleted file mode 100644 index 27bf883..0000000 --- a/rules/image-toolchain-deb.in +++ /dev/null @@ -1,3 +0,0 @@ -config IMAGE_TOOLCHAIN_DEB - bool - default y diff --git a/rules/image-toolchain-deb.make b/rules/image-toolchain-deb.make deleted file mode 100644 index 2214a93..0000000 --- a/rules/image-toolchain-deb.make +++ /dev/null @@ -1,33 +0,0 @@ -# -*-makefile-*- -# -# Copyright (C) 2014 by Michael Olbrich -# -# See CREDITS for details about who has contributed to this project. -# -# For further information about the PTXdist project and license conditions -# see the README file. -# - -# -# We provide this package -# -IMAGE_PACKAGES-$(PTXCONF_IMAGE_TOOLCHAIN_DEB) += image-toolchain-deb - -# -# Paths and names -# -IMAGE_TOOLCHAIN_DEB_VERSION_EXT ?= $(shell ptxd_make_debian_version_ext) -IMAGE_TOOLCHAIN_DEB_VERSION := $(shell ./scripts/setlocalversion ./.tarball-version) -IMAGE_TOOLCHAIN_DEB_IMAGE := $(PTXDIST_WORKSPACE)/dist/oselas.toolchain-$(IMAGE_TOOLCHAIN_DEB_VERSION)-$(subst _,-,$(PTXCONF_PLATFORM))_$(IMAGE_TOOLCHAIN_DEB_VERSION)$(IMAGE_TOOLCHAIN_DEB_VERSION_EXT)_$(PTX_TOOLCHAIN_HOST_ARCH).deb - -# ---------------------------------------------------------------------------- -# Image -# ---------------------------------------------------------------------------- - -$(IMAGE_TOOLCHAIN_DEB_IMAGE): $(STATEDIR)/world.cleanup - @$(call targetinfo) - @mkdir -p $(dir $@) - @scripts/make_deb.sh -d "$(@)" -s "$(PTXCONF_SYSROOT_CROSS)" - @$(call finish) - -# vim: syntax=make diff --git a/scripts/make_deb.sh b/scripts/make_deb.sh deleted file mode 100755 index 9dc3298..0000000 --- a/scripts/make_deb.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash - -main() { - while getopts "d:s:" opt; do - case "${opt}" in - d) - local deb="${OPTARG}" - ;; - s) - local src="${OPTARG}" - esac - done - - if [ -z "${deb}" -o -z "${src}" ]; then - exit 1 - fi - - local ifs_orig="${IFS}" - IFS="_" - set -- ${deb} - IFS="${ifs_orig}" - - local package="${1##*/}" - local inst="${1%${package}}" - local version="${2}" - local arch="${3%%.deb}" - - local prefix="opt/${src##*/opt/}" - local destdir="${src%${prefix}}" - local debian_tmp="${inst}/${package}-temp" - if [ -e "${debian_tmp}" ]; then - rm -rf "${debian_tmp}" - fi - - mkdir -p "${debian_tmp}"/{tmp,debian} - - cat < "${debian_tmp}/debian/control" -Source: oselas.toolchain -Maintainer: Pengutronix -Uploaders: $(git config user.name) <$(git config user.email)> -Section: devel -Priority: optional -Origin: pengutronix -Homepage: https://www.pengutronix.de/software/toolchain.html -Bugs: mailto:bugs@pengutronix.de - -Package: ${package} -Architecture: ${arch} -Depends: \${shlibs:Depends} -Description: ${package} -EOF - cat < "${debian_tmp}/debian/changelog" -oselas.toolchain (${version}) unstable; urgency=low - - * New upstream release. - - -- $(git config user.name) <$(git config user.email)> $(date -R) -EOF - cat < "${debian_tmp}/debian/compat" -9 -EOF - # copy data - echo "Copy data..." - tar -C "${destdir}" --exclude=gcc-first -c "${prefix}" | tar -C "${debian_tmp}/tmp" -x - - ( - cd "${debian_tmp}" - - # generate dependencies - echo "Generate dependencies..." - local sysroot="$(ptxd_get_ptxconf PTXCONF_SYSROOT_TARGET)" - sysroot="${debian_tmp}/tmp${sysroot#${PTX_AUTOBUILD_DESTDIR}}" - local other="$(ptxd_get_ptxconf PTXCONF_SYSROOT_CROSS)" - other="${debian_tmp}/tmp${other#${PTX_AUTOBUILD_DESTDIR}}/$(ptxd_get_ptxconf PTXCONF_GNU_TARGET)" - - fakeroot dh_shlibdeps \ - -P"${debian_tmp}/tmp" \ - -X/$(ptxd_get_ptxconf PTXCONF_GNU_TARGET)/lib/ \ - -X/sysroot-$(ptxd_get_ptxconf PTXCONF_GNU_TARGET)/ \ - -- \ - -T"${debian_tmp}/substvars" && - - # generate DEBIAN/control - dpkg-gencontrol \ - -P"${debian_tmp}/tmp" \ - -T"${debian_tmp}/substvars" - ) || exit - - # make a deb out of it - echo dpkg-deb --build -Zxz "${debian_tmp}/tmp" "${deb}" | fakeroot - - rm -rf "${debian_tmp}" -} - - -main "${@}" -exit $? -- cgit v1.2.3