Skip to content

Instantly share code, notes, and snippets.

@CIAvash
Last active October 17, 2016 13:18
Show Gist options
  • Save CIAvash/1171ce45a287a747340b to your computer and use it in GitHub Desktop.
Save CIAvash/1171ce45a287a747340b to your computer and use it in GitHub Desktop.
Copy Pacman's cached packages
#!/usr/bin/env perl6
subset File of Str where *.IO.f;
subset Directory of Str where *.IO.d;
#| Copies requested packages from Pacman's cache directory
sub MAIN (File $pkg_list, Directory $destination) {
my @pkg_list = $pkg_list.IO.lines>>.comb(/^^\S+||\S+$$/);
die 'Package list is empty' unless @pkg_list;
for @pkg_list -> [$pkg, $version] {
qqx<find /var/cache/pacman/pkg/ -type f -name "$pkg-$version*.pkg.tar.xz" -exec cp \{\} $destination \\;>;
}
say 'Done!';
}
=begin description
$pkg_list file must have a package name and a version on each line -> [pkg] ... [version]
for example this can be generated with `pacman -Qu` when upgrading packages on another computer
Example: cp-pkgs.pl6 pkgs.txt destination-dir
=end description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment