You are not logged in.

#1 2020-03-27 19:53:14

loqs
Member
Registered: 2014-03-06
Posts: 10,644

[SOLVED] Split package packaging

Is it allowed to move files to $pkgdir/.. then back between different split packing functions?
Concrete example below.  libvirt_storage_backend_rbd.so is not generated under $srcdir so it can not be installed from there.
make install could be executed in build() but that loses fakeroot.

Other changes to PKGBUILD from official repository version:

  • Updated to 6.1.0

  • Dropped custom LDFLAGS=-lx11 that broke full RELRO and appears to be unneeded

  • Made pakcage reproducible [*/]

  • Removed unused dependencies

# Maintainer: Christian Rebischke <chris.rebischke@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Jonathan Wiersma <archaur at jonw dot org>

pkgbase=libvirt
pkgname=(libvirt libvirt-ceph)
pkgver=6.1.0
pkgrel=0
pkgdesc="API for controlling virtualization engines (openvz,kvm,qemu,virtualbox,xen,etc)"
arch=('x86_64')
url="https://libvirt.org/"
license=('LGPL' 'GPL3') #libvirt_parthelper links to libparted which is GPL3 only
makedepends=('lvm2' 'linux-api-headers' 'dnsmasq' 'lxc' 'open-iscsi'
             'perl' 'libxslt' 'qemu' 'parted' 'python' 'rpcsvc-proto'
             'python-docutils' 'radvd' 'ceph-libs')
depends=('gnutls' 'iptables' 'libxml2' 'polkit'
         'yajl' 'libpciaccess' 'udev' 'dbus' 'libpcap'
         'libcap-ng' 'curl' 'libsasl'
         'gcc-libs' 'iproute2' 'libnl' 'numactl' 'gettext'
         'libssh2' 'netcf' 'fuse2' 'glusterfs' 'libiscsi')
optdepends=('ebtables: required for default NAT networking'
            'dnsmasq: required for default NAT/DHCP for guests'
            'bridge-utils: for bridged networking'
            'bsd-netcat: for remote management over ssh'
            'qemu'
            'radvd'
            'dmidecode'
            'parted'
            'libvirt-ceph: for ceph support'
            'qemu-block-gluster: for qemu glusterfs support'
            'firewalld')
backup=('etc/conf.d/libvirt-guests'
  'etc/conf.d/libvirtd'
  'etc/libvirt/libvirt.conf'
  'etc/libvirt/virtlogd.conf'
  'etc/libvirt/libvirtd.conf'
  'etc/libvirt/lxc.conf'
  'etc/libvirt/nwfilter/allow-arp.xml'
  'etc/libvirt/nwfilter/allow-dhcp-server.xml'
  'etc/libvirt/nwfilter/allow-dhcp.xml'
  'etc/libvirt/nwfilter/allow-incoming-ipv4.xml'
  'etc/libvirt/nwfilter/allow-ipv4.xml'
  'etc/libvirt/nwfilter/clean-traffic.xml'
  'etc/libvirt/nwfilter/no-arp-ip-spoofing.xml'
  'etc/libvirt/nwfilter/no-arp-mac-spoofing.xml'
  'etc/libvirt/nwfilter/no-arp-spoofing.xml'
  'etc/libvirt/nwfilter/no-ip-multicast.xml'
  'etc/libvirt/nwfilter/no-ip-spoofing.xml'
  'etc/libvirt/nwfilter/no-mac-broadcast.xml'
  'etc/libvirt/nwfilter/no-mac-spoofing.xml'
  'etc/libvirt/nwfilter/no-other-l2-traffic.xml'
  'etc/libvirt/nwfilter/no-other-rarp-traffic.xml'
  'etc/libvirt/nwfilter/qemu-announce-self-rarp.xml'
  'etc/libvirt/nwfilter/qemu-announce-self.xml'
  'etc/libvirt/nwfilter/clean-traffic-gateway.xml'
  'etc/libvirt/qemu-lockd.conf'
  'etc/libvirt/qemu.conf'
  'etc/libvirt/qemu/networks/default.xml'
  'etc/libvirt/virt-login-shell.conf'
  'etc/libvirt/virtlockd.conf'
  'etc/logrotate.d/libvirtd'
  'etc/logrotate.d/libvirtd.lxc'
  'etc/logrotate.d/libvirtd.qemu'
  'etc/sasl2/libvirt.conf')
options=('emptydirs')
validpgpkeys=('C74415BA7C9C7F78F02E1DC34606B8A5DE95BC1F')
source=("https://libvirt.org/sources/${pkgname}-${pkgver}.tar.xz"{,.asc}
        'libvirtd.conf.d'
        'libvirtd-guests.conf.d'
        'libvirt.sysusers.d'
        'libvirt.tmpfiles.d')
sha512sums=('17a2641f300a4a05149261bae74ac856e9a2511a259146595d2e2412c4a0601d88369b0544ba86edc80e433a47cf828317d8de38c6ec86a1b3efaca75294a606'
            'SKIP'
            'fc0e16e045a2c84d168d42c97d9e14ca32ba0d86025135967f4367cf3fa663882eefb6923ebf04676ae763f4f459e5156d7221b36b47c835f9e531c6b6e0cd9d'
            'ef221bae994ad0a15ab5186b7469132896156d82bfdc3ef3456447d5cf1af347401ef33e8665d5b2f76451f5457aee7ea01064d7b9223d6691c90c4456763258'
            '7d1d535aaf739a6753f6819c49272c8d9b5f488e0a8553797499334a76b8631474e222b6048f2125b858e5ecc21e602face45dd02121f833d605b9ae58322982'
            'a5e39dee6efa80d76a5169901bdd5a4721534d0b0914bd7992ece67d90effec50e6d17ed84fe56f3834f17f266ca3b347f0c9bc0ee27ccfb21f01a5bea418237')
changelog=Changelog

prepare() {
  cd $pkgname-$pkgver

  sed -i 's|/sysconfig/|/conf.d/|g' \
    src/remote/libvirtd.service.in \
    tools/{libvirt-guests.service,libvirt-guests.sh,virt-pki-validate}.in \
    src/locking/virtlockd.service.in
}

build() {
  cd $pkgname-$pkgver

  mkdir build && cd build
  ../configure \
    --prefix=/usr \
    --libexec=/usr/lib/"${pkgname}" \
    --sbindir=/usr/bin \
    --with-runstatedir=/run \
    --with-hal=no \
    --disable-static \
    --with-firewalld \
    --with-firewalld-zone \
    --with-init-script=systemd \
    --with-netcf \
    --with-udev \
    --with-qemu-user=nobody \
    --with-qemu-group=kvm \
    --with-interface \
    --with-openvz=no \
    --with-vmware=no \
    --with-libxl=no \
    --with-vbox=no \
    --with-lxc \
    --with-vz=no \
    --with-bhyve=no \
    --with-esx=no \
    --with-hyperv=no \
    --with-storage-dir=no \
    --with-storage-fs=no \
    --with-storage-lvm=no \
    --with-storage-iscsi=no \
    --with-storage-iscsi_direct=no \
    --with-storage-scsi=no \
    --with-storage-mpath=no \
    --with-storage-disk=no \
    --with-storage-rbd=yes \
    --with-storage-sheepdog=no \
    --with-storage-gluster=no \
    --with-storage-zfs=no \
    --with-storage-vstorage=no \
    --with-driver-modules # --with-audit
  make
}

package_libvirt() {
  cd $pkgbase-$pkgver

  make DESTDIR="$pkgdir" -C build install

  install -D -m644 "$srcdir"/libvirtd.conf.d "$pkgdir"/etc/conf.d/libvirtd
  install -D -m644 "$srcdir"/libvirtd-guests.conf.d "$pkgdir"/etc/conf.d/libvirt-guests
  install -D -m644 "$srcdir"/libvirt.sysusers.d "$pkgdir"/usr/lib/sysusers.d/libvirt.conf
  install -D -m644 "$srcdir"/libvirt.tmpfiles.d "$pkgdir"/usr/lib/tmpfiles.d/libvirt.conf

  chown 0:102 "$pkgdir"/usr/share/polkit-1/rules.d
  chmod 0750 "$pkgdir"/usr/share/polkit-1/rules.d

  rm -rf \
    "$pkgdir"/run \
    "$pkgdir"/var/lib/libvirt/qemu \
    "$pkgdir"/var/cache/libvirt/qemu \
    "$pkgdir"/etc/sysconfig

  rm "$pkgdir"/etc/libvirt/qemu/networks/autostart/default.xml

  # Strip auto-generated UUID,  so it will be generated per-install.  Also makes build reproducible.
  sed -i '/<uuid>/d' "$pkgdir"/etc/libvirt/qemu/networks/default.xml

  # Fix permission Fix #61977
  chmod 600 "$pkgdir"/etc/libvirt/nwfilter/*.xml "$pkgdir/etc/libvirt/qemu/networks/default.xml"

  mv "$pkgdir"/usr/lib/libvirt/storage-backend/libvirt_storage_backend_rbd.so "$pkgdir"/..
}

package_libvirt-ceph() {
  depends=('ceph')
  cd $pkgbase-$pkgver
  install -dm 755 "$pkgdir"/usr/lib/libvirt/storage-backend
  mv "$pkgdir"/../libvirt_storage_backend_rbd.so "$pkgdir"/usr/lib/libvirt/storage-backend/ 
}

Last edited by loqs (2020-03-28 19:22:13)

Offline

#2 2020-03-28 11:41:24

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 8,086

Re: [SOLVED] Split package packaging

I'm not aware of a rule for this, but there are 2 methods used in repo packages .
Before going into them :
$pkgdir has a different value inside each package_foo() , using relative paths to folders above it feels error-prone and wrong to me.

first method, used in llvm package
package_llvm() moves stuff from $pkgdir to $srcdir
package_llvm-ocaml() copies same stuff from $srcdir to $pkgdir


2nd method, used in mesa package
install to folder in $srcdir during build()
each package_foo() then moves only stuff it needs to $pkgdir .


Multi-init booting with apg Openrc and systemd coexisting
Automounting : not needed, i prefer pmount
Aur helpers : makepkg + my own local repo === rarely need them

Offline

#3 2020-03-28 18:08:10

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 7,620

Re: [SOLVED] Split package packaging

The real question is why the file doesn't exist after build. You really shouldn't be building anything in package functions.

Offline

#4 2020-03-28 18:54:20

loqs
Member
Registered: 2014-03-06
Posts: 10,644

Re: [SOLVED] Split package packaging

I missed search . directories

./src/libvirt-6.1.0/build/src/.libs/libvirt_storage_backend_rbd.so

Edit:

# Maintainer: Christian Rebischke <chris.rebischke@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Jonathan Wiersma <archaur at jonw dot org>

pkgbase=libvirt
pkgname=(libvirt libvirt-ceph)
pkgver=6.1.0
pkgrel=0
pkgdesc="API for controlling virtualization engines (openvz,kvm,qemu,virtualbox,xen,etc)"
arch=('x86_64')
url="https://libvirt.org/"
license=('LGPL' 'GPL3') #libvirt_parthelper links to libparted which is GPL3 only
makedepends=('lvm2' 'linux-api-headers' 'dnsmasq' 'lxc' 'open-iscsi'
             'perl' 'libxslt' 'qemu' 'parted' 'python' 'rpcsvc-proto'
             'python-docutils' 'radvd' 'ceph-libs')
depends=('gnutls' 'iptables' 'libxml2' 'polkit'
         'yajl' 'libpciaccess' 'udev' 'dbus' 'libpcap'
         'libcap-ng' 'curl' 'libsasl'
         'gcc-libs' 'iproute2' 'libnl' 'numactl' 'gettext'
         'libssh2' 'netcf' 'fuse2' 'glusterfs' 'libiscsi')
optdepends=('ebtables: required for default NAT networking'
            'dnsmasq: required for default NAT/DHCP for guests'
            'bridge-utils: for bridged networking'
            'bsd-netcat: for remote management over ssh'
            'qemu'
            'radvd'
            'dmidecode'
            'parted'
            'libvirt-ceph: for ceph support'
            'lxc'
            'qemu-block-gluster: for qemu glusterfs support'
            'firewalld')
options=('emptydirs')
validpgpkeys=('C74415BA7C9C7F78F02E1DC34606B8A5DE95BC1F')
source=("https://libvirt.org/sources/${pkgname}-${pkgver}.tar.xz"{,.asc}
        'libvirtd.conf.d'
        'libvirtd-guests.conf.d'
        'libvirt.sysusers.d'
        'libvirt.tmpfiles.d')
sha512sums=('17a2641f300a4a05149261bae74ac856e9a2511a259146595d2e2412c4a0601d88369b0544ba86edc80e433a47cf828317d8de38c6ec86a1b3efaca75294a606'
            'SKIP'
            'fc0e16e045a2c84d168d42c97d9e14ca32ba0d86025135967f4367cf3fa663882eefb6923ebf04676ae763f4f459e5156d7221b36b47c835f9e531c6b6e0cd9d'
            'ef221bae994ad0a15ab5186b7469132896156d82bfdc3ef3456447d5cf1af347401ef33e8665d5b2f76451f5457aee7ea01064d7b9223d6691c90c4456763258'
            '7d1d535aaf739a6753f6819c49272c8d9b5f488e0a8553797499334a76b8631474e222b6048f2125b858e5ecc21e602face45dd02121f833d605b9ae58322982'
            'a5e39dee6efa80d76a5169901bdd5a4721534d0b0914bd7992ece67d90effec50e6d17ed84fe56f3834f17f266ca3b347f0c9bc0ee27ccfb21f01a5bea418237')
changelog=Changelog

prepare() {
  cd $pkgname-$pkgver

  sed -i 's|/sysconfig/|/conf.d/|g' \
    src/remote/libvirtd.service.in \
    tools/{libvirt-guests.service,libvirt-guests.sh,virt-pki-validate}.in \
    src/locking/virtlockd.service.in
}

build() {
  cd $pkgname-$pkgver

  mkdir build && cd build
  ../configure \
    --prefix=/usr \
    --libexec=/usr/lib/"${pkgname}" \
    --sbindir=/usr/bin \
    --with-runstatedir=/run \
    --with-hal=no \
    --disable-static \
    --with-firewalld \
    --with-firewalld-zone \
    --with-init-script=systemd \
    --with-netcf \
    --with-udev \
    --with-qemu-user=nobody \
    --with-qemu-group=kvm \
    --with-interface \
    --with-openvz=no \
    --with-vmware=no \
    --with-libxl=no \
    --with-vbox=no \
    --with-lxc \
    --with-vz=no \
    --with-bhyve=no \
    --with-esx=no \
    --with-hyperv=no \
    --with-storage-dir=no \
    --with-storage-fs=no \
    --with-storage-lvm=no \
    --with-storage-iscsi=no \
    --with-storage-iscsi_direct=no \
    --with-storage-scsi=no \
    --with-storage-mpath=no \
    --with-storage-disk=no \
    --with-storage-rbd=yes \
    --with-storage-sheepdog=no \
    --with-storage-gluster=no \
    --with-storage-zfs=no \
    --with-storage-vstorage=no \
    --with-driver-modules # --with-audit
  make
}

package_libvirt() {
backup=('etc/conf.d/libvirt-guests'
  'etc/conf.d/libvirtd'
  'etc/libvirt/libvirt.conf'
  'etc/libvirt/virtlogd.conf'
  'etc/libvirt/libvirtd.conf'
  'etc/libvirt/lxc.conf'
  'etc/libvirt/nwfilter/allow-arp.xml'
  'etc/libvirt/nwfilter/allow-dhcp-server.xml'
  'etc/libvirt/nwfilter/allow-dhcp.xml'
  'etc/libvirt/nwfilter/allow-incoming-ipv4.xml'
  'etc/libvirt/nwfilter/allow-ipv4.xml'
  'etc/libvirt/nwfilter/clean-traffic.xml'
  'etc/libvirt/nwfilter/no-arp-ip-spoofing.xml'
  'etc/libvirt/nwfilter/no-arp-mac-spoofing.xml'
  'etc/libvirt/nwfilter/no-arp-spoofing.xml'
  'etc/libvirt/nwfilter/no-ip-multicast.xml'
  'etc/libvirt/nwfilter/no-ip-spoofing.xml'
  'etc/libvirt/nwfilter/no-mac-broadcast.xml'
  'etc/libvirt/nwfilter/no-mac-spoofing.xml'
  'etc/libvirt/nwfilter/no-other-l2-traffic.xml'
  'etc/libvirt/nwfilter/no-other-rarp-traffic.xml'
  'etc/libvirt/nwfilter/qemu-announce-self-rarp.xml'
  'etc/libvirt/nwfilter/qemu-announce-self.xml'
  'etc/libvirt/nwfilter/clean-traffic-gateway.xml'
  'etc/libvirt/qemu-lockd.conf'
  'etc/libvirt/qemu.conf'
  'etc/libvirt/qemu/networks/default.xml'
  'etc/libvirt/virt-login-shell.conf'
  'etc/libvirt/virtlockd.conf'
  'etc/logrotate.d/libvirtd'
  'etc/logrotate.d/libvirtd.lxc'
  'etc/logrotate.d/libvirtd.qemu'
  'etc/sasl2/libvirt.conf')

  cd $pkgbase-$pkgver

  make DESTDIR="$pkgdir" -C build install

  install -D -m644 "$srcdir"/libvirtd.conf.d "$pkgdir"/etc/conf.d/libvirtd
  install -D -m644 "$srcdir"/libvirtd-guests.conf.d "$pkgdir"/etc/conf.d/libvirt-guests
  install -D -m644 "$srcdir"/libvirt.sysusers.d "$pkgdir"/usr/lib/sysusers.d/libvirt.conf
  install -D -m644 "$srcdir"/libvirt.tmpfiles.d "$pkgdir"/usr/lib/tmpfiles.d/libvirt.conf

  chown 0:102 "$pkgdir"/usr/share/polkit-1/rules.d
  chmod 0750 "$pkgdir"/usr/share/polkit-1/rules.d

  rm -rf \
    "$pkgdir"/run \
    "$pkgdir"/var/lib/libvirt/qemu \
    "$pkgdir"/var/cache/libvirt/qemu \
    "$pkgdir"/etc/sysconfig

  rm "$pkgdir"/etc/libvirt/qemu/networks/autostart/default.xml

  # Strip auto-generated UUID,  so it will be generated per-install.  Also makes build reproducible.
  sed -i '/<uuid>/d' "$pkgdir"/etc/libvirt/qemu/networks/default.xml

  # Fix permission Fix #61977
  chmod 600 "$pkgdir"/etc/libvirt/nwfilter/*.xml "$pkgdir/etc/libvirt/qemu/networks/default.xml"

  rm "$pkgdir"/usr/lib/libvirt/storage-backend/libvirt_storage_backend_rbd.so
}

package_libvirt-ceph() {
  depends=('ceph')

  cd $pkgbase-$pkgver
  install -dm 755 "$pkgdir"/usr/lib/libvirt/storage-backend
  install -Dm 755 build/src/.libs/libvirt_storage_backend_rbd.so "$pkgdir"/usr/lib/libvirt/storage-backend/libvirt_storage_backend_rbd.so
}

Last edited by loqs (2020-03-28 20:27:59)

Offline

#5 2020-03-29 23:23:35

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 3,321

Re: [SOLVED] Split package packaging

You could also use make's own sub-install targets, e.g. make -C src/ install-libLTLIBRARIES to install a subset of files in that package function, then delete the ones you don't need. The .libs/ directory is technically an implementation detail of autotools, though realistically it's never going to change. install-libLTLIBRARIES is a public interface.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB