Skip to content
Permalink
Browse files

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
  • Loading branch information...
vn971 committed Oct 31, 2018
1 parent 5a05666 commit fc8c2f307e6c3e9fbc6cacd32abd94ebce3a17c8
Showing with 269 additions and 57 deletions.
  1. +145 −1 Cargo.lock
  2. +3 −2 Cargo.toml
  3. +0 −15 res/get_deps.sh
  4. +21 −14 src/aur.rs
  5. +2 −2 src/cli_args.rs
  6. +3 −1 src/main.rs
  7. +1 −1 src/pacman.rs
  8. +68 −0 src/srcinfo.rs
  9. +26 −21 src/wrapped.rs

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -1,6 +1,6 @@
[package]
name = "rua"
version = "0.6.8"
version = "0.7.0"
description = "AUR builder written in Rust"
authors = ["Vasya Novikov <n1dr+cm3513git@ya.ru>"]
license="GPL-3.0-or-later"
@@ -20,10 +20,11 @@ directories = "1.0"
env_logger = "0.5.13"
fs2 = "0.4.3"
itertools = "0.7.8"
lazy_static = "1.1.0"
libalpm = { git = "https://github.com/jameslzhu/alpm", branch = "master" }
log = "0.4"
regex = "1"
tar = "0.4"
#libalpm = "0.1.2"

[dependencies.config]
version = "0.9"

This file was deleted.

Oops, something went wrong.
@@ -3,11 +3,12 @@ use regex::Regex;
use std::env;
use std::fs;
use std::io;
use std::path::Path;
use std::process::Command;
use std::process::Output;
use util;

pub const PREFETCH_DIR: &str = "aur.tmp";


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


pub fn fresh_download(name: &str, dirs: &ProjectDirs) {
let valid_name_regexp = Regex::new(r"[a-zA-Z][a-zA-Z._-]*").unwrap();
assert!(valid_name_regexp.is_match(name), "unexpected package name {}", name);
fs::remove_dir_all(dirs.cache_dir().join(name)).expect(&format!("Failed to clean cache dir for {}", name));
lazy_static! {
static ref name_regexp: Regex = Regex::new(r"[a-zA-Z][a-zA-Z._-]*").unwrap();
}
assert!(name_regexp.is_match(name), "unexpected package name {}", name);
let path = dirs.cache_dir().join(name);
if path.exists() {
fs::remove_dir_all(&path).expect(&format!("Failed to clean cache dir {:?}", path));
}
fs::create_dir_all(dirs.cache_dir().join(name)).expect(&format!("Failed to create cache dir for {}", name));
env::set_current_dir(dirs.cache_dir().join(name)).expect(&format!("Faild to cd into build dir for {}", name));
let dir = "aur.tmp";
let git_http_ref = format!("https://aur.archlinux.org/{}.git", name);
let command = Command::new("git").args(&["clone", &git_http_ref, dir])
let command = Command::new("git").args(&["clone", &git_http_ref, PREFETCH_DIR])
.output().expect(&format!("Failed to git-clone repository {}", name));
assert_command_success(&command);
env::set_current_dir(&dir).unwrap();
assert!(Path::new("PKGBUILD").exists(), "PKGBUILD not found for package {}. \
Does this package really exist in AUR?", name);
}


pub fn review_repo(name: &str, dirs: &ProjectDirs) {
env::set_current_dir(dirs.cache_dir().join(name).join(PREFETCH_DIR)).expect(&format!("Faild to cd into build dir for {}", name));
loop {
eprint!("Downloaded {}. V=view PKGBUILD, E=edit PKGBUILD, \
I=run shell to inspect, O=ok, use the file: ", name);
eprint!("Verifying package {}. V=view PKGBUILD, E=edit PKGBUILD, \
I=run shell to inspect, O=ok, use package: ", name);
let mut string = String::new();
io::stdin().read_line(&mut string).expect("RUA requires console to ask confirmation.");
let string = string.trim().to_lowercase();
@@ -51,6 +58,6 @@ pub fn fresh_download(name: &str, dirs: &ProjectDirs) {
}
}
env::set_current_dir("..").unwrap();
fs::rename(dir, "build")
.expect(&format!("Failed to move temporary directory '{}' to 'build'", dir));
fs::rename(PREFETCH_DIR, "build")
.expect(&format!("Failed to move temporary directory '{}' to 'build'", PREFETCH_DIR));
}
@@ -9,15 +9,15 @@ pub fn build_cli() -> App<'static, 'static> {
.subcommand(SubCommand::with_name("install")
.about("Downloads a package by name and builds it.")
.arg(Arg::with_name("offline").long("offline").short("o")
.help("forbid internet access while building packages"))
.help("forbid internet access while building packages (sources are downloaded using .SRCINFO)"))
.arg(Arg::with_name("TARGET")
.help("target package")
.required(true)
.index(1)))
.subcommand(SubCommand::with_name("jailbuild")
.about("Builds package, using PKGBUILD and wrapping in jail")
.arg(Arg::with_name("offline").long("offline").short("o")
.help("forbid internet access while building packages"))
.help("forbid internet access while building (sources are downloaded using .SRCINFO)"))
.arg(Arg::with_name("DIR")
.help("directory to build")
.required(false)
Oops, something went wrong.

0 comments on commit fc8c2f3

Please sign in to comment.
You can’t perform that action at this time.