2

I want to create a Debian package to be used in my company. The default policy for such custom packages is to install them in a non standard directory, ie not in /usr.

I try to stick to Debian tools as much as I can, but I can't find a way to tell pybuild to install my package in /opt/python-mypackage/mypackageversion.

Here is the actual rules file:

#!/usr/bin/make -f
DH_VERBOSE = 1
export PYBUILD_NAME = mypackage-0.8.2
export PYBUILD_INSTALL_ARGS=--prefix=/opt/python-mypackage/0.8.2 --install-layout=deb

%:
    dh $@ --with python2,python3 --buildsystem=pybuild

The log of the packaging process shows that files are installed in /usr:

(...)
running install_scripts
Installing mypackage script to /<<PKGBUILDDIR>>/debian/python-mypackage/usr/bin
I: pybuild base:170: /usr/bin/python3 setup.py install --root /<<PKGBUILDDIR>>/debian/python3-mypackage --prefix=/opt/python-mypackage/0.8.2 --install-layout=deb
running install
running build
running build_py
running install_lib
creating /<<PKGBUILDDIR>>/debian/python3-mypackage
creating /<<PKGBUILDDIR>>/debian/python3-mypackage/usr
creating /<<PKGBUILDDIR>>/debian/python3-mypackage/usr/lib
creating /<<PKGBUILDDIR>>/debian/python3-mypackage/usr/lib/python3.4
creating /<<PKGBUILDDIR>>/debian/python3-mypackage/usr/lib/python3.4/dist-packages
copying /<<PKGBUILDDIR>>/.pybuild/pythonX.Y_3.4/build/mypackage.py -> /<<PKGBUILDDIR>>/debian/python3-mypackage/usr/lib/python3.4/dist-packages
byte-compiling /<<PKGBUILDDIR>>/debian/python3-mypackage/usr/lib/python3.4/dist-packages/mypackage.py to mypackage.cpython-34.pyc
(...)

Any idea on how to tweak pybuild for my needs (beside not using pybuild) ?

Frodon
  • 3,684
  • 1
  • 16
  • 33
  • the "default policy" for Debian packages (regardless of their origin) is to install into `/usr/`. why do you want to change that? – umläute Jan 27 '20 at 12:08
  • It's not on my watch but imposed by our company rules. We provide module files to configure environment for such packages. – Frodon Jan 27 '20 at 12:15

1 Answers1

1

The only solution that I found was to override the dh_install target, resulting in the following rules file:

#!/usr/bin/make -f
#DH_VERBOSE = 1
export PYBUILD_NAME = mypackage-0.8.2
MYPACKAGE_DIR = /opt/python-mypackage/0.8.2

%:
    dh $@ --with python2,python3 --buildsystem=pybuild

override_dh_install:
    dh_install

    mkdir -p $(CURDIR)/debian/python-mypackage-0.8.2$(MYPACKAGE_DIR)
    mv $(CURDIR)/debian/python-mypackage-0.8.2/usr/* $(CURDIR)/debian/python-mypackage-0.8.2$(MYPACKAGE_DIR)
    rmdir $(CURDIR)/debian/python-mypackage-0.8.2/usr

    mkdir -p $(CURDIR)/debian/python3-mypackage-0.8.2$(MYPACKAGE_DIR)
    mv $(CURDIR)/debian/python3-mypackage-0.8.2/usr/* $(CURDIR)/debian/python3-mypackage-0.8.2$(MYPACKAGE_DIR)
    rmdir $(CURDIR)/debian/python3-mypackage-0.8.2/usr
Frodon
  • 3,684
  • 1
  • 16
  • 33