#archlinux #pkgbuild #arch #aur

aur-fetch

A libary for downloading and diffing AUR packages

17 releases (8 breaking)

0.9.1 Jan 20, 2021
0.8.1 Nov 21, 2020
0.6.0 Jul 27, 2020
0.5.0 Jun 28, 2019
0.1.0 Mar 22, 2019

#3 in #pkgbuild

Download history 2220/week @ 2021-02-26 2143/week @ 2021-03-05 2348/week @ 2021-03-12 2128/week @ 2021-03-19 2192/week @ 2021-03-26 2040/week @ 2021-04-02 2179/week @ 2021-04-09 1943/week @ 2021-04-16 2007/week @ 2021-04-23 2441/week @ 2021-04-30 2269/week @ 2021-05-07 2200/week @ 2021-05-14 2015/week @ 2021-05-21 4673/week @ 2021-05-28 4750/week @ 2021-06-04 3138/week @ 2021-06-11

9,592 downloads per month
Used in paru

GPL-3.0 license

26KB
592 lines


lib.rs:

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::Handle;

# use aur_fetch::Error;
# async fn foo() -> Result<(), Error> {

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

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

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

// 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());
}

# Ok(())
# }

Diff View

use aur_fetch::Handle;
use std::process::Command;

# use aur_fetch::Error;
# async fn foo() -> Result<(), Error> {

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

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

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

// 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(&pkgs, &fetched)?;
Command::new("vifm").arg(dir.path()).spawn()?.wait()?;

# Ok(())
# }

Using a Callback

use aur_fetch::Handle;

# use aur_fetch::Error;
# async fn foo() -> Result<(), Error> {

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

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

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

// 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);
}).await?;

// 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)?;

# Ok(())
# }

Dependencies

~5MB
~109K SLoC