LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-12-2021, 09:36 AM   #1
stoorky
Member
 
Registered: Sep 2015
Posts: 43

Rep: Reputation: Disabled
aptitude search with archive pattern - unexpected results


Hi,

I just did some tests with "$ aptitude search", and I'm puzzled by the results.

First I tried to get all installed packages having "Debian" as origin, and "unstable" as archive :

Code:
$ aptitude search "?narrow(?installed,?and(?origin(^Debian$),?archive(^unstable$)))"
i   apt-mirror       - APT sources mirroring tool
i A cups-pk-helper   - PolicyKit helper to configure cups with fine-grained privileges
(...)
i   wmctrl           - control an EWMH/NetWM compatible X Window Manager
i A youtube-dl       - downloader of videos from web page.
Why not...

Then I tried to get all installed packages having "Debian" as origin, and not "stable" as archive :
Code:
$ aptitude search "?narrow(?installed,?and(?origin(^Debian$),?not(?archive(^stable$))))"
i A amd64-microcode  - Processor microcode firmware for AMD CPUs
i   bluez-firmware   - Firmware for Bluetooth devices
(...)                                                             
i A update-glx       - utility for switching the GLX implementation
i A youtube-dl       - downloader of videos from web page.
I expected the results of the first command to be a subset of the results of the second command (packages from archive "unstable" should be a subset of the packages of all archives except "stable"). But it's not the case, and incidentally the first set of results is much larger than the second.

Am I missing something ?
 
Old 04-12-2021, 09:49 AM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 2,321

Rep: Reputation: Disabled
I never used aptitude search terms in their long form. I'd do it like this:
Code:
aptitude search '~i~ODebian~Aunstable'
Code:
aptitude search '~i~ODebian!~Astable'
As to your question: no, your assumption is wrong.

The first command lists packages installed from unstable.

The second one lists packages installed from experimental, unstable, and testing.

Last edited by shruggy; 04-12-2021 at 09:54 AM.
 
Old 04-12-2021, 09:52 AM   #3
stoorky
Member
 
Registered: Sep 2015
Posts: 43

Original Poster
Rep: Reputation: Disabled
@shruggy
Your second command

Code:
aptitude search '~i~ODebian!~Astable'
returns nothing
 
Old 04-12-2021, 10:01 AM   #4
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 2,321

Rep: Reputation: Disabled
Ah sorry, it's a regular expression, so stable matches both stable and unstable. Try it like this:
Code:
aptitude search '~i~ODebian!~A^stable$'
 
Old 04-12-2021, 10:15 AM   #5
stoorky
Member
 
Registered: Sep 2015
Posts: 43

Original Poster
Rep: Reputation: Disabled
@shruggy
Nothing works like I (we ?) expect it to, I did some tests with your commands :

First,
Code:
aptitude search '~i~ODebian~Aunstable'
doesn't get me the packages installed from unstable, because my package "acl" for example has clearly been installed from "stable" (from the DVD in fact) :
Code:
$ aptitude search '~i~ODebian~Aunstable' | head -n 3
i A accountsservice - query and manipulate user account information
i A acl - Access control list utilities
i A adb - Android Debug Bridge

$ apt-cache policy acl
acl:
  Installed: 2.2.52-3+b1
  Candidate: 2.2.52-3+b1
  Version table:
     2.2.53-10 100
        100 http://ftp.fr.debian.org/debian sid/main amd64 Packages
     2.2.53-4 200
        200 http://ftp.fr.debian.org/debian buster/main amd64 Packages
 *** 2.2.52-3+b1 500
        500 file:/tmp/debian_dvds/amd64/debian-9.2.1-amd64-DVD-1 stretch/main amd64 Packages
        100 /var/lib/dpkg/status
Second,
As for your second command, which should lists the packages installed from experimental, unstable, and testing, well, it doesn't. The package "youtube-dl" for example has clearly been installed from unstable (sid), but it doesn't appear in the list :
Code:
$ aptitude search '~i~ODebian!~A^stable$' | tail -n 3
i A libnvidia-cfg1:i386 - NVIDIA binary OpenGL/GLX configuration library
i A libopengl0-glvnd-nvidia - Vendor neutral GL dispatch library -- libOpenGL
i A libopengl0-glvnd-nvidia:i386 - Vendor neutral GL dispatch library -- libOpenGL

$ apt-cache policy youtube-dl 
youtube-dl:
  Installed: 2021.02.10-1
  Candidate: 2021.04.07-dmo1
  Version table:
     2021.04.07-dmo1 100
        100 http://www.deb-multimedia.org stretch/main amd64 Packages
 *** 2021.02.10-1 100
        100 http://ftp.fr.debian.org/debian sid/main amd64 Packages
        100 /var/lib/dpkg/status
     2019.01.17-1.1 200
        200 http://ftp.fr.debian.org/debian buster/main amd64 Packages
     2019.01.17-1.1~bpo9+1 100
        100 http://ftp.fr.debian.org/debian stretch-backports/main amd64 Packages
     2017.05.18.1-1 500
        500 file:/tmp/debian_dvds/amd64/debian-9.2.1-amd64-DVD-2 stretch/main amd64 Packages
Does it really work on your computer ?
 
Old 04-12-2021, 10:33 AM   #6
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 2,321

Rep: Reputation: Disabled
I don't have Debian to test. Here is how I tested it on Ubuntu:
Code:
$ aptitude search '~i~OUbuntu!~A^focal$'|cat
i A libllvm11 - Modular compiler and toolchain technologies, runtime library
i A libstd-rust-1.47 - Rust standard libraries
i  linux-headers-5.4.0-31 - Header files related to Linux kernel version 5.4.0
i  linux-headers-5.4.0-33 - Header files related to Linux kernel version 5.4.0
i A linux-headers-5.4.0-67 - Header files related to Linux kernel version 5.4.0
i A linux-headers-5.4.0-67-generic - Linux kernel headers for version 5.4.0 on 64 bit x86 SMP
i A linux-headers-5.4.0-70 - Header files related to Linux kernel version 5.4.0
i A linux-headers-5.4.0-70-generic - Linux kernel headers for version 5.4.0 on 64 bit x86 SMP
i A linux-image-5.4.0-67-generic - Signed kernel image generic
i A linux-image-5.4.0-70-generic - Signed kernel image generic
i A linux-modules-5.4.0-67-generic - Linux kernel extra modules for version 5.4.0 on 64 bit x86 SMP
i A linux-modules-5.4.0-70-generic - Linux kernel extra modules for version 5.4.0 on 64 bit x86 SMP
i A linux-modules-extra-5.4.0-67-generic - Linux kernel extra modules for version 5.4.0 on 64 bit x86 SMP
i A linux-modules-extra-5.4.0-70-generic - Linux kernel extra modules for version 5.4.0 on 64 bit x86 SMP
Code:
$ apt-cache policy lib{llvm11,std-rust-1.47}
libllvm11:
  Installed: 1:11.0.0-2~ubuntu20.04.1
  Candidate: 1:11.0.0-2~ubuntu20.04.1
  Version table:
 *** 1:11.0.0-2~ubuntu20.04.1 500
        500 http://de.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        100 /var/lib/dpkg/status
libstd-rust-1.47:
  Installed: 1.47.0+dfsg1+llvm-1ubuntu1~20.04.1
  Candidate: 1.47.0+dfsg1+llvm-1ubuntu1~20.04.1
  Version table:
 *** 1.47.0+dfsg1+llvm-1ubuntu1~20.04.1 500
        500 http://de.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages
        100 /var/lib/dpkg/status
 
Old 04-12-2021, 10:46 AM   #7
stoorky
Member
 
Registered: Sep 2015
Posts: 43

Original Poster
Rep: Reputation: Disabled
@shruggy

Yes, your output seems coherent

I don't know what happens, maybe my version of aptitude is buggy. I'll try again sometime with an up-to-date version of Debian, maybe it'll solve the problem

Anyway, thanks for your help
 
Old 05-06-2021, 07:30 AM   #8
stoorky
Member
 
Registered: Sep 2015
Posts: 43

Original Poster
Rep: Reputation: Disabled
@shruggy,

Again, thanks for your help, it put me on the right path.

I think I solved the whole mystery (I hope so at least !). The interpretation of $aptitude's results is a little bit more tricky than I thought (and possibly that you thought too, I think).

Let's go over our two examples again :


FIRST EXAMPLE
Code:
$ aptitude search '~i~O^Debian$~Aunstable'
will not return all packages with origine Debian and installed from archive "unstable", like I thought (like you thought too ?). It will instead return all installed packages with origin "Debian" and available in the "unstable" archive (not necessarily installed from the "unstable" archive). They could have been installed from the "unstable" archive, but not necessarily. There is a version available in the "unstable" archive, but it's not necessarily the installed version.
Example :
Code:
$ aptitude search '~i~O^Debian$~Aunstable' | head -n 3
i A accountsservice - query and manipulate user account information
i A acl - Access control list utilities
i A adb - Android Debug Bridge

$ apt-cache policy acl
acl:
  Installed: 2.2.52-3+b1
  Candidate: 2.2.52-3+b1
  Version table:
     2.2.53-10 100
        100 http://ftp.fr.debian.org/debian sid/main amd64 Packages
     2.2.53-4 200
        200 http://ftp.fr.debian.org/debian buster/main amd64 Packages
 *** 2.2.52-3+b1 500
        500 http://ftp.fr.debian.org/debian stretch/main amd64 Packages
        500 file:/tmp/debian_dvds/amd64/debian-9.2.1-amd64-DVD-1 stretch/main amd64 Packages
        100 /var/lib/dpkg/status
Version 2.2.52 of package acl has been installed from stretch, but there is indeed another version available in sid, 2.2.53 (not installed)

To get all packages with origin "Debian" and installed from archive "sid", you need to use the "~S" flag, and put ~O and ~A between parenthesis and separated with a space :
Code:
$ aptitude search '~i~O^Debian$~Aunstable' | wc -l
3043

$ aptitude search '~S~i~O^Debian$~Aunstable' | wc -l
2972

$ aptitude search '~S~i(~O^Debian$ ~Aunstable)' | wc -l
74

$ aptitude search '~S~i(~O^Debian$ ~Aunstable)' | head -n 3
i  apt-mirror - APT sources mirroring tool
i A cups-pk-helper - PolicyKit helper to configure cups with fine-grained privileges
i  dhcp-probe - network DHCP or BootP server discover

$ apt-cache policy apt-mirror
apt-mirror:
  Installed: 0.5.4-1
  Candidate: 0.5.4-1
  Version table:
 *** 0.5.4-1 500
        500 http://ftp.fr.debian.org/debian stretch/main amd64 Packages
        500 http://ftp.fr.debian.org/debian stretch/main i386 Packages
        200 http://ftp.fr.debian.org/debian buster/main amd64 Packages
        200 http://ftp.fr.debian.org/debian buster/main i386 Packages
        100 http://ftp.fr.debian.org/debian sid/main amd64 Packages
        100 http://ftp.fr.debian.org/debian sid/main i386 Packages
        500 file:/tmp/debian_dvds/amd64/debian-9.2.1-amd64-DVD-5 stretch/main amd64 Packages
        500 file:/tmp/debian_dvds/i386/debian-9.2.1-i386-DVD-5 stretch/main i386 Packages
        100 /var/lib/dpkg/status
The package "apt-mirror" has indeed been "installed from" the sid (unstable) archive. I put "installed from" between quotes, because it's not exactly true. I am quite sure that my package "apt-mirror" has been installed from stable, but the versions available in stable and unstable are the same.

So,
Code:
$ aptitude search '~S~i(~O^Debian$ ~Aunstable)'
will in fact return all installed packages with origin "Debian" and where the installed version is the same as the version available in the "unstable" archive (whether those packages have indeed been installed from the "unstable" archive or not is not known).

The long syntax would be :
Code:
$ aptitude search '?narrow(?installed,?and(?origin(^Debian$),?archive(^unstable$)))' | wc -l
74

$ aptitude search '~S~i(~O^Debian$ ~Aunstable)' | wc -l
74
SECOND EXAMPLE
Code:
$ aptitude search '~i~O^Debian$!~A^stable$'
will not return all packages with origin "Debian" and installed from all archives except "stable", like I thought (like you thought too ?). It will instead return all installed packages with origin "Debian" and not available in the "stable" archive :
Code:
$ aptitude search '~i~O^Debian$!~A^stable$' | wc -l
18

$ aptitude search '~i~O^Debian$!~A^stable$' | head -n 3
i  gnome-activity-journal - graphical user interface for Zeitgeist
i A libegl1-glvnd-nvidia - Vendor neutral GL dispatch library -- libEGL
i A libegl1-glvnd-nvidia:i386 - Vendor neutral GL dispatch library -- libEGL

$ apt-cache policy gnome-activity-journal 
gnome-activity-journal:
  Installed: 0.8.0-2.1
  Candidate: 1.0.0-3
  Version table:
     1.0.0-3 100
        100 http://ftp.fr.debian.org/debian sid/main amd64 Packages
        100 http://ftp.fr.debian.org/debian sid/main i386 Packages
 *** 0.8.0-2.1 100
        100 /var/lib/dpkg/status
Indeed, the package "gnome-activity-journal" for example has been installed (we don't know from where), and isn't available in the "stable" archive

To get all packages with origin "Debian" and installed from all archives except "stable", you need once again to use the "~S" flag :
Code:
$ aptitude search '~S~i(~O^Debian$ !~A^stable$)' | wc -l
48

$ aptitude search '~S~i(~O^Debian$ !~A^stable$)' | tail -n 3
i  unrar - Unarchiver for .rar files (non-free version)
i A update-glx - utility for switching the GLX implementation
i A youtube-dl - downloader of videos from web page.

$ apt-cache policy youtube-dl 
youtube-dl:
  Installed: 2021.02.10-1
  Candidate: 2021.04.07-dmo1
  Version table:
     2021.04.07-dmo1 100
        100 http://www.deb-multimedia.org stretch/main amd64 Packages
 *** 2021.02.10-1 100
        100 http://ftp.fr.debian.org/debian sid/main amd64 Packages
        100 /var/lib/dpkg/status
     2019.01.17-1.1 200
        200 http://ftp.fr.debian.org/debian buster/main amd64 Packages
     2019.01.17-1.1~bpo9+1 100
        100 http://ftp.fr.debian.org/debian stretch-backports/main amd64 Packages
     2017.05.18.1-1 500
        500 http://ftp.fr.debian.org/debian stretch/main amd64 Packages
        500 file:/tmp/debian_dvds/amd64/debian-9.2.1-amd64-DVD-2 stretch/main amd64 Packages
The package "youtube-dl" for example, has indeed been installed from the unstable archive.

In fact,
Code:
$ aptitude search '~S~i(~O^Debian$ !~A^stable$)'
does return all installed packages with origin "Debian" and where the installed version is different from the one available in the "stable" archive (which is the same as saying all packages with origin "Debian" and not installed from the "stable" archive).

The long syntax would be :
Code:
$ aptitude search "?narrow(?installed,?and(?origin(^Debian$),?not(?archive(^stable$))))" | wc -l
48

$ aptitude search '~S~i(~O^Debian$ !~A^stable$)' | wc -l
48
 
1 members found this post helpful.
Old 05-06-2021, 08:04 AM   #9
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 2,321

Rep: Reputation: Disabled
Yes, that makes sense. Thank you for clarification.

I think this still may be related to the fact that repositories are referenced by their codenames in /var/lib/apt/lists/. Have you tried to search by codenames (stretch, buster, sid) instead?

Last edited by shruggy; 05-06-2021 at 08:22 AM.
 
Old 05-06-2021, 12:46 PM   #10
stoorky
Member
 
Registered: Sep 2015
Posts: 43

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by shruggy View Post
I think this still may be related to the fact that repositories are referenced by their codenames in /var/lib/apt/lists/.
Yes, I think so too

Quote:
Have you tried to search by codenames (stretch, buster, sid) instead?
It seems this is not possible : https://unix.stackexchange.com/quest...-based-systems
 
  


Reply

Tags
aptitude, archive, debian, search, ubuntu


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
aptitude search with archive pattern - unexpected results stoorky Debian 1 04-12-2021 09:38 AM
Search and replace Pattern preceeding another pattern nbkisnz Programming 3 05-13-2012 01:50 PM
[SOLVED] /bin/bash if statement pattern search, end of pattern special character? headhunter_unit23 Programming 3 04-29-2010 08:05 AM
Question on Aptitude search pattern Akhran Debian 1 02-11-2006 04:18 AM
Question on aptitude search pattern Akhran Linux - Newbie 4 02-10-2006 12:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:23 AM.

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