Skip to content

Instantly share code, notes, and snippets.

@MarkWalters-dev
Last active February 24, 2021 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkWalters-dev/7a7e36c4a99c15e7b355ba12e3857d65 to your computer and use it in GitHub Desktop.
Save MarkWalters-dev/7a7e36c4a99c15e7b355ba12e3857d65 to your computer and use it in GitHub Desktop.
PKGBUILD for apt
# Maintainer: Moses Narrow <moe_narrow@use.startmail.com>
# Co-Maintainer: Felix Golatofski <contact@xdfr.de>
# Contributor: Mark Weiman <mark.weiman@markzz.com>
# Contributor: Johannes Dewender arch at JonnyJD dot net
# Contributor: Tony Lambiris <tony@critialstack.com>
pkgbase=apt
pkgname=('apt' 'apt-docs')
pkgver=2.2.0
pkgrel=1
arch=('i686' 'x86_64')
url="http://packages.debian.org"
license=('GPL2')
makedepends=('cmake' 'dpkg' 'docbook-xsl' 'doxygen' 'git' 'gtest' 'w3m' 'triehash'
'perl-text-wrapi18n' 'perl-locale-gettext' 'perl-yaml-tiny'
'perl-term-readkey' 'perl-sgmls' 'perl-module-build' 'perl-unicode-linebreak' 'perl-pod-parser' 'po4a' 'xxhash')
provides=('libapt-inst' 'libapt-pkg' 'libapt-pkg-dev' "apt-utils")
source=("git+https://salsa.debian.org/apt-team/apt.git#tag=${pkgver}"
"https://github.com/mquinson/po4a/releases/download/v0.60/po4a-0.60.tar.gz")
sha256sums=('SKIP'
'c8d9c28758fa007e8e2989b5820c55910a6533dab581208d0c8acf4d43027b59')
build() {
# arch linux's po4a is too new to build apt, so build an older version
# will likely be good to use system po4a when it's updated in sid
msg2 "Building po4a 0.60..."
cd "$srcdir/po4a-0.60"
perl Build.PL installdirs=vendor create_packlist=0
LC_ALL=en_US.UTF-8 perl Build
[[ "$PATH" =~ /usr/bin/vendor_perl ]] || export PATH="$PATH:/usr/bin/vendor_perl"
msg2 "Building apt..."
cd "$srcdir/$pkgname"
# docbook xsl is stored with the version on Arch
DOCBOOK_XSL_VER=`ls -d /usr/share/xml/docbook/xsl-stylesheets-* | sort | head -1 | xargs basename`
cmake -B build \
-DCMAKE_INSTALL_PREFIX="/usr" \
-DCMAKE_INSTALL_LIBDIR="lib" \
-DCMAKE_INSTALL_LIBEXECDIR="lib" \
-DDOCBOOK_XSL="/usr/share/xml/docbook/${DOCBOOK_XSL_VER}-nons"
sed -i -e "s|stylesheet/docbook-xsl|$DOCBOOK_XSL_VER=t|" build/doc/*.xsl
sed -i -e "s|stylesheet/nwalsh|$DOCBOOK_XSL_VER=|" build/doc/*.xsl
make -C build all
}
package_apt() {
depends=('gnupg' 'curl' 'libseccomp' 'perl' 'xxhash')
pkgdesc="Command-line package manager used on Debian-based systems"
cd "$srcdir/$pkgbase"
make -C build DESTDIR="${pkgdir}" install
rm -rf "${pkgdir}/usr/share/doc"
find "$pkgdir/usr/share/man" -type d -empty -delete
}
package_apt-docs() {
arch=('any')
pkgdesc="Documentation for apt"
cd "$srcdir/$pkgbase"
make -C build DESTDIR="${pkgdir}" install
rm -rf "${pkgdir}"/etc
rm -rf "${pkgdir}"/var
rm -rf "${pkgdir}"/usr/{bin,include,lib}
rm -rf "${pkgdir}"/usr/share/{bash-completion,locale,man}
}
# vim:set ts=2 sw=2 et:
@MarkWalters-dev
Copy link
Author

The original fails to build with the error: /bin/sh: line 1: po4a: command not found

@MarkWalters-dev
Copy link
Author

First edit fixes the p04a error so apt builds now. It might be good enough to just replace the alias with alias po4a="/usr/bin/vendor_perl/po4a"

But now it has another error with apt-docs:

/usr/share/doc/libapt-pkg-doc/method.html/ch1.html exists in both 'apt' and 'apt-docs'
/usr/share/doc/libapt-pkg-doc/method.html/ch2.html exists in both 'apt' and 'apt-docs'
/usr/share/doc/libapt-pkg-doc/method.html/index.html exists in both 'apt' and 'apt-docs'
/usr/share/doc/libapt-pkg-doc/method.text exists in both 'apt' and 'apt-docs'
Errors occurred, no packages were upgraded.
==> WARNING: Failed to install built package(s).```

@MarkWalters-dev
Copy link
Author

The second edit fixes the exists in both 'apt' and 'apt-docs' error. It was just a typo with the doc directory.

@MarkWalters-dev
Copy link
Author

Third edit just replaced the alias with PATH.

@Un1Gfn
Copy link

Un1Gfn commented Feb 22, 2021

man pages corrupted (e.g. stray .SH .PP .RE et al. in the following screenshot)

Issue applies to both your PKGBUILD on this page and their PKGBUILD in AUR as of 2.1.7-1

Am I the only one getting this?

Is it upstream?

$ man 8 apt

Screenshot from 2021-02-22 19-49-00

$ man 5 apt.conf

Screenshot from 2021-02-22 20-00-40

@MarkWalters-dev
Copy link
Author

MarkWalters-dev commented Feb 23, 2021

I'm getting the same thing. Same problem when I tried version 2.2.0.
Looks like it works in debian sid under docker though.

git clone --depth=1 https://salsa.debian.org/apt-team/apt.git --branch 2.2.0
cd apt
cmake -B build \
  	-DCMAKE_INSTALL_PREFIX="/usr" \
  	-DCMAKE_INSTALL_LIBDIR="lib" \
  	-DCMAKE_INSTALL_LIBEXECDIR="lib" \
	-DDOCBOOK_XSL=/usr/share/xml/docbook/stylesheet/docbook-xsl
make -C build all
make -C build DESTDIR=../pkg install
man ./pkg/usr/share/man/man8/apt-get.8

I copied /usr/share/xml/docbook/stylesheet/docbook-xsl to arch and changed the first cmake to:

cmake -B build \
  	-DCMAKE_INSTALL_PREFIX="/usr" \
  	-DCMAKE_INSTALL_LIBDIR="lib" \
  	-DCMAKE_INSTALL_LIBEXECDIR="lib" \
	-DDOCBOOK_XSL=$PWD/docbook-xsl

Which works. So it's a problem with docbook-xsl. Both debian and arch are using the same version of docbook, 1.79.2. Yet the files are not the same. Did a diff between the 2 different apt builds and found a bunch of these errors: Note: namesp. add : added namespace before processing that is not present when using the debian docbook.

git clone --depth=1 https://github.com/archlinux/svntogit-packages --branch packages/docbook-xsl
cd svntogit-packages/trunk/
makepkg --needed --noconfirm -sf
cd -

Fails when using -DDOCBOOK_XSL=./svntogit-packages/trunk/pkg/docbook-xsl/usr/share/xml/docbook/xsl-stylesheets-1.79.2 but works when using -DDOCBOOK_XSL=./svntogit-packages/trunk/pkg/docbook-xsl/usr/share/xml/docbook/xsl-stylesheets-1.79.2-nons

So updated it to -DDOCBOOK_XSL="/usr/share/xml/docbook/${DOCBOOK_XSL_VER}-nons" which works for me. Does it work for you now?

@Un1Gfn
Copy link

Un1Gfn commented Feb 24, 2021

Works like a charm 🚀 Thanks

@Un1Gfn
Copy link

Un1Gfn commented Feb 24, 2021

namcap apt-2.2.0-1-x86_64.pkg.tar

  1. base depends on xz => remove xz from depends of package_apt()
  2. /usr/lib/libapt-pkg.so.6.0.0 depends on /usr/lib/libxxhash.so.0 => add xxhash to package_apt() depends
  3. /usr/lib/apt/methods/store depends on /usr/lib/libseccomp.so.2 => add libseccomp to package_apt() depends
  4. /usr/lib/dpkg/methods/apt/setup is a perl script => add perl to package_apt() depends
  5. find "$pkgdir/usr/share/man" -type d -empty -delete since the following empty directories are introduced on my machine
    • /usr/share/man/pl/man7
    • /usr/share/man/ja/man7
    • /usr/share/man/es/man7
    • /usr/share/man/it/man7

namcap apt-2.2.0-1-x86_64.pkg.tar

apt-docs W: No ELF files and not an "any" package => add overriding arch=('any') to package_apt-docs()

patch in the next comment

@Un1Gfn
Copy link

Un1Gfn commented Feb 24, 2021

orig + patch = new

patch
--- PKGBUILD
+++ PKGBUILD
@@ -48,14 +48,16 @@
 }
 
 package_apt() {
-  depends=('gnupg' 'curl' 'xz')
+  depends=('gnupg' 'curl' 'libseccomp' 'perl' 'xxhash')
   pkgdesc="Command-line package manager used on Debian-based systems"
   cd "$srcdir/$pkgbase"
   make -C build DESTDIR="${pkgdir}" install
   rm -rf "${pkgdir}/usr/share/doc"
+  find "$pkgdir/usr/share/man" -type d -empty -delete
 }
 
 package_apt-docs() {
+  arch=('any')
   pkgdesc="Documentation for apt"
   cd "$srcdir/$pkgbase"
   make -C build DESTDIR="${pkgdir}" install
new
# Maintainer: Moses Narrow <moe_narrow@use.startmail.com>
# Co-Maintainer: Felix Golatofski <contact@xdfr.de>
# Contributor: Mark Weiman <mark.weiman@markzz.com>
# Contributor: Johannes Dewender  arch at JonnyJD dot net
# Contributor: Tony Lambiris <tony@critialstack.com>

pkgbase=apt
pkgname=('apt' 'apt-docs')
pkgver=2.2.0
pkgrel=1
arch=('i686' 'x86_64')
url="http://packages.debian.org"
license=('GPL2')
makedepends=('cmake' 'dpkg' 'docbook-xsl' 'doxygen' 'git' 'gtest' 'w3m' 'triehash'
             'perl-text-wrapi18n' 'perl-locale-gettext' 'perl-yaml-tiny'
             'perl-term-readkey' 'perl-sgmls' 'perl-module-build' 'perl-unicode-linebreak' 'perl-pod-parser' 'po4a' 'xxhash')
provides=('libapt-inst' 'libapt-pkg' 'libapt-pkg-dev' "apt-utils")
source=("git+https://salsa.debian.org/apt-team/apt.git#tag=${pkgver}"
  "https://github.com/mquinson/po4a/releases/download/v0.60/po4a-0.60.tar.gz")
sha256sums=('SKIP'
            'c8d9c28758fa007e8e2989b5820c55910a6533dab581208d0c8acf4d43027b59')

build() {
  # arch linux's po4a is too new to build apt, so build an older version
  # will likely be good to use system po4a when it's updated in sid
  msg2 "Building po4a 0.60..."
  cd "$srcdir/po4a-0.60"
  perl Build.PL installdirs=vendor create_packlist=0
  LC_ALL=en_US.UTF-8 perl Build
  [[ "$PATH" =~ /usr/bin/vendor_perl ]] || export PATH="$PATH:/usr/bin/vendor_perl"

  msg2 "Building apt..."
  cd "$srcdir/$pkgname"

  # docbook xsl is stored with the version on Arch
  DOCBOOK_XSL_VER=`ls -d /usr/share/xml/docbook/xsl-stylesheets-* | sort | head -1 | xargs basename`

  cmake -B build \
    -DCMAKE_INSTALL_PREFIX="/usr" \
    -DCMAKE_INSTALL_LIBDIR="lib" \
    -DCMAKE_INSTALL_LIBEXECDIR="lib" \
  -DDOCBOOK_XSL="/usr/share/xml/docbook/${DOCBOOK_XSL_VER}-nons"

  sed -i -e "s|stylesheet/docbook-xsl|$DOCBOOK_XSL_VER=t|" build/doc/*.xsl
  sed -i -e "s|stylesheet/nwalsh|$DOCBOOK_XSL_VER=|" build/doc/*.xsl

  make -C build all
}

package_apt() {
  depends=('gnupg' 'curl' 'libseccomp' 'perl' 'xxhash')
  pkgdesc="Command-line package manager used on Debian-based systems"
  cd "$srcdir/$pkgbase"
  make -C build DESTDIR="${pkgdir}" install
  rm -rf "${pkgdir}/usr/share/doc"
  find "$pkgdir/usr/share/man" -type d -empty -delete
}

package_apt-docs() {
  arch=('any')
  pkgdesc="Documentation for apt"
  cd "$srcdir/$pkgbase"
  make -C build DESTDIR="${pkgdir}" install
  rm -rf "${pkgdir}"/etc
  rm -rf "${pkgdir}"/var
  rm -rf "${pkgdir}"/usr/{bin,include,lib}
  rm -rf "${pkgdir}"/usr/share/{bash-completion,locale,man}
}

# vim:set ts=2 sw=2 et:

@MarkWalters-dev
Copy link
Author

1-4: Good catch.
5: Yep. I see that on my machine too.
Updated my gist. Hopefully the maintainer will use these updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment