Skip to content

Commit fc8c2f3

Browse files
author
Vasya Novikov
committed
use .SRCINFO, simplify non-offline build
this also simplifies up the build process for user as they're shown a summary first. Review and subsequent steps can thus be taken later. fixes GH-3
1 parent 5a05666 commit fc8c2f3

File tree

9 files changed

+269
-57
lines changed

9 files changed

+269
-57
lines changed

Cargo.lock

Lines changed: 145 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rua"
3-
version = "0.6.8"
3+
version = "0.7.0"
44
description = "AUR builder written in Rust"
55
authors = ["Vasya Novikov <n1dr+cm3513git@ya.ru>"]
66
license="GPL-3.0-or-later"
@@ -20,10 +20,11 @@ directories = "1.0"
2020
env_logger = "0.5.13"
2121
fs2 = "0.4.3"
2222
itertools = "0.7.8"
23+
lazy_static = "1.1.0"
24+
libalpm = { git = "https://github.com/jameslzhu/alpm", branch = "master" }
2325
log = "0.4"
2426
regex = "1"
2527
tar = "0.4"
26-
#libalpm = "0.1.2"
2728

2829
[dependencies.config]
2930
version = "0.9"

res/get_deps.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/aur.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ use regex::Regex;
33
use std::env;
44
use std::fs;
55
use std::io;
6-
use std::path::Path;
76
use std::process::Command;
87
use std::process::Output;
98
use util;
109

10+
pub const PREFETCH_DIR: &str = "aur.tmp";
11+
1112

1213
fn assert_command_success(command: &Output) {
1314
assert!(command.status.success(),
@@ -18,23 +19,29 @@ fn assert_command_success(command: &Output) {
1819
);
1920
}
2021

22+
2123
pub fn fresh_download(name: &str, dirs: &ProjectDirs) {
22-
let valid_name_regexp = Regex::new(r"[a-zA-Z][a-zA-Z._-]*").unwrap();
23-
assert!(valid_name_regexp.is_match(name), "unexpected package name {}", name);
24-
fs::remove_dir_all(dirs.cache_dir().join(name)).expect(&format!("Failed to clean cache dir for {}", name));
24+
lazy_static! {
25+
static ref name_regexp: Regex = Regex::new(r"[a-zA-Z][a-zA-Z._-]*").unwrap();
26+
}
27+
assert!(name_regexp.is_match(name), "unexpected package name {}", name);
28+
let path = dirs.cache_dir().join(name);
29+
if path.exists() {
30+
fs::remove_dir_all(&path).expect(&format!("Failed to clean cache dir {:?}", path));
31+
}
2532
fs::create_dir_all(dirs.cache_dir().join(name)).expect(&format!("Failed to create cache dir for {}", name));
26-
env::set_current_dir(dirs.cache_dir().join(name)).expect(&format!("Faild to cd into build dir for {}", name));
27-
let dir = "aur.tmp";
2833
let git_http_ref = format!("https://aur.archlinux.org/{}.git", name);
29-
let command = Command::new("git").args(&["clone", &git_http_ref, dir])
34+
let command = Command::new("git").args(&["clone", &git_http_ref, PREFETCH_DIR])
3035
.output().expect(&format!("Failed to git-clone repository {}", name));
3136
assert_command_success(&command);
32-
env::set_current_dir(&dir).unwrap();
33-
assert!(Path::new("PKGBUILD").exists(), "PKGBUILD not found for package {}. \
34-
Does this package really exist in AUR?", name);
37+
}
38+
39+
40+
pub fn review_repo(name: &str, dirs: &ProjectDirs) {
41+
env::set_current_dir(dirs.cache_dir().join(name).join(PREFETCH_DIR)).expect(&format!("Faild to cd into build dir for {}", name));
3542
loop {
36-
eprint!("Downloaded {}. V=view PKGBUILD, E=edit PKGBUILD, \
37-
I=run shell to inspect, O=ok, use the file: ", name);
43+
eprint!("Verifying package {}. V=view PKGBUILD, E=edit PKGBUILD, \
44+
I=run shell to inspect, O=ok, use package: ", name);
3845
let mut string = String::new();
3946
io::stdin().read_line(&mut string).expect("RUA requires console to ask confirmation.");
4047
let string = string.trim().to_lowercase();
@@ -51,6 +58,6 @@ pub fn fresh_download(name: &str, dirs: &ProjectDirs) {
5158
}
5259
}
5360
env::set_current_dir("..").unwrap();
54-
fs::rename(dir, "build")
55-
.expect(&format!("Failed to move temporary directory '{}' to 'build'", dir));
61+
fs::rename(PREFETCH_DIR, "build")
62+
.expect(&format!("Failed to move temporary directory '{}' to 'build'", PREFETCH_DIR));
5663
}

src/cli_args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ pub fn build_cli() -> App<'static, 'static> {
99
.subcommand(SubCommand::with_name("install")
1010
.about("Downloads a package by name and builds it.")
1111
.arg(Arg::with_name("offline").long("offline").short("o")
12-
.help("forbid internet access while building packages"))
12+
.help("forbid internet access while building packages (sources are downloaded using .SRCINFO)"))
1313
.arg(Arg::with_name("TARGET")
1414
.help("target package")
1515
.required(true)
1616
.index(1)))
1717
.subcommand(SubCommand::with_name("jailbuild")
1818
.about("Builds package, using PKGBUILD and wrapping in jail")
1919
.arg(Arg::with_name("offline").long("offline").short("o")
20-
.help("forbid internet access while building packages"))
20+
.help("forbid internet access while building (sources are downloaded using .SRCINFO)"))
2121
.arg(Arg::with_name("DIR")
2222
.help("directory to build")
2323
.required(false)

0 commit comments

Comments
 (0)