You are not logged in.

#1 2003-12-11 18:02:23

EmaRsk
Member
From: Italy
Registered: 2003-12-07
Posts: 26

removing unused packages?

is there a way to remove unused packages? i see pacman can remove a package and all the ones depending on it (-Rc), but i did'n find a way to remove all the ones needed only by it. is there a way to list all the dependencies (maybe in an ordered tree-like format)? if not i think these would be useful features to include in pacman.

Offline

#2 2003-12-11 23:57:09

EmaRsk
Member
From: Italy
Registered: 2003-12-07
Posts: 26

Re: removing unused packages?

sarah31 wrote:
EmaRsk wrote:

is there a way to remove unused packages?

How is pacman supposed to know if a package is unused? beyond pacman -Rd/c i know of no feature like this and is sounds like it would require a fair bit of dynamic interaction by pacman.

for example, let's suppose i want to remove pac1. pacman could check, for each package pac1 depends on, if pac1 is the ONLY package that depends on 'em (something like a simulated "pacman -Rc" that doesn't actually remove anything), and if there is no other package that would go broke, proceed with removing.

i see pacman can remove a package and all the ones depending on it (-Rc), but i did'n find a way to remove all the ones needed only by it.

not sure what you are asking here but if you mean removing something like xfree86 without taking dependencies with it pacman -Rd will do that.

i mean removing those packages that were needed only by pac1 as dependencies.  maybe an ask for confirmation would be needed to avoid accidentally removing packages useful by themselves.

is there a way to list all the dependencies (maybe in an ordered tree-like format)?

pacman -Qi  packagename  i believe lists the depends. if it doesn't there are lots of places to find the depends.

yes but if i want to know if i still need a package i would have to check the dependencies of all installed packages. doing it by hand is a pain... is there a more automated way?

thanks for reply. i hope my english is good enough to not generate misunderstandings (it'not my mother language).

Offline

#3 2003-12-12 01:16:53

Xentac
Forum Fellow
From: Victoria, BC
Registered: 2003-01-17
Posts: 1,797
Website

Re: removing unused packages?

There is no automatic way to do that, though it's an ok idea.


I have discovered that all of mans unhappiness derives from only one source, not being able to sit quietly in a room
- Blaise Pascal

Offline

#4 2003-12-12 03:56:23

RdsArts
Member
Registered: 2003-10-17
Posts: 32

Re: removing unused packages?

If your know what you need and what's cruft, you could use this script I wrote for my own nefarious purposes a while back:

#!/bin/bash

echo "Running a check for packages without depends."
echo "Started on:"
date
echo ""

for pac_name in `pacman -Qi | sed 's/ .*//'`;
do
        Y=`pacman -Qi "$pac_name" | grep Required | grep None`
        if [ ! -z "$Y" ]; then
                echo Package:    $pac_name
                pacman -Qi $pac_name | grep Descript
                echo
        fi
done

It'll lists everything without a dependancy. Which means even programs your still using.

.... And it's probably horrendously coded. But it works for me.

Offline

#5 2003-12-12 09:36:49

EmaRsk
Member
From: Italy
Registered: 2003-12-07
Posts: 26

Re: removing unused packages?

Thanx RdsArts, it seems to work fine. one day i'd better learn to use sed ;-), i feel it's a powerful tool for scripts.

a reply to sarah: afaik pacman -Qi won't tell me ALL the packages needed for a package to run, but only direct dependencies. for example, xmms depends on gtk, which is listed, but gtk itself depends on other many packages that are not listed by "pacman -Qi xmms"...
thanks for replying
bye

Offline

#6 2003-12-12 15:42:41

EmaRsk
Member
From: Italy
Registered: 2003-12-07
Posts: 26

Re: removing unused packages?

that's the point: i never said i'm "asking for direct" nor that i "want to get into only second generation". my question was another one: if  there's a way, when i remove a pkg, to remove those dependencies (recursively, not only direct or second generation) no more needed.

Offline

#7 2003-12-12 16:25:43

Xentac
Forum Fellow
From: Victoria, BC
Registered: 2003-01-17
Posts: 1,797
Website

Re: removing unused packages?

Sarah, he's talking about doing it backwards.  pacman -R will remove a package and everything that depends on it.  But what about removing a package and everything that it depends on that nothing else depends on.

Bad example, but let's say you want mozilla, but don't have xfree86 installed.  xfree86 is obviously a depend of mozilla, so installing mozilla means you install xfree86.  What if you remove mozilla?  Removing mozilla leaves xfree86 because xfree86 doesn't depend on mozilla.  At the same time (in this contrived example) nothing else on the system depend on xfree86, so why have it around if you weren't using it for anything other than mozilla?


I have discovered that all of mans unhappiness derives from only one source, not being able to sit quietly in a room
- Blaise Pascal

Offline

#8 2003-12-13 13:36:13

secsaba
Member
From: Espoo, Finland
Registered: 2003-11-06
Posts: 19

Re: removing unused packages?

It's like deborphan in debian, I think. It's listing orphaned package what the user can remove if he doasn't use it anymore.

Offline

#9 2003-12-13 18:10:59

Mork II
Member
From: Visby, Sweden
Registered: 2003-05-14
Posts: 87

Re: removing unused packages?

You can list orpahaned packages with pacman -Qi --orphan. That will list all packages that are not needed by any other package, you can then remove the stuff you know you don't use with a simple pacman -R package.

This is not  exactly what you are looking for but to make these removals auotmatic pacman would have to know the difference between a library you don't use and an app you do use.... That could be done by adding a  flag ("toplevel ( 'x') "  where x is yes or no)  in the packagebuilds to distinguish a library from an end user application. An automatic removal should remove all "libraries (with "toplevel('n')" ) while all apps (like mozilla with "toplevel('y')") would be left alone. Of course this doesn't deal with the handling additional libraries that may be used by programs but aren't included as dependencies.

//Edited because I klicked submit before I was done//

Offline

#10 2003-12-14 14:57:31

EmaRsk
Member
From: Italy
Registered: 2003-12-07
Posts: 26

Re: removing unused packages?

cool. thanx. but i did'n find "--orphan" in pacman manpage... how can i find informations such this one? maybe i'm missing something? (btw, i saw also a "pacman -T" in makeworld script...). thanks for the help, y'all, i've got a lot to learn.

Offline

#11 2005-05-06 09:23:50

bsdson.tw
Member
From: Taiwan
Registered: 2005-05-06
Posts: 161

Re: removing unused packages?

That I've modified the code so that it can skip some packages that you specified in the file "./pacNoReq.skip"

#!/bin/bash

echo "Running a check for packages required by none."
echo "Started on:"
date
echo ""

for pkgName in `pacman -Qi | sed 's/ .*//'`;
do
        if [ -f "./pacNonReq.skip" ] && [ -n "`grep $pkgName ./pacNonReq.skip`" ]; then
                :
        elif [ -n "`pacman -Qi $pkgName | grep Required | grep None`" ]; then
                echo "Package        : $pkgName"
                pacman -Qi $pkgName | grep Descript
                echo
        fi
done

If.. I break the code, please forgive me that it's my 1st time... tongue
and..

@RdsArts
May I quote your code to our local wiki in Taiwan?
Thank you very much in advance!

Offline

#12 2005-05-06 12:15:47

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: removing unused packages?

pacman -Qe 

       -e, --orphans
              List all packages that were explicitly installed (ie, not pulled
              in  as  a  dependency by other packages) and are not required by
              any other packages.

Offline

#13 2006-02-15 00:57:31

avb
Member
From: Minsk, BY
Registered: 2006-02-08
Posts: 10

Re: removing unused packages?

I wrote a perl script fully like a debfoster.
You can grab it here: http://avb.bas-net.by/pkgpurge

Feel free to write bugreports smile


Regards, Alex

Offline

Board footer

Powered by FluxBB