[SOLVED by xyne] Search for packages I have but are NOT installed?

Hi all,
I run a couple of computers on Arch (both 64-bit), was just wondering if I could copy the /var/cache/pacman/pkg from one computer to the other, and then run some command to install from the cache all packages that are not currently installed. Basically it would be something like "go through all the packages in /var/cache/pacman/pkg, if any are installed ignore them, if a newer version is installed ignore them, but if no version of this package is installed then install it.
Last edited by ngoonee (2009-06-26 05:17:35)

Try this:
#!/usr/bin/perl
use strict;
use warnings;
exit(1) if not @ARGV;
my $cachedir = $ARGV[0];
$cachedir = substr($cachedir,0,-1) if substr($cachedir,-1) eq '/';
opendir(my $dh, $ARGV[0]) or die $!;
my @cache_pkgs = map { s/-[^-]+-[^-]+(?:-i686|-x86_64|-any)?\.pkg\.tar\.gz$//; $_ }
grep {/\.pkg\.tar\.gz$/}
readdir($dh);
closedir($dh);
my @installed_pkgs = split(/\s*\n\s*/, `pacman -Qq`);
my %cache_pkgs;
$cache_pkgs{$_} = 1 foreach @cache_pkgs;
my %installed_pkgs;
$installed_pkgs{$_} = 1 foreach @installed_pkgs;
foreach (keys(%cache_pkgs))
delete($cache_pkgs{$_}) if exists($installed_pkgs{$_});
# uncomment these lines if you just want a list of uninstalled packages
# without filtering dependencies
# @cache_pkgs = keys(%cache_pkgs);
# print "$_\n" foreach @cache_pkgs;
# exit();
my $pkg_files;
foreach my $pkg (keys(%cache_pkgs))
opendir(my $dh, $cachedir) or die $!;
my @pkg_files = grep {/^\Q$pkg\E/} readdir($dh);
closedir($dh);
foreach my $pkg_file (@pkg_files)
if ( $pkg_file =~ m/^(.+)-([^-]+-[^-]+)(?:-i686|-x86_64|-any)?\.pkg\.tar\.gz$/ )
$pkg_file = $cachedir . '/' . $pkg_file;
if (not exists($pkg_files->{$1}))
$pkg_files->{$1}->{'ver'} = $2;
$pkg_files->{$1}->{'file'} = $pkg_file;
else
my $ver = $pkg_files->{$1}->{'ver'};
if (&compare_versions($2,$ver))
$pkg_files->{$1}->{'ver'} = $2;
$pkg_files->{$1}->{'file'} = $pkg_file;
foreach my $pkg (keys(%{$pkg_files}))
my $pkg_file = $pkg_files->{$pkg}->{'file'};
my $pkginfo = `tar -O -zxf $pkg_file .PKGINFO`;
foreach my $line (split(/\s*\n\s*/, $pkginfo))
if ($line =~ /^depend\s+=\s+([^>=\s]+)/)
delete($cache_pkgs{$1}) if exists($installed_pkgs{$1});
@cache_pkgs = keys(%cache_pkgs);
print "$_\n" foreach @cache_pkgs;
sub compare_versions
my ($a,$b) = @_;
return -1 if not defined($a) and defined($b);
return 1 if defined($a) and not defined($b);
return 0 if not defined($a) and not defined($b);
my ($rel_a,$rel_b) = (0,0);
if ($a =~ m/(.*)-(.+)$/) {($a,$rel_a)=($1,$2);}
if ($b =~ m/(.*)-(.+)$/) {($b,$rel_b)=($1,$2);}
my @a = split(/\./,$a);
my @b = split(/\./,$b);
my $len_a = scalar @a;
my $len_b = scalar @b;
my $n = ($len_a < $len_b) ? $len_a : $len_b;
for (my $i=0; $i<$n; $i++)
my ($int_a,$alph_a,$dash_a) = ($a[$i] =~ m/^(\d*)(.*?)(_.*)?$/);
my ($int_b,$alph_b,$dash_b) = ($b[$i] =~ m/^(\d*)(.*?)(_.*)?$/);
$int_a = 0 if $int_a eq '';
$int_b = 0 if $int_b eq '';
if ($int_a != $int_b)
return $int_a <=> $int_b;
if (length($alph_a) and not length($alph_b))
return -1;
if (not length($alph_a) and length($alph_b))
return 1;
if ($alph_a ne $alph_b)
return $alph_a cmp $alph_b;
return 1 if defined($dash_a) and not defined($dash_b);
return -1 if not defined($dash_a) and defined($dash_b);
if (defined($dash_a) and defined($dash_b))
my $dash_cmp = $dash_a cmp $dash_b;
return $dash_cmp if $dash_cmp != 0;
return $len_a <=> $len_b if not $len_a == $len_b;
return $rel_a <=> $rel_b;
Save it as "list_pkgs", make it executable and then run it with
./list_pkgs /var/cache/pacman/pkg
It should spit back a list which contains all packages in the cache which are currently uninstalled, minus any packages which are dependencies of others. To install those packages, combine it with pacman:
pacman -S $(./list_pkgs /var/cache/pacman/pkg)
This doesn't completely solve the issue of explicit versus implicit installation, but I expect that this would be more manageable than installing everything explicitly. I've commented on lines which can be uncommented to get a simple list which ignores dependency relationships.
Btw, the script isn't really as long as it might look. The compare_versions function, which I copied over from another module, nearly doubles the size of the script.
*edited for typos*
Last edited by Xyne (2009-06-26 04:30:12)

Similar Messages

  • I have paid my subscription for Adobe Acrobat Pro but can not install it- I always get an error message -also I did not receive any instalation code...

    I have paid my subscription for Adobe Acrobat Pro but can not install it… I always get an error message …also I did not receive any instalation code...

    With the subscription you sign in with your Adobe ID that you used to order the subscription. By installation code, I assume you mean serial number. You do not get one with the subscription, but use your Adobe ID.

  • The latest update for iCloud has downloaded, but, will not install, I have tried manually as suggested.

    The latest update for iCloud has downloaded, but, will not install, even when tried manually. The QuickTime update which was on the same page was ok though!

    I have the same problem....I hope they get arouind to fixing this issue?????????????????

  • VS Exp 2013: Unable to create the Web site ... The components for communicating with FTP servers are not installed.

    I have MS Visual Studio Express 2013 It has worked fine for many months and then suddenly (I have made no configuration changes or added new programs) when I try to publish I am getting the message:
    Unable to create the Web site 'ftp://ftp.xx.xx/xxx.org.uk/www/htdocs'. The components for communicating with FTP servers are not installed.
    (I have replaced actual name with x's).
    I had a similar problem some months ago and found that saving all files, closing VS 2013 and re-starting the program fixed the problem. This time it has not.
    I am at a loss to know how to take this forwards. I do not use IIS.
    Any help would be appreciated.
    Michael.

    Hi Michael,
    For web site development, so you use the VS2013 express for web, am I right? We have to make sure that it is not the VS version issue.
    As you said that it worked well before, did you install other add-ins or tools in your VS IDE like
    Xamarin or others?
    Maybe you could disable or remove all add-ins in your VS IDE, test it again.
    please also install the VS2013 update 4 in your side.
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • The components for communicating with FTP servers are not installed.

    I'm running VS 2013 and when I try to publish to ftp site I get the following message. "Unable to create the Web site 'ftp://xx/'. The components for communicating with the FTP servers are not installed."   It has been running fine. I
    can publish to file system, web sites etc, just not through the ftp settings. I can access the ftp sites from my system, using other programs. It is not trying to connect to the ftp site at all.

    Hi paaccess,
    Glad to receive your reply.
    According to your description, since we can publish an application to ftp site in Visual Studio Prof 2013 in our side. Therefore, to further make sure if the issue is related to the VS IDE issue. We suggest
    you try to publish to ftp site on another machine you installed same version of VS Prof 2013 and then check it again.
    If you can publish on another machine, I suggest may need to re-download the
    VS Prof 2013 from Microsoft website and then install it again on your local machine.
    If you still could not publish on another machine, I think that the issue is not related to the VS2013 IDE issue. If possible, I still suggest you post the issue directly to the IIS.NET Forum:
    http://forums.iis.net/,
    it will better help you solve the issue.
    Thanks for your understanding.
    Have a nice day!
    Best Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • How to search for packages that Names including "'" [solved]

    Hi everyone
    first ,forgive my english lvevel
    and I want to know
    How to search for packages that Names including "'"
    for instance
    $ pacman -Ss America's Army
    it returned
    >
    Please help me ,many thanks!
    Last edited by icywalk (2010-04-05 13:09:26)

    fyi America's Army in the AUR as armyops if you're looking for it.

  • Search for packages with pacman

    Normally I searched for packages with packman -Ss ...
    But is there a posiblity that it shows only that packages wich i havent installed?

    pacman -Ss <packagename>
    shows packages in the repositories you have specified in /etc/pacman.conf, whether they are installed or not
    pacman -Q
    will list the packages installed on your system

  • Hi. I am using the iPhone 4S and when I'm searching for places using Google it does not automatically detect my location. How do I change this? FYI...under settings i have it set at "Use new precise locations from my device."

    Hi. I am using the iPhone 4S and when I'm searching for places using Google it does not automatically detect my location. How do I change this? FYI...under settings i have it set at "Use new precise locations from my device."

    If you are missing using google maps - try the Nokia map app called "here"

  • I have a Canon MP990 and i keep getting an eror code.  I have searched for a driver update but cannot seem to find one- Any ideas please?

    I have a Canon MP990 and I keep getting a communication error code 306A.  I have tried the usual turning everything off and starting again all to no avail.  I have searched for a driver update but cannot seem to find one- Any ideas please?

    Hi Peter!
    I'm sorry to read that you are having issues with your Sync account.
    Your best bet is to follow the steps described in this blogposts and open a bug:
    https://philikon.wordpress.com/2011/06/13/how-to-file-a-good-sync-bug/
    After that, if you don't want to user Sync in your computer, you can stop it with this simple steps:
    * At the top of the Firefox window, click on the Firefox button (Tools menu in Windows XP) and then click Options.
    * Once the options window opens, click on the Sync tab.
    * At the bottom of the Sync tab click on '''Deactivate this Device''' link

  • Search for doc's on WIN7 Drive not working

    Hello, I am wondering if any of you know a work around for this. I cant seem to understand why the search for the names of documents does not look in the windows bootcam drive correctly. For example I open the HDD for windows 7 and say I search for a text document called serials.txt and I search for "serials" and serials.txt" and Finder does not find.... The document is there and inside the folder located on the WIN7 Partition I am searching. I do have Paragon NTFS installed... Confused.

    Sounds like Spotlight doesn't use Paragon which actually doesn't surprise me at all.
    Allan

  • My outlook will not open yet all other microsoft packages will.  When I click on the icon, the 'o' logo will come up for a split second but will not open the package - need to receive emails asap!

    My outlook will not open yet all other microsoft packages will.  When I click on the icon, the 'o' logo will come up for a split second but will not open the package - need to receive emails asap!

    You're very welcome!
    I meant holding the "option" (or "alt") key on your keyboard as you click the Outlook icon on the Dock, and continuing to hold it until you see the Microsoft Database Utility come up. Alternatively, you can open the utility by navigating to Applications/Microsoft Office 2011/Office and then double-clicking the Microsoft Database Utility app.
    When you rebuild your database using that program, a backup copy of your original database (containing your account info, contacts, mail, calendars, etc) will be created. As a security precaution, you should also ensure you have a backup of your database (which you can find by going to Documents/Microsoft User Data/Office 2011 Identities/ and copying the contents of that folder onto an external drive).

  • Where does one search for ALL the APPS that are available?

    Where does one search for All the apps that are available ?

    If you don't see any messages, not have anti-malware running or the Firewall on, try installing the Mac OS X 10.6.8 Update Combo
    It's ok to do this even though you are already running v10.6.8 (according to your profile).
    Restart your Mac after the combo in installed, try the App Store.
    Also... if you have an app called Little Snitch installed, that can prevent a connection to the App Store.

  • Hi. I am using the iPhone 4S and when I'm searching for places using Google it does not automatically detect my location. How do I change this?  FYI...under settings i

    Hi. I am using the iPhone 4S and when I'm searching for places using Google it does not automatically detect my location. How do I change this?  FYI...under settings i

    If you are missing using google maps - try the Nokia map app called "here"

  • My Ipod touch Is stuck in restoe mode. I have reinstalled Itunes 10.4 .1 10. windows says drivers are not installed. I have followed all trouble shooting advice, fixes and updates for windows 7

    I have reinstalled Itunes 10.4 .1 10. windows says drivers are not installed. I have followed all trouble shooting advice, fixes and updates for windows 7

    I have reinstalled Itunes 10.4 .1 10. windows says drivers are not installed. I have followed all trouble shooting advice, fixes and updates for windows 7

  • Windows 8.1 PC, using reader, when searching a folder containing approx 100 doc's. If i search for a word, no results are returned. only the doc names can be found but nothing from within the doc. This is a new problem and was not the case before.

    Windows 8.1 PC, using reader, when searching a folder containing approx 100 doc's. If i search for a word, no results are returned. only the doc names can be found but nothing from within the doc.
    This is a new problem and was not the case before.

    Works perfectly fine for me with the latest Reader version (11.0.09).
    You write that it worked "before"; before what?  An update?  Update from what version to what version?

Maybe you are looking for

  • Error while installing OBIEE 11.1.1.7 on Linux

    Hi, I am trying to do OBIEE 11.1.1.7 Enterprise install on a Linux server. When I run the installer, after specifying install location, when I configure the components(Select BI Enterprise Edition, BI Publisher) I get error as ORACLE_HOME variable is

  • WRT54G router and call of duty online gaming

    I just bought the WRT54G wireless router and had no problem installing it. I was able to get internet connection on the wired desktop and the wireless laptop. However, when I start playing 'Call of Duty 4' online, within a couple of minutes I start t

  • Sto with delivery procdure in sd

    hey sap guru,** can  some body explain me the setting for sto with delivery for intercompany in sd ?                                                       thanks

  • Java3D, Webstart & file access

    I have a Java3D application that opens files (for example using ImageIO.read in TextLoader) perfectly well fom the local file system When I use the Webstart version of Java3D (http://download.java.net/media/java3d/webstart/release/java3d-latest.jnlp)

  • Listener.8li plugin not working with PS CS2 ?

    Dear forum, I tried to compile (Win 2000 / VC7.1 aka Visual Studio.NET 2003) and run the Listener plugin supplied with the PhotoShop CS2 SDK. I opened with VC7.1 the solution file (Listener.sln) and built it. As described in the "Automation tutorial.