You are not logged in.

#1 2020-04-15 13:34:44

Badgy
Member
Registered: 2019-10-27
Posts: 3

Handling deprecated symlinks in PKGBUILD

I maintain a python package on the AUR and I've run into a minor issue. Up until now I have been installing everything manually and symlinking the main file to /usr/bin in the PKGBUILD. An example, assuming this package is named package

package() {
    cd "$srcdir/${_pkgname}"
    mkdir -p "$pkgdir/usr/lib/package"

    install package.py -t "$pkgdir/usr/lib/package"

    ln -s "/usr/lib/package/package.py" "$pkgdir/usr/bin/package"
}

I've recently done a major restructure in the project, and I wanted to start using python setuptools to install instead. My setup.py looks something like this

setup(
    name='package',
    version='1.3',
    license='GPL3',
    url='https://github.com/User/package',
    download_url='https://github.com/User/package/archive/v1.3.tar.gz',
    packages=['package'],
    entry_points={
        'console_scripts': [
            'package = package.main:run'
        ]
    }
)

where package.main:run is equivalent to the old main file, i.e. /usr/bin/package. Performing a test run then yields this error

ModuleNotFoundError: No module named 'package.main'; 'package' is not a package

and I found that, while the main file is actually overwritten, the symlink still exists, and the issue can be solved by removing the main file before installing.

My question is, is there any proper way to handle this? Can I simply rm the file in the package() section of the PKGBUILD before running setup.py, or is that not common practice?

Offline

#2 2020-04-19 05:44:42

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Handling deprecated symlinks in PKGBUILD

I'm not even sure what this question means, since a setup.py console_scripts entry for 'package = package.main:run' will create a file "$pkgdir/usr/bin/package" during python setup.py install --root="$pkgdir". Why does the symlink exist at all? Isn't it part of the old PKGBUILD, which is now overwritten by the new version of the package?


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

Offline

#3 2020-04-19 11:37:20

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,846

Re: Handling deprecated symlinks in PKGBUILD

Is the old symlink causing issues while building the package or at installation ?

If the latter, commands in the pre_upgrade section of a .install script* could be used to remove the old symlink .
Check https://wiki.archlinux.org/index.php/PKGBUILD#install


*maybe a pacman hook could also do this, but a .install feels like the right tool for this job to me.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#4 2020-04-19 13:58:11

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Handling deprecated symlinks in PKGBUILD

Lone_Wolf wrote:

Is the old symlink causing issues while building the package or at installation ?

If the latter, commands in the pre_upgrade section of a .install script* could be used to remove the old symlink .
Check https://wiki.archlinux.org/index.php/PKGBUILD#install

... did you try that?

pre_upgrade sections of install scripts are run immediately before the package itself is un-tared into the system root, long after pacman has done the "looking for file conflicts" stage of its pre-transaction affairs.

Even PreTransaction alpm-hooks are run after the "looking for file conflicts" stage, though both occur pre-transaction.


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

Offline

Board footer

Powered by FluxBB