#arch-linux #aur #pkgbuild

aur-fetch

A libary for downloading and diffing AUR packages

21 unstable releases

0.11.2 Nov 21, 2022
0.11.0 Jul 9, 2022
0.10.0 Sep 21, 2021
0.9.1 Jan 20, 2021
0.1.0 Mar 22, 2019

#545 in Unix APIs

Download history 3375/week @ 2023-11-20 15479/week @ 2023-11-27 6580/week @ 2023-12-04 5229/week @ 2023-12-11 4560/week @ 2023-12-18 4471/week @ 2023-12-25 4311/week @ 2024-01-01 4061/week @ 2024-01-08 4140/week @ 2024-01-15 4136/week @ 2024-01-22 3998/week @ 2024-01-29 3995/week @ 2024-02-05 3815/week @ 2024-02-12 3869/week @ 2024-02-19 3735/week @ 2024-02-26 4044/week @ 2024-03-04

16,018 downloads per month
Used in paru

GPL-3.0 license

30KB
666 lines

aur-fetch

aur-fetch is a crate that manages downloading and diffing packages downloading from the AUR. This process is split up into many different steps to give maximum control of how diffs are handled and to ensure packages are never merged until the user has confirmed they have read them.

Note: This crate only deals with fetching packages. It assumes the list of packages you pass to it are pkgbases and therefore can not work with split packages. To deal with split packages the AUR RPC must be used to get the pkgbase from a pkgname.

Examples

Printing - Diffs

use aur_fetch::Fetch;


let pkgs = vec!["discord", "spotify", "pacman-git"];

// Create our handle
let fetch = Fetch::new()?;

// Clone/Fetch the packages.
let fetched = fetch.download(&pkgs)?;

// Merge changes
fetch.merge(&fetched)?;

// Only diff packages that have not been reviewed
let to_diff = fetch.unseen(&pkgs)?;

// Print each diff
for (diff, pkg) in fetch.diff(&to_diff, true)?.iter().zip(pkgs.iter()) {
    println!("{}:", pkg);
    println!("{}", diff.trim());
}

Diff View

use aur_fetch::Fetch;
use std::process::Command;


let pkgs = vec!["discord", "spotify", "pacman-git"];

// Create our handle
let fetch = Fetch::new()?;

// Clone/Fetch the packages.
let fetched = fetch.download(&pkgs)?;

// Merge the changes.
fetch.merge(&fetched)?;

// Save diffs to cache.
fetch.save_diffs(&fetched)?;

// Make a view of the new files so we can easily see them in the file browser
let dir = fetch.make_view( "/tmp/aur_view",  &pkgs, &fetched)?;
Command::new("vifm").arg("/tmp/aur_view").spawn()?.wait()?;

Using a Callback

use aur_fetch::Fetch;


let pkgs = vec!["discord", "spotify", "pacman-git"];

// Create our handle
let fetch = Fetch::new()?;

// Clone/Fetch the packages.
let feteched = fetch.download(&pkgs)?;

// Download the packages, printing downloads as they complete.
let fetched = fetch.download_cb(&pkgs, |cb| {
    println!("Downloaded ({:0pad$}/{:0pad$}): {}", cb.n, pkgs.len(), cb.pkg, pad = 3);
})?;

// Merge the changes.
// In a real tool you would ask for user conformation before this
// As long as the changes are not merged this process can always be restarted and the diffs
// perserved
fetch.merge(&fetched)?;

Dependencies

~2MB
~63K SLoC