LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-01-2022, 06:10 AM   #1
jwoithe
Member
 
Registered: Oct 2019
Posts: 75

Rep: Reputation: 99
[Slackware64-current] Bug in removepkg


Completely by accident I have stumbled across what appears to be a bug in removepkg. In short, if the path to the package file given at install time starts with "./" (or simply includes "./") and the package tarball did not include a "./" entry, removepkg will not remove the package's files if called upon to do so in the future. For example, if a package is installed using
Code:
installpkg foobar-1.2-x86_64-1.tgz
then its files will be correctly removed by running
Code:
removepkg foobar
If however the installation command was
Code:
installpkg ./pkgs/foobar-1.2-x86_64-1.tgz
then its files will not be removed by the removepkg command.

The cause of the problem is probably the logic used to set TRIGGER at line 354-355. The intent of the conditional is to select the block of lines which start with a "./" if such an entry is found (which will be the case with a fully slackware-compliant tarball). However, for packages which for one reason or another do not include this entry but which happened to have a leading "./" specified in their path at install time, the logic breaks down and results in an empty delete_list. The presence of "./" in the "PACKAGE LOCATION" tricks the script into thinking that there's a "./" entry in the file list when there isn't. Thus the sed command used to create delete_list returns nothing.

I suspect the fix is to use "^./" as the argument to fgrep in line 354. This will cause TRIGGER to be set to "^./" only if there really is a line which starts with "./": the inclusion of "./" in the "PACKAGE LOCATION" entry will be ignored for the purposes of the test.

There are potentially only hours to go before the release of Slackware 15.0 so I realise that it might be too late even for a bugfix (even though it would be nice). However, it would be good if a fix for this issue could be added to removepkg soon after the next development cycle begins.
 
Old 02-01-2022, 06:27 AM   #2
marav
LQ Sage
 
Registered: Sep 2018
Location: Gironde
Distribution: Slackware
Posts: 5,441

Rep: Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191
Quote:
Originally Posted by jwoithe View Post
then its files will not be removed by the removepkg command.
This, has never happened here
Code:
blackstar :: / » sudo installpkg ./tmp/pyudev-0.23.1-x86_64-1_SBo.tgz 
Verifying package pyudev-0.23.1-x86_64-1_SBo.tgz.
Installing package pyudev-0.23.1-x86_64-1_SBo.tgz:
PACKAGE DESCRIPTION:
# pyudev (pure Python libudev binding)
#
# pyudev is an LGPL licensed, pure Python 2/3 binding to libudev, the
# device and hardware management and information library of Linux.
#
# homepage: http://pyudev.readthedocs.org
#
Package pyudev-0.23.1-x86_64-1_SBo.tgz installed.
Code:
blackstar :: / » sudo removepkg pyudev-0.23.1-x86_64-1_SBo 
Removing package: pyudev-0.23.1-x86_64-1_SBo
Removing files:
  --> Deleting /usr/doc/pyudev-0.23.1/CHANGES.rst
  --> Deleting /usr/doc/pyudev-0.23.1/COPYING
  --> Deleting /usr/doc/pyudev-0.23.1/README.rst
  --> Deleting /usr/doc/pyudev-0.23.1/pyudev.SlackBuild
...
  --> Deleting empty directory /usr/lib64/python2.7/site-packages/pyudev/_ctypeslib/
  --> Deleting empty directory /usr/lib64/python2.7/site-packages/pyudev/
  --> Deleting empty directory /usr/lib64/python2.7/site-packages/pyudev-0.23.1-py2.7.egg-info/
  --> Deleting empty directory /usr/doc/pyudev-0.23.1/
 
Old 02-01-2022, 06:38 AM   #3
jwoithe
Member
 
Registered: Oct 2019
Posts: 75

Original Poster
Rep: Reputation: 99
Quote:
Originally Posted by marav View Post
This, has never happened here
Since the example quoted used an SBo package I strongly suspect it is a "properly formed" slackware package. That is, it includes the "./" entry at the start of the file list. In this case, the "./" entry is found by sed and everything is good. The issue occurs if the package's file list does not start with a "./" entry and the path to the package includes "./" somewhere in it.

While one could argue that the fault is in the package (for not including a "./"), many packages don't do this for one reason or another and pkgtools tries to support such packages anyway. For the most part this support works fine, but it's broken in circumstances described in my initial post.
 
Old 02-01-2022, 06:39 AM   #4
pghvlaans
Member
 
Registered: Jan 2021
Distribution: Slackware64 {15.0,-current}, FreeBSD, stuff on QEMU
Posts: 462

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by jwoithe View Post
The intent of the conditional is to select the block of lines which start with a "./" if such an entry is found (which will be the case with a fully slackware-compliant tarball). However, for packages which for one reason or another do not include this entry but which happened to have a leading "./" specified in their path at install time, the logic breaks down and results in an empty delete_list.
Do you have a sample package to share? I'm not sure it's even possible for makepkg to generate something without a ./ directory.

EDIT: Never mind about the sample package; I managed to put something together without makepkg. And adding in the carat where you said did result in everything being deleted properly.

Last edited by pghvlaans; 02-01-2022 at 07:06 AM.
 
Old 02-01-2022, 06:43 AM   #5
marav
LQ Sage
 
Registered: Sep 2018
Location: Gironde
Distribution: Slackware
Posts: 5,441

Rep: Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191
Quote:
Originally Posted by jwoithe View Post
Since the example quoted used an SBo package I strongly suspect it is a "properly formed" slackware package. That is, it includes the "./" entry at the start of the file list. In this case, the "./" entry is found by sed and everything is good. The issue occurs if the package's file list does not start with a "./" entry and the path to the package includes "./" somewhere in it.

While one could argue that the fault is in the package (for not including a "./"), many packages don't do this for one reason or another and pkgtools tries to support such packages anyway. For the most part this support works fine, but it's broken in circumstances described in my initial post.
I think it's well summarized ;-)
 
Old 02-01-2022, 07:22 AM   #6
jwoithe
Member
 
Registered: Oct 2019
Posts: 75

Original Poster
Rep: Reputation: 99
Quote:
Originally Posted by pghvlaans View Post
Do you have a sample package to share? I'm not sure it's even possible for makepkg to generate something without a ./ directory.
Yes, I am fairly certain that the makepkg script will always include the "./" directory. The issue involves packages generated in other ways. Since pkgtools tries hard to work with such packages, it seems to me that the issue identified here ought to be addressed, especially since (as far as I can tell) it can be fixed with the addition of a single character (a "^") to the fgrep argument. To be honest, I think this ought to be done for consistency anyway since it is "^./" that sed ends up looking for by vitue of what TRIGGER is set to. The fgrep is checking for the existence of the token that will ultimately be passed to sed, so it ought to search for the exact same regex.

As to a sample package, it's fairly easy to create one:
Code:
cd /tmp
mkdir -p foo/opt/test
touch foo/opt/test/file
cd foo
tar cfz ../foo-1-x86_64-1.tgz --owner=root --group=root *
If you install this package using
Code:
installpkg foo-1-x86_64-1.tgz
then it will be correctly removed using
Code:
removepkg foo
However, if installation of the exact same package includes "./" anywhere in the name, then removepkg won't remove the package's files. Examples which will cause removepkg to fail:
Code:
installpkg ./foo-1-x86_64-1.tgz
installpkg /tmp/./foo-1-x86_64-1.tgz
Since pkgtools accept tarballs for installation without the "./" entry, it is reasonable to expect that they will uninstall. Having different behaviour at removal time just because "./" was used in the path to the package at installation is more than a little surprising.

The inconsistency is perhaps as important here as ideology. Leaving this issue unfixed on the grounds that it only affects mal-formed packages would be fair if installpkg rejected such packages. As it stands, installpkg is able to deal with packages which lack the "./" entry, and removepkg has a specific workaround for them too. It's just that the incomplete fgrep argument used as part of removepkg's workaround doesn't always work correctly for the reasons stated.

The packages I discovered this with are locally created using tar, not makepkg. makepkg is not used since running as root during package creation is awkward in the circumstances, and tar generally does the job. There's just this corner case that's triggered if one happens to use "./" in the path to the package at installation time.
 
Old 02-01-2022, 07:58 AM   #7
Windu
Member
 
Registered: Aug 2021
Distribution: Arch Linux, Debian, Slackware
Posts: 597

Rep: Reputation: Disabled
I've tried with a package which I expect to have been created with 'makepkg' and I can install and remove it properly using the example you gave with the "./" in the package pathname:
Code:
# installpkg ./Downloads/dosbox-0.74.3-x86_64-1alien.tgz
# removepkg dosbox
And "# removepkg dosbox-0.74.3-x86_64-1alien" worked too.

Slackware is not forgiving when you make mistakes, which means either you learn fast or you move to a different distro...
Why would you create packages in a manner unsupported anyway?
 
Old 02-01-2022, 08:10 AM   #8
drumz
Member
 
Registered: Apr 2005
Location: Oklahoma, USA
Distribution: Slackware
Posts: 907

Rep: Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697
Quote:
Originally Posted by Windu View Post
Why would you create packages in a manner unsupported anyway?
OP already addressed that question, and also challenged the idea of it being "unsupported."
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How and When to removepkg in -current kjhambrick Slackware 18 03-14-2018 08:23 AM
[SOLVED] current: removepkg fails to remove all files from kbd-1.15.3 package aaazen Slackware 14 09-16-2016 01:15 PM
Removepkg pkgtools and removepkg tar problem.. pepe41695 Linux - Newbie 3 08-26-2013 04:11 AM
Critical bug in removepkg kikinovak Slackware 14 11-20-2012 11:49 AM
Updating from Slackware64-current to Slackware64 13. glore2002 Slackware 4 08-28-2009 06:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration