From: Stefan Schantl Date: Wed, 26 Apr 2023 09:57:52 +0000 (+0200) Subject: Build: Allow to build debian packages of pakfire X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fdebian-build;p=people%2Fstevee%2Fpakfire.git Build: Allow to build debian packages of pakfire Signed-off-by: Stefan Schantl --- diff --git a/Makefile.am b/Makefile.am index e70b08ce..365be928 100644 --- a/Makefile.am +++ b/Makefile.am @@ -932,3 +932,19 @@ EXTRA_DIST += \ .PHONY: clean-local-check clean-local-check: -rm -rf $(TEST_ROOTFS)/* + +EXTRA_DIST += \ + debian/build.sh \ + debian/changelog \ + debian/control \ + debian/copyright \ + debian/genchangelog.sh \ + debian/libpakfire0.install \ + debian/libpakfire-dev.install \ + debian/pakfire.install \ + debian/rules \ + debian/source/format + +.PHONY: debian +debian: dist + $(SHELL) debian/build.sh $(PACKAGE_NAME)-$(PACKAGE_VERSION) $(distdir).tar.gz diff --git a/debian/build.sh b/debian/build.sh new file mode 100644 index 00000000..4b955b8b --- /dev/null +++ b/debian/build.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +ARCHITECTURES=( amd64 ) +RELEASES=( bullseye ) + +CHROOT_PATH="/var/tmp" + +main() { + if [ $# -lt 2 ]; then + echo "Not enough arguments" >&2 + return 2 + fi + + # Get host architecture + local host_arch="$(dpkg --print-architecture)" + if [ -z "${host_arch}" ]; then + echo "Could not discover host architecture" >&2 + return 1 + fi + + local package="${1}" + local sources="${2}" + + # Create some temporary directory + local tmp="$(mktemp -d)" + + # Extract the sources into it + mkdir -p "${tmp}/sources" + tar xvfa "${sources}" -C "${tmp}/sources" + + # Copy the tarball under the correct Debian name + cp -vf "${sources}" "${tmp}/sources/${package//-/_}.orig.tar.gz" + + # Change into temporary directory + pushd "${tmp}" + + # Build the package for each release + local release + for release in ${RELEASES[@]}; do + local chroot="${release}-${host_arch}-sbuild" + + mkdir -p "${release}" + pushd "${release}" + + # Create a chroot environment + if [ ! -d "/etc/sbuild/chroot/${chroot}" ]; then + if ! sbuild-createchroot --arch="${host_arch}" "${release}" \ + "${CHROOT_PATH}/${chroot}"; then + echo "Could not create chroot for ${release} on ${host_arch}" >&2 + rm -rf "${tmp}" + return 1 + fi + fi + + # And for each architecture we want to support + local arch + for arch in ${ARCHITECTURES[@]}; do + mkdir -p "${arch}" + pushd "${arch}" + + # Copy sources + cp -r "${tmp}/sources" . + + # Run the build process + if ! sbuild --dist="${release}" --host="${arch}" --source "sources/${package}"; then + echo "Could not build package for ${release} on ${arch}" >&2 + rm -rf "${tmp}" + return 1 + fi + + # Remove the sources + rm -rf "sources/${package}" + popd + done + popd + done + + # Remove sources + rm -rf "${tmp}/sources" + popd + + # Done! + echo "SUCCESS!" + echo " You can find your Debian packages in ${tmp}" + return 0 +} + +main "$@" || exit $? diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..5e6284dd --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +pakfire (0.9.28-1) unstable; urgency=medium + + * Initial release. + + -- Stefan Schantl Sun, 27 Oct 2019 18:55:44 +0100 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..789fb95e --- /dev/null +++ b/debian/control @@ -0,0 +1,88 @@ +Source: pakfire +Maintainer: Stefan Schantl +Section: misc +Priority: optional +Standards-Version: 4.6.1 +Build-Depends: + debhelper-compat (= 13), + dh-sequence-python3, + asciidoc, + autoconf, + automake, + bison, + flex, + intltool, + libarchive-dev, + libcap-dev, + libcurl4-openssl-dev, + libelf-dev, + libgpgme-dev, + libjson-c-dev, + liblzma-dev, + libmagic-dev, + libmount-dev, + libpcre2-dev, + libseccomp-dev, + libsolv-dev, + libsqlite3-dev, + libssl-dev, + libsystemd-dev, + libzstd-dev, + pkg-config, + python3-all-dev, + python3-cpuinfo, + python3-kerberos, + python3-systemd, + python3-tornado, + python3-psutil, + python3-setproctitle, + systemd, + uuid-dev, + xsltproc, + docbook-xsl, + git, +Rules-Requires-Root: no +Homepage: https://pakfire.ipfire.org/ +Vcs-Git: https://git.ipfire.org/pub/git/pakfire/pakfire.git +Vcs-Browser: https://git.ipfire.org/pub/git/pakfire/pakfire.git +Description: Package management and build system for IPFire 3.x. + Pakfire combines the package management and the build system for IPFire 3.x + in one tool. + +Package: libpakfire0 +Architecture: any +Section: libs +Depends: + ${shlibs:Depends}, + ${misc:Depends}, +Recommends: + pakfire, +Multi-Arch: same +Description: ${source:Synopsis} + ${source:Extended-Description} + . + This package provides the shared library. + +Package: libpakfire-dev +Architecture: any +Section: libdevel +Depends: + libpakfire0 (= ${binary:Version}), + ${misc:Depends}, +Multi-Arch: same +Description: ${source:Synopsis} (development files) + ${source:Extended-Description} + . + This package provides the headers and development files needed to use + libpakfire in your own programs. + +Package: pakfire +Architecture: any +Depends: + ${misc:Depends}, + ${python3:Depends}, + ${shlibs:Depends}, +Description: ${source:Synopsis} + ${source:Extended-Description} + . + This package provides the pakfire tools. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..e4c3a2d3 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,26 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: pakfire +Upstream-Contact: Michael Tremer +Source: https://source.ipfire.org/releases/pakfire/ + +Files: * +Copyright: 2017-2023 IPFire Development team +License: LGPL-2.1 + +Files: debian/* +Copyright: 2023 Stefan Schantl +License: LGPL-2.1 + +License: LGPL-2.1 + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; version 2.1 of the License, or (at + your option) any later version. + . + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + . + The complete text of the GNU General Public License + can be found in /usr/share/common-licenses/LGPL-2.1 file. + . diff --git a/debian/genchangelog.sh b/debian/genchangelog.sh new file mode 100755 index 00000000..ab1c1980 --- /dev/null +++ b/debian/genchangelog.sh @@ -0,0 +1,38 @@ +#!/bin/bash -e +gitshow () { + local format=$1 + local commit=$2 + + git show --no-patch --format=format:"$format" "$commit" +} + +main () { + if [ $# -lt 1 ]; then + local bn="$(basename $0)" + echo "Usage: $bn " >&2 + echo "Example: $bn 0.9.7..HEAD" >&2 + echo "Example: $bn 0.9.5..0.9.6^" >&2 + return 1 + fi + + local commitrange=$1 + + local commit + for commit in $(git rev-list --reverse "$commitrange"); do + # Skip commits with diffs that only have Makefile.am or d/ changes. + if [ "$(git diff --name-only "${commit}^..${commit}" -- . ':^Makefile.am' ':^debian/' | wc -l)" == 0 ]; then + continue + fi + + local author_name="$(gitshow %an "$commit")" + local author_email="$(gitshow %ae "$commit")" + local subject="$(gitshow %s "$commit")" + + echo "$author_name <$author_email> $subject" + DEBFULLNAME="$author_name" DEBEMAIL="$author_email" debchange --upstream --multimaint-merge "$subject" + done + + debchange --release '' +} + +main "$@" || exit $? diff --git a/debian/gensymbols.sh b/debian/gensymbols.sh new file mode 100755 index 00000000..85235565 --- /dev/null +++ b/debian/gensymbols.sh @@ -0,0 +1,50 @@ +#!/bin/bash +SYMBOLS_PKG=libloc1 +LOCAL_FILE=debian/libloc1.symbols +TEMP_FILE="$(mktemp --tmpdir libloc1.XXXXXX.symbols)" +trap "rm -f ${TEMP_FILE}" EXIT + +generate () { + intltoolize --force --automake + autoreconf --install --symlink + ./configure CFLAGS='-g -O0' --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib + + make + + dpkg-gensymbols -p"$SYMBOLS_PKG" -O"$TEMP_FILE" -esrc/.libs/libloc.so.* + sed -i -E -e 's/( [0-9\.]+)-.+$/\1/' "$TEMP_FILE" + + make clean +} + +main () { + local maxver='0.0.0' + if [ -f "$LOCAL_FILE" ]; then + cp "$LOCAL_FILE" "$TEMP_FILE" + maxver="$(grep -E '^ ' "$LOCAL_FILE" | cut -d' ' -f3 | sort -Vru | head -n1)" + echo "Latest version checked: $maxver" + fi + + + local tag + for tag in $(git tag -l --sort=version:refname) + do + if [ "$(echo -e "${maxver}\n${tag}" | sort -Vr | head -n1)" == "$maxver" ]; then + echo "Tag $tag -- skip" + continue + fi + + echo "Tag $tag -- checking" + git switch --quiet --detach "$tag" || return 1 + generate || return 1 + git switch --quiet - || return 1 + done + + echo "Current -- checking" + generate || return 1 + + mv "$TEMP_FILE" "$LOCAL_FILE" + chmod 644 "$LOCAL_FILE" +} + +main "$@" || exit $? diff --git a/debian/libpakfire-dev.install b/debian/libpakfire-dev.install new file mode 100644 index 00000000..5ca31382 --- /dev/null +++ b/debian/libpakfire-dev.install @@ -0,0 +1,2 @@ +usr/include/pakfire +usr/lib/*/libpakfire.so diff --git a/debian/libpakfire0.install b/debian/libpakfire0.install new file mode 100644 index 00000000..47facd73 --- /dev/null +++ b/debian/libpakfire0.install @@ -0,0 +1 @@ +usr/lib/*/libpakfire.so.* diff --git a/debian/pakfire.install b/debian/pakfire.install new file mode 100644 index 00000000..1f759156 --- /dev/null +++ b/debian/pakfire.install @@ -0,0 +1,6 @@ +etc/pakfire/* +lib/systemd/* +usr/bin/* +usr/lib/pakfire/* +usr/lib/python3* +usr/share/* diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..ce35ff2f --- /dev/null +++ b/debian/rules @@ -0,0 +1,23 @@ +#!/usr/bin/make -f + +export DEB_BUILD_MAINT_OPTIONS=hardening=+all + +export PYBUILD_SYSTEM=custom + +export PYBUILD_CLEAN_ARGS=dh_auto_clean + +export PYBUILD_CONFIGURE_ARGS=intltoolize --force --automake; \ + PYTHON={interpreter} dh_auto_configure -- + +export PYBUILD_BUILD_ARGS=dh_auto_build + +export PYBUILD_INSTALL_ARGS=dh_auto_install --destdir={destdir}; \ + mkdir -p {destdir}/usr/lib/python{version}/dist-packages; \ + mv -v {destdir}/usr/lib/python3/dist-packages/pakfire {destdir}/usr/lib/python{version}/dist-packages/pakfire; \ + rm -vf {destdir}/usr/lib/python*/*-packages/pakfire/_pakfire.la; \ + rm -vf {destdir}/usr/lib/*/libpakfire.la + +#export PYBUILD_TEST_ARGS=dh_auto_test + +%: + dh $@ --buildsystem=pybuild diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 00000000..163aaf8d --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt)