Pacman-related Scripts

2021-08-15 01:45 UTC
  • Xyne


This directory contains pacman-related scripts. There may be more in the system scripts directory. I haven’t really figured out how I want to categorize everything yet.

As usually, if there is no description below, check the comments in the file.

See Also

Other package- and pacman-related scripts can be found here.

AUR Scripts

Some of these will require python3-aur

Check which packages are in the AUR

Pass this a list of package names to determine which are available in the AUR.

#!/usr/bin/env python3
from AUR import AUR
from sys import argv

pkgs = set(argv[1:])
aur = AUR(log_func=lambda x,y: None)

aurpkgs = set(p['Name'] for p in
nonaurpkgs = pkgs - aurpkgs

print("Found in AUR")
for p in aurpkgs:
  print(" ",p)

print("Not found in AUR")
for p in nonaurpkgs:
  print(" ",p)

Example output (with script saved as

$ ./ arch32-light synclinks foo bar
Found in AUR
Not found in AUR

Scripts Posted On The Forum

Most will have been written in response to a forum post and forgotten about.

Pacman Log Cleaner

The script accepts two optional arguments. The first is the number of months to keep all messages (default: 6). The second argument is the path to the log file (default: /etc/pacman.log). The number of months are counted from the last timestamp in the log.

The script tracks messages associated with installations, upgrades and removals for each package. All messages younger than the specified number of months are kept. Older messages are kept for the last installation or upgrade of each package. The following messages are never removed:

[*-*-* *:*] installed * (*)
[*-*-* *:*] upgraded * (* -> *)
[*-*-* *:*] removed * (*)
[*-*-* *:*] synchronizing package lists
[*-*-* *:*] starting full system upgrade.

The script does not overwrite the log. It only prints the filtered log to STDOUT. The user should redirect the log to a separate file then compare it with the original log before overwriting it with the filtered log. Do not redirect the output directly to the log! You will overwrite it.

use strict;
use warnings;

my $months = shift // 6;
my $fpath = shift // '/var/log/pacman.log';

my $regex = qr/^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2})\] (installed \S+|upgraded \S+|removed \S+|synchronizing package lists|starting full system upgrade)/;

open (my $fh, '<', $fpath) or die $!;

my %entry_to_msg = ();
my %pkgname_to_entry = ();
my $last_timestamp = '';

my $msg = '';

foreach my $line (<$fh>)
  if ($line =~ m/$regex/)
    $last_timestamp = $1;
    my $entry = $2;
    if ($entry =~ m/^(?:installed|upgraded|removed) (\S+)/)
      my $pkgname = $1;
      if (exists($pkgname_to_entry{$pkgname}))
        my $k = $pkgname_to_entry{$pkgname};
        delete $pkgname_to_entry{$pkgname};
        delete $entry_to_msg{$k}
      if ($msg)
        $entry_to_msg{$line} = $msg;
        $pkgname_to_entry{$pkgname} = $line
    $msg = ''
    $msg .= $line


$last_timestamp = &parse_timestamp($last_timestamp);
my $filter = 1;

foreach my $line (<$fh>)
  if ($filter)
    if ($line =~ m/$regex/)
      my ($timestamp,$entry) = ($1,$2);
      my $keep_msg = &keep_message( $months,$last_timestamp,&parse_timestamp($timestamp) );
      $filter = not $keep_msg;
        $entry =~ m/^(?:installed|upgraded) (\S+)/
        print $entry_to_msg{$line}
        $entry =~ m/^removed (\S+)/
        print $entry_to_msg{$line}
      print $line
    print $line;

close $fh;

sub parse_timestamp
  return [$_[0] =~ m/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})/]

sub keep_message
  my ($months, $a, $b) = @_;
  my $dt = ($a->[0] - $b->[0]) * 12 + ($a->[1] - $b->[1]);
  return (($dt < $months) or ($dt == $months and ($a->[2] <= $b->[2])))

List Explicitly Installed Repo And Foreign Packages

This will create two files. repo_pkgs.txt will contain a list of all explicitly installed packages that are available in the repos. foreign_pkgs.txt will contain a list of all explicitly installed packages that are not available in the repos.


pacman -Qqme | sort > foreign_pkgs.txt
comm -23 <(pacman -Qqe|sort) foreign_pkgs.txt > repo_pkgs.txt


Paconky is a Python 3 script that uses pyalpm and python3-aur to display a list up upgradable packages conky. The script is only a basic template and should be customized as desired by the user. This is also why it will not be packaged… much more can be done with it by direct editing than could ever be achieved by an arbitrary configuration system.

The scripts includes comments to assist editing.


This script was written to replace the original verion of Paconky written in Bash. That version was slow, unoptimized and noobish. This one is fast(er), less unoptimized, and less noobish.


Update - the code base of Parisync has developed into Powerpill. Use that instead.

Parisync is a pm2ml-based script that determines the download queue for a synchronization operation and then uses rsync and aria2c to retrieve the files in parallel. rsync is used for all of the official packages and aria2c is used for everything else.

Parisync works with Pacserve and will preferentially download packages from available Pacserve servers.

It is not a full wrapper but it can easily be used in scripts that wrap pacman synchronization commands. Some examples are given below.

More features may be added eventually but they will require some refactoring of the pm2ml code.

Forum Thread


  • pm2ml
  • rsync
  • aria2c


parisync <rsync mirror url> [Pacserve URL] [<pm2ml args>]

Check the Arch Linux mirror status page for an rsync-enabled mirror near you. You can also use reflector:

reflector -p rsync -c <your country> ...

Wrapper Script

The easiest way to use parisync is to create a wrapper script with the mirror URL:

parisync '<rsync mirror URL>' "$@"

A local Pacserve URL can also be included in the wrapper script to enable Pacserve support:

parisync '<rsync mirror URL>' http://localhost:15678 "$@"

This script can then be used in other scripts to downloading packages and databases. Here is an example that will synchronize the system (= pacman -Syu …):

# Download databases (= pacman -Sy)
parisync_wrapper -ys -o /var/lib/pacman/sync

# Download packages to the cache. (= pacman -Suw ...)
parisync_wrapper -u -o /var/cache/pacman/pkg "$@"

# Install new packages.
pacman -Su "$@"

This script could be saved under the name “psyu” and used instead of pacman -Syu ....

Another useful example:

# Download packages to the cache. (= pacman -Suw ...)
parisync_wrapper -o /var/cache/pacman/pkg "$@"

# Install new packages.
pacman -S "$@"

This script basically acts as an alias for “pacman -S”. You can specify packages and even pass it the “-u” flag to download upgradable packages.


Parisync accepts the rsync mirror URL and pm2ml arguments. Many of these are designed to match Pacman’s arguments, but they are not completely compatible and not all of Pacman’s arguments are recognized. Remember this when using the scripts above. Parisync and pm2ml are downloaders, not wrappers themselves.




repkg is simple script to avoid rebuilding a package for metadata changes. It will extract built package files to $pkgdir and then repackage them with the updated metadata.

Post feedback here or via email.


repkg <build pkgfile> [makepkg options]
echo | sed 's/\./@/'
XHTML 1.0 Strict CSS level 3 Atom 1.0