mirror of
https://github.com/Morganamilo/paru
synced 2024-07-01 05:54:19 +00:00
Add devel checks to tests
And fix races
This commit is contained in:
parent
1c7d7e5cd6
commit
a4eaa3c775
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@
|
|||
paru.tar.*
|
||||
po/*.mo
|
||||
locale/
|
||||
testdata/pkg/*
|
||||
|
|
|
@ -186,6 +186,7 @@ impl Config {
|
|||
Arg::Long("config") => self.pacman_conf = Some(value?.to_string()),
|
||||
|
||||
Arg::Long("builddir") | Arg::Long("clonedir") => self.build_dir = value?.into(),
|
||||
Arg::Long("develfile") => self.devel_path = value?.into(),
|
||||
Arg::Long("makepkgconf") => self.makepkg_conf = Some(value?.to_string()),
|
||||
Arg::Long("mflags") => self.mflags.extend(split_whitespace(value?)),
|
||||
Arg::Long("gitflags") => self.git_flags.extend(split_whitespace(value?)),
|
||||
|
@ -419,6 +420,7 @@ fn takes_value(arg: Arg) -> TakesValue {
|
|||
Arg::Long("builddir") => TakesValue::Required,
|
||||
Arg::Long("provides") => TakesValue::Optional,
|
||||
Arg::Long("clonedir") => TakesValue::Required,
|
||||
Arg::Long("develfile") => TakesValue::Required,
|
||||
//pacman
|
||||
Arg::Long("dbpath") | Arg::Short('b') => TakesValue::Required,
|
||||
Arg::Long("root") | Arg::Short('r') => TakesValue::Required,
|
||||
|
|
|
@ -620,11 +620,6 @@ impl Config {
|
|||
..Self::default()
|
||||
};
|
||||
|
||||
let mut fetch = config.fetch.clone();
|
||||
fetch.clone_dir = config.build_dir.join("repo");
|
||||
fetch.diff_dir = config.cache_dir.join("diff/repo");
|
||||
config.pkgbuild_repos.fetch = fetch;
|
||||
|
||||
if let Some(old) = old {
|
||||
if let Ok(devel) = OpenOptions::new().read(true).open(old) {
|
||||
if let Ok(devel) = serde_json::from_reader(devel) {
|
||||
|
|
|
@ -256,6 +256,11 @@ async fn ls_remote_intenral(
|
|||
remote: &str,
|
||||
branch: Option<&str>,
|
||||
) -> Result<String> {
|
||||
#[cfg(feature = "mock")]
|
||||
let _ = git;
|
||||
#[cfg(feature = "mock")]
|
||||
let git = "git";
|
||||
|
||||
let mut command = AsyncCommand::new(git);
|
||||
command
|
||||
.args(flags)
|
||||
|
@ -472,7 +477,7 @@ pub async fn pkg_has_update<'pkg, 'info, 'cfg>(
|
|||
async fn has_update(style: Style, git: &str, flags: &[String], url: &RepoInfo) -> Result<()> {
|
||||
let sha = ls_remote(style, git, flags, url.url.clone(), url.branch.as_deref()).await?;
|
||||
debug!(
|
||||
"devel check {}: {} == {} different: {}",
|
||||
"devel check {}: '{}' == '{}' different: {}",
|
||||
url.url,
|
||||
url.commit,
|
||||
sha,
|
||||
|
|
36
src/exec.rs
36
src/exec.rs
|
@ -210,21 +210,47 @@ pub fn pacman_output<S: AsRef<str> + Display + std::fmt::Debug>(
|
|||
command_output(&mut cmd)
|
||||
}
|
||||
|
||||
fn new_makepkg<S: AsRef<OsStr>>(config: &Config, dir: &Path, args: &[S]) -> Command {
|
||||
fn new_makepkg<S: AsRef<OsStr>>(
|
||||
config: &Config,
|
||||
dir: &Path,
|
||||
args: &[S],
|
||||
pkgdest: Option<&str>,
|
||||
) -> Command {
|
||||
let mut cmd = Command::new(&config.makepkg_bin);
|
||||
if let Some(mconf) = &config.makepkg_conf {
|
||||
cmd.arg("--config").arg(mconf);
|
||||
}
|
||||
if let Some(dest) = pkgdest {
|
||||
cmd.env("PKGDEST", dest);
|
||||
}
|
||||
cmd.args(&config.mflags).args(args).current_dir(dir);
|
||||
cmd
|
||||
}
|
||||
|
||||
pub fn makepkg<S: AsRef<OsStr>>(config: &Config, dir: &Path, args: &[S]) -> Result<Status> {
|
||||
let mut cmd = new_makepkg(config, dir, args);
|
||||
pub fn makepkg_dest<S: AsRef<OsStr>>(
|
||||
config: &Config,
|
||||
dir: &Path,
|
||||
args: &[S],
|
||||
pkgdest: Option<&str>,
|
||||
) -> Result<Status> {
|
||||
let mut cmd = new_makepkg(config, dir, args, pkgdest);
|
||||
command_status(&mut cmd)
|
||||
}
|
||||
|
||||
pub fn makepkg_output<S: AsRef<OsStr>>(config: &Config, dir: &Path, args: &[S]) -> Result<Output> {
|
||||
let mut cmd = new_makepkg(config, dir, args);
|
||||
pub fn makepkg<S: AsRef<OsStr>>(config: &Config, dir: &Path, args: &[S]) -> Result<Status> {
|
||||
makepkg_dest(config, dir, args, None)
|
||||
}
|
||||
|
||||
pub fn makepkg_output_dest<S: AsRef<OsStr>>(
|
||||
config: &Config,
|
||||
dir: &Path,
|
||||
args: &[S],
|
||||
pkgdest: Option<&str>,
|
||||
) -> Result<Output> {
|
||||
let mut cmd = new_makepkg(config, dir, args, pkgdest);
|
||||
command_output(&mut cmd)
|
||||
}
|
||||
|
||||
pub fn makepkg_output<S: AsRef<OsStr>>(config: &Config, dir: &Path, args: &[S]) -> Result<Output> {
|
||||
makepkg_output_dest(config, dir, args, None)
|
||||
}
|
||||
|
|
|
@ -498,6 +498,7 @@ impl Installer {
|
|||
Ok(debug_paths)
|
||||
}
|
||||
|
||||
// TODO: sort out args
|
||||
fn build_pkgbuild(
|
||||
&mut self,
|
||||
config: &mut Config,
|
||||
|
@ -506,6 +507,9 @@ impl Installer {
|
|||
dir: &Path,
|
||||
) -> Result<(HashMap<String, String>, String)> {
|
||||
let c = config.color;
|
||||
let pkgdest = repo.map(|r| r.1);
|
||||
let mut env = config.env.clone();
|
||||
env.extend(pkgdest.map(|p| ("PKGDEST".to_string(), p.to_string())));
|
||||
|
||||
if config.chroot {
|
||||
let mut extra = Vec::new();
|
||||
|
@ -514,7 +518,7 @@ impl Installer {
|
|||
}
|
||||
self.chroot
|
||||
.build(dir, &extra, &["-cu"], &["-ofA"], &config.env)
|
||||
.with_context(|| tr!("failed to download sources for '{}'", base))?;
|
||||
.with_context(|| tr!("failed to download sources for '{}'"))?;
|
||||
} else {
|
||||
// download sources
|
||||
let mut args = vec!["--verifysource", "-Af"];
|
||||
|
@ -536,15 +540,15 @@ impl Installer {
|
|||
}
|
||||
|
||||
printtr!("{}: parsing pkg list...", base);
|
||||
let (pkgdest, version) = parse_package_list(config, dir)?;
|
||||
let (pkgdests, version) = parse_package_list(config, dir, pkgdest)?;
|
||||
|
||||
if !base.packages().all(|p| pkgdest.contains_key(p)) {
|
||||
if !base.packages().all(|p| pkgdests.contains_key(p)) {
|
||||
bail!(tr!("package list does not match srcinfo"));
|
||||
}
|
||||
|
||||
let debug_paths = self.debug_paths(config, base, &pkgdest)?;
|
||||
let debug_paths = self.debug_paths(config, base, &pkgdests)?;
|
||||
|
||||
let needs_build = needs_build(config, base, &pkgdest, &version);
|
||||
let needs_build = needs_build(config, base, &pkgdests, &version);
|
||||
if needs_build {
|
||||
// actual build
|
||||
if config.chroot {
|
||||
|
@ -558,7 +562,7 @@ impl Installer {
|
|||
&extra,
|
||||
&[],
|
||||
&["-feA", "--noconfirm", "--noprepare", "--holdver"],
|
||||
&config.env,
|
||||
&env,
|
||||
)
|
||||
.with_context(|| tr!("failed to build '{}'", base))?;
|
||||
} else {
|
||||
|
@ -566,7 +570,7 @@ impl Installer {
|
|||
if !config.keep_src {
|
||||
args.push("-c");
|
||||
}
|
||||
exec::makepkg(config, dir, &args)?
|
||||
exec::makepkg_dest(config, dir, &args, pkgdest)?
|
||||
.success()
|
||||
.with_context(|| tr!("failed to build '{}'", base))?;
|
||||
}
|
||||
|
@ -582,9 +586,9 @@ impl Installer {
|
|||
)
|
||||
}
|
||||
|
||||
self.add_pkg(config, base, repo, &pkgdest, &debug_paths)?;
|
||||
self.queue_install(base, &pkgdest, &debug_paths);
|
||||
Ok((pkgdest, version))
|
||||
self.add_pkg(config, base, repo, &pkgdests, &debug_paths)?;
|
||||
self.queue_install(base, &pkgdests, &debug_paths);
|
||||
Ok((pkgdests, version))
|
||||
}
|
||||
|
||||
fn queue_install(
|
||||
|
@ -683,6 +687,7 @@ impl Installer {
|
|||
.clone(),
|
||||
};
|
||||
|
||||
let pkgdest = repo.map(|r| r.1);
|
||||
let build = base.build();
|
||||
|
||||
if !config.chroot
|
||||
|
@ -749,11 +754,11 @@ impl Installer {
|
|||
self.build_pkgbuild(config, base, repo, &dir)?
|
||||
} else {
|
||||
printtr!("{}: parsing pkg list...", base);
|
||||
let (pkgdest, version) = parse_package_list(config, &dir)?;
|
||||
let debug_paths = self.debug_paths(config, base, &pkgdest)?;
|
||||
self.add_pkg(config, base, repo, &pkgdest, &debug_paths)?;
|
||||
self.queue_install(base, &pkgdest, &debug_paths);
|
||||
(pkgdest, version)
|
||||
let (pkgdests, version) = parse_package_list(config, &dir, pkgdest)?;
|
||||
let debug_paths = self.debug_paths(config, base, &pkgdests)?;
|
||||
self.add_pkg(config, base, repo, &pkgdests, &debug_paths)?;
|
||||
self.queue_install(base, &pkgdests, &debug_paths);
|
||||
(pkgdests, version)
|
||||
};
|
||||
|
||||
match &*base {
|
||||
|
@ -820,7 +825,6 @@ impl Installer {
|
|||
if let Some(repo) = default_repo {
|
||||
let file = repo::file(&repo).unwrap();
|
||||
repo::init(config, file, repo.name())?;
|
||||
std::env::set_var("PKGDEST", file);
|
||||
}
|
||||
|
||||
if config.chroot {
|
||||
|
@ -1971,8 +1975,12 @@ pub fn copy_sync_args<'a>(config: &'a Config, args: &mut Args<&'a str>) {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_package_list(config: &Config, dir: &Path) -> Result<(HashMap<String, String>, String)> {
|
||||
let output = exec::makepkg_output(config, dir, &["--packagelist"])?;
|
||||
fn parse_package_list(
|
||||
config: &Config,
|
||||
dir: &Path,
|
||||
pkgdest: Option<&str>,
|
||||
) -> Result<(HashMap<String, String>, String)> {
|
||||
let output = exec::makepkg_output_dest(config, dir, &["--packagelist"], pkgdest)?;
|
||||
let output = String::from_utf8(output.stdout).context("pkgdest is not utf8")?;
|
||||
let mut pkgdests = HashMap::new();
|
||||
let mut version = String::new();
|
||||
|
|
28
src/lib.rs
28
src/lib.rs
|
@ -167,14 +167,38 @@ async fn run2<S: AsRef<str>>(config: &mut Config, args: &[S]) -> Result<i32> {
|
|||
config.parse(Some(name.as_str()), &file)?;
|
||||
};
|
||||
|
||||
log::debug!("{:#?}", config);
|
||||
|
||||
if args.is_empty() {
|
||||
config.parse_args(["-Syu"])?;
|
||||
} else {
|
||||
config.parse_args(args)?;
|
||||
}
|
||||
|
||||
let aur_url = if config.ssh {
|
||||
config
|
||||
.aur_url
|
||||
.to_string()
|
||||
.replacen("https://", "ssh://aur@", 1)
|
||||
.parse()
|
||||
.expect("change AUR URL schema from HTTPS to SSH")
|
||||
} else {
|
||||
config.aur_url.clone()
|
||||
};
|
||||
|
||||
config.fetch = aur_fetch::Fetch {
|
||||
git: config.git_bin.clone().into(),
|
||||
git_flags: config.git_flags.clone(),
|
||||
clone_dir: config.build_dir.clone(),
|
||||
diff_dir: config.cache_dir.join("diff"),
|
||||
aur_url,
|
||||
};
|
||||
|
||||
let mut fetch = config.fetch.clone();
|
||||
fetch.clone_dir = config.build_dir.join("repo");
|
||||
fetch.diff_dir = config.cache_dir.join("diff/repo");
|
||||
config.pkgbuild_repos.fetch = fetch;
|
||||
|
||||
log::debug!("{:#?}", config);
|
||||
|
||||
handle_cmd(config).await
|
||||
}
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ pub fn refresh<S: AsRef<OsStr>>(config: &mut Config, repos: &[S]) -> Result<i32>
|
|||
);
|
||||
|
||||
if !dbs.is_empty() {
|
||||
dbs.update(false)?;
|
||||
dbs.update(cfg!(feature = "mock"))?;
|
||||
} else {
|
||||
printtr!(" nothing to do");
|
||||
}
|
||||
|
|
2
testdata/bin/makepkg.bak
vendored
Executable file
2
testdata/bin/makepkg.bak
vendored
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
bash -x /usr/local/bin/local/makepkg "$@" | tee /dev/tty
|
2
testdata/bin/pacman
vendored
2
testdata/bin/pacman
vendored
|
@ -1,2 +1,2 @@
|
|||
#!/bin/sh
|
||||
/usr/bin/pacman --config "$PACMAN_CONF" --dbpath "$DBPATH" "$@"
|
||||
/usr/local/bin/pacman --config "$PACMAN_CONF" --dbpath "$DBPATH" "$@"
|
||||
|
|
3
testdata/bin/pacman.bak
vendored
Executable file
3
testdata/bin/pacman.bak
vendored
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
#/usr/local/bin/pacman --config "$PACMAN_CONF" --dbpath "$DBPATH" "$@"
|
||||
/usr/local/bin/pacman "$@"
|
BIN
testdata/clone/auracle-git/repo/auracle-git-r366.8739929-1-x86_64.pkg.tar.gz
vendored
Normal file
BIN
testdata/clone/auracle-git/repo/auracle-git-r366.8739929-1-x86_64.pkg.tar.gz
vendored
Normal file
Binary file not shown.
8
testdata/clone/devel/.SRCINFO
vendored
Normal file
8
testdata/clone/devel/.SRCINFO
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
pkgbase = devel
|
||||
pkgver = 1
|
||||
pkgrel = 1
|
||||
arch = any
|
||||
source = git+file:////Users/morganamilo/git/paru/testdata/clone/devel/../../git-repo
|
||||
sha256sums = SKIP
|
||||
|
||||
pkgname = devel
|
6
testdata/clone/devel/PKGBUILD
vendored
Normal file
6
testdata/clone/devel/PKGBUILD
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
pkgname=devel
|
||||
pkgver=2
|
||||
pkgrel=1
|
||||
arch=(any)
|
||||
source=(git+file:///$PWD/../../git-repo)
|
||||
sha256sums=(SKIP)
|
33
testdata/db/local/devel-1-1/desc
vendored
Normal file
33
testdata/db/local/devel-1-1/desc
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
%NAME%
|
||||
devel
|
||||
|
||||
%VERSION%
|
||||
1-1
|
||||
|
||||
%BASE%
|
||||
devel
|
||||
|
||||
%DESC%
|
||||
|
||||
|
||||
%URL%
|
||||
|
||||
|
||||
%ARCH%
|
||||
any
|
||||
|
||||
%BUILDDATE%
|
||||
1697290439
|
||||
|
||||
%INSTALLDATE%
|
||||
1697290651
|
||||
|
||||
%PACKAGER%
|
||||
Unknown Packager
|
||||
|
||||
%VALIDATION%
|
||||
none
|
||||
|
||||
%XDATA%
|
||||
pkgtype=pkg
|
||||
|
0
testdata/db/local/devel-1-1/files
vendored
Normal file
0
testdata/db/local/devel-1-1/files
vendored
Normal file
BIN
testdata/db/local/devel-1-1/mtree
vendored
Normal file
BIN
testdata/db/local/devel-1-1/mtree
vendored
Normal file
Binary file not shown.
3
testdata/devel.toml
vendored
Normal file
3
testdata/devel.toml
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[[devel]]
|
||||
url = "file:////Users/morganamilo/git/paru/testdata/clone/devel/../../git-repo"
|
||||
commit = "deadbeef"
|
1
testdata/git-repo/HEAD
vendored
Normal file
1
testdata/git-repo/HEAD
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
ref: refs/heads/main
|
8
testdata/git-repo/config
vendored
Normal file
8
testdata/git-repo/config
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = true
|
||||
ignorecase = true
|
||||
precomposeunicode = true
|
||||
[remote "origin"]
|
||||
url = /Users/morganamilo/a
|
1
testdata/git-repo/description
vendored
Normal file
1
testdata/git-repo/description
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
Unnamed repository; edit this file 'description' to name the repository.
|
6
testdata/git-repo/info/exclude
vendored
Normal file
6
testdata/git-repo/info/exclude
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
# git ls-files --others --exclude-from=.git/info/exclude
|
||||
# Lines that start with '#' are comments.
|
||||
# For a project mostly in C, the following would be a good set of
|
||||
# exclude patterns (uncomment them if you want to use them):
|
||||
# *.[oa]
|
||||
# *~
|
BIN
testdata/git-repo/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904
vendored
Normal file
BIN
testdata/git-repo/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904
vendored
Normal file
Binary file not shown.
3
testdata/git-repo/objects/62/ba46861565a44a61b16968f9ef248f2828cb94
vendored
Normal file
3
testdata/git-repo/objects/62/ba46861565a44a61b16968f9ef248f2828cb94
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
x¥<>A
|
||||
Â0E]ç³d&q"^e’Nm i ¤èñ-®ÜË_=x¼Ÿ[e€e:<3A>®
|
||||
”Øù)r9MQ0 zJ3O!:æ9©RD2²<32>¥u¨?e“ZÖ·xHÏËZ¶ý}9Œ;دŽ#yg´ˆ&<>‡þ‘0ò:f>ù5>E
|
2
testdata/git-repo/packed-refs
vendored
Normal file
2
testdata/git-repo/packed-refs
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
# pack-refs with: peeled fully-peeled sorted
|
||||
62ba46861565a44a61b16968f9ef248f2828cb94 refs/heads/main
|
38
testdata/makepkg.conf
vendored
Normal file
38
testdata/makepkg.conf
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
DLAGENTS=('file::/usr/bin/curl -qgC - -o %o %u'
|
||||
'ftp::/usr/bin/curl -qgfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
|
||||
'http::/usr/bin/curl -qgb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
|
||||
'https::/usr/bin/curl -qgb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
|
||||
'rsync::/usr/bin/rsync --no-motd -z %u %o'
|
||||
'scp::/usr/bin/scp -C %u %o')
|
||||
|
||||
VCSCLIENTS=('bzr::bzr'
|
||||
'fossil::fossil'
|
||||
'git::git'
|
||||
'hg::mercurial'
|
||||
'svn::subversion')
|
||||
|
||||
CARCH="x86_64"
|
||||
CHOST="x86_64-unknown-linux-gnu"
|
||||
BUILDENV=(!distcc color !ccache check !sign)
|
||||
INTEGRITY_CHECK=(ck)
|
||||
STRIP_BINARIES=""
|
||||
STRIP_SHARED="-s"
|
||||
STRIP_STATIC="-s"
|
||||
MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
|
||||
DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
|
||||
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
|
||||
DBGSRCDIR="/usr/src/debug"
|
||||
LIB_DIRS=('lib:usr/lib' 'lib32:usr/lib32')
|
||||
|
||||
COMPRESSGZ=(gzip -c -f -n)
|
||||
COMPRESSBZ2=(bzip2 -c -f)
|
||||
COMPRESSXZ=(xz -c -z -)
|
||||
COMPRESSZST=(zstd -c -z -q -)
|
||||
COMPRESSLRZ=(lrzip -q)
|
||||
COMPRESSLZO=(lzop -q)
|
||||
COMPRESSZ=(compress -c -f)
|
||||
COMPRESSLZ4=(lz4 -q)
|
||||
COMPRESSLZ=(lzip -c -f)
|
||||
|
||||
PKGEXT='.pkg.tar.gz'
|
||||
SRCEXT='.src.tar.gz'
|
7
testdata/pkgbuild-repo/a/.SRCINFO
vendored
Normal file
7
testdata/pkgbuild-repo/a/.SRCINFO
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
pkgbase = a
|
||||
pkgver = 1
|
||||
pkgrel = 1
|
||||
arch = any
|
||||
depends = b
|
||||
|
||||
pkgname = a
|
5
testdata/pkgbuild-repo/a/PKGBUILD
vendored
Normal file
5
testdata/pkgbuild-repo/a/PKGBUILD
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
pkgname=a
|
||||
pkgver=1
|
||||
pkgrel=1
|
||||
arch=(any)
|
||||
depends=(b)
|
BIN
testdata/pkgbuild-repo/a/a-1-1-any.pkg.tar.gz
vendored
Normal file
BIN
testdata/pkgbuild-repo/a/a-1-1-any.pkg.tar.gz
vendored
Normal file
Binary file not shown.
7
testdata/pkgbuild-repo/b/.SRCINFO
vendored
Normal file
7
testdata/pkgbuild-repo/b/.SRCINFO
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
pkgbase = b
|
||||
pkgver = 1
|
||||
pkgrel = 1
|
||||
arch = any
|
||||
depends = c
|
||||
|
||||
pkgname = b
|
5
testdata/pkgbuild-repo/b/PKGBUILD
vendored
Normal file
5
testdata/pkgbuild-repo/b/PKGBUILD
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
pkgname=b
|
||||
pkgver=1
|
||||
pkgrel=1
|
||||
arch=(any)
|
||||
depends=(c)
|
BIN
testdata/pkgbuild-repo/b/b-1-1-any.pkg.tar.gz
vendored
Normal file
BIN
testdata/pkgbuild-repo/b/b-1-1-any.pkg.tar.gz
vendored
Normal file
Binary file not shown.
6
testdata/pkgbuild-repo/c/.SRCINFO
vendored
Normal file
6
testdata/pkgbuild-repo/c/.SRCINFO
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
pkgbase = c
|
||||
pkgver = 1
|
||||
pkgrel = 1
|
||||
arch = any
|
||||
|
||||
pkgname = c
|
4
testdata/pkgbuild-repo/c/PKGBUILD
vendored
Normal file
4
testdata/pkgbuild-repo/c/PKGBUILD
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
pkgname=c
|
||||
pkgver=1
|
||||
pkgrel=1
|
||||
arch=(any)
|
BIN
testdata/pkgbuild-repo/c/c-1-1-any.pkg.tar.gz
vendored
Normal file
BIN
testdata/pkgbuild-repo/c/c-1-1-any.pkg.tar.gz
vendored
Normal file
Binary file not shown.
BIN
testdata/repo/repo.db.tar.gz
vendored
BIN
testdata/repo/repo.db.tar.gz
vendored
Binary file not shown.
|
@ -1,7 +1,7 @@
|
|||
#![cfg(feature = "mock")]
|
||||
|
||||
use alpm::Alpm;
|
||||
use anyhow::Result;
|
||||
use anyhow::{Context, Result};
|
||||
use std::env::var;
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
|
@ -15,21 +15,35 @@ async fn run(run_args: &[&str], repo: bool) -> Result<(TempDir, i32)> {
|
|||
let testdata = Path::new(&var("CARGO_MANIFEST_DIR").unwrap()).join("testdata");
|
||||
|
||||
let status = Command::new("cp")
|
||||
.arg("-r")
|
||||
.arg("-rp")
|
||||
.arg(testdata.join("pacman.conf"))
|
||||
.arg(dir.join("pacman.conf"))
|
||||
.status()?;
|
||||
assert!(status.success());
|
||||
|
||||
let status = Command::new("cp")
|
||||
.arg("-r")
|
||||
.arg("-rp")
|
||||
.arg(testdata.join("makepkg.conf"))
|
||||
.arg(dir.join("makepkg.conf"))
|
||||
.status()?;
|
||||
assert!(status.success());
|
||||
|
||||
let status = Command::new("cp")
|
||||
.arg("-rp")
|
||||
.arg(testdata.join("devel.toml"))
|
||||
.arg(dir.join("devel.toml"))
|
||||
.status()?;
|
||||
assert!(status.success());
|
||||
|
||||
let status = Command::new("cp")
|
||||
.arg("-rp")
|
||||
.arg(testdata.join("db"))
|
||||
.arg(dir.join("db"))
|
||||
.status()?;
|
||||
assert!(status.success());
|
||||
|
||||
let status = Command::new("cp")
|
||||
.arg("-r")
|
||||
.arg("-rp")
|
||||
.arg(testdata.join("pkgbuild-repo"))
|
||||
.arg(dir.join("pkgbuils-repo"))
|
||||
.status()?;
|
||||
|
@ -37,13 +51,25 @@ async fn run(run_args: &[&str], repo: bool) -> Result<(TempDir, i32)> {
|
|||
|
||||
if repo {
|
||||
let status = Command::new("cp")
|
||||
.arg("-r")
|
||||
.arg("-rp")
|
||||
.arg(testdata.join("repo"))
|
||||
.arg(dir.join("repo"))
|
||||
.status()?;
|
||||
assert!(status.success());
|
||||
}
|
||||
|
||||
std::fs::create_dir(dir.join("cache"))?;
|
||||
|
||||
let mut file = fs::OpenOptions::new()
|
||||
.append(true)
|
||||
.open(dir.join("makepkg.conf"))?;
|
||||
|
||||
writeln!(
|
||||
file,
|
||||
"\n PKGDEST={0:}/pkgdest \n SRCDEST={0:}/src \n BUILDDIR={0:}/build",
|
||||
dir.join("cache").to_str().unwrap(),
|
||||
)?;
|
||||
|
||||
let mut file = fs::OpenOptions::new()
|
||||
.write(true)
|
||||
.append(true)
|
||||
|
@ -53,8 +79,10 @@ async fn run(run_args: &[&str], repo: bool) -> Result<(TempDir, i32)> {
|
|||
file,
|
||||
"[options]
|
||||
DBPath = {}
|
||||
CacheDir = {}
|
||||
CacheDir = {}",
|
||||
dir.join("db").to_str().unwrap(),
|
||||
dir.join("cache/pkg").to_str().unwrap(),
|
||||
testdata.join("pkg").to_str().unwrap()
|
||||
)?;
|
||||
|
||||
|
@ -63,14 +91,15 @@ async fn run(run_args: &[&str], repo: bool) -> Result<(TempDir, i32)> {
|
|||
file,
|
||||
"[repo]
|
||||
Server = file://{0:}/repo
|
||||
SigLevel = Never
|
||||
[options]
|
||||
CacheDir = {0:}/repo",
|
||||
dir.display()
|
||||
SigLevel = Never",
|
||||
dir.display(),
|
||||
)?;
|
||||
std::fs::write(dir.join("localrepo"), "1")?;
|
||||
}
|
||||
|
||||
let mconf = dir.join("makepkg.conf");
|
||||
let mconf = mconf.to_str();
|
||||
|
||||
let pconf = dir.join("pacman.conf");
|
||||
let pconf = pconf.to_str();
|
||||
|
||||
|
@ -80,6 +109,9 @@ async fn run(run_args: &[&str], repo: bool) -> Result<(TempDir, i32)> {
|
|||
let clonedir = testdata.join("clone");
|
||||
let clonedir = clonedir.to_str();
|
||||
|
||||
let develfile = dir.join("devel.toml");
|
||||
let develfile = develfile.to_str();
|
||||
|
||||
let mut args = vec![
|
||||
"--root=/var/empty",
|
||||
"--dbonly",
|
||||
|
@ -91,6 +123,10 @@ async fn run(run_args: &[&str], repo: bool) -> Result<(TempDir, i32)> {
|
|||
clonedir.unwrap(),
|
||||
"--config",
|
||||
pconf.unwrap(),
|
||||
"--develfile",
|
||||
develfile.unwrap(),
|
||||
"--makepkgconf",
|
||||
mconf.unwrap(),
|
||||
];
|
||||
|
||||
if repo {
|
||||
|
@ -101,12 +137,37 @@ async fn run(run_args: &[&str], repo: bool) -> Result<(TempDir, i32)> {
|
|||
path.push(':');
|
||||
path.push_str(testdata.join("bin").to_str().unwrap());
|
||||
|
||||
std::env::set_var("PACMAN", testdata.join("bin/pacman"));
|
||||
std::env::set_var("PACMAN", "true");
|
||||
std::env::set_var("PACMAN_CONF", dir.join("pacman.conf"));
|
||||
std::env::set_var("DBPATH", dir.join("db"));
|
||||
std::env::set_var("PARU_CONF", testdata.join("paru.conf"));
|
||||
std::env::set_var("PATH", path);
|
||||
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_CHECKDEPENDS_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_VARIABLE_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_PKGVER_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_ARCH_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_MAKEDEPENDS_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_PACKAGE_FUNCTION_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_SOURCE_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_OPTIONS_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_PROVIDES_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_OPTDEPENDS_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_CHANGELOG_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_INSTALL_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_PKGBASE_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_FULLPKGVER_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_PKGREL_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_EPOCH_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_BACKUP_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_PKGNAME_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_PKGLIST_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_UTIL_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_PACKAGE_FUNCTION_VARIABLE_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_DEPENDS_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_CONFLICTS_SH", "1");
|
||||
std::env::set_var("LIBMAKEPKG_LINT_PKGBUILD_ARCH_SPECIFIC_SH", "1");
|
||||
|
||||
if repo {
|
||||
let mut args = args.clone();
|
||||
args.push("-Ly");
|
||||
|
@ -116,6 +177,15 @@ async fn run(run_args: &[&str], repo: bool) -> Result<(TempDir, i32)> {
|
|||
|
||||
args.extend(run_args);
|
||||
let ret = paru::run(&args).await;
|
||||
|
||||
for pkg in std::fs::read_dir(dir.join("cache"))? {
|
||||
let name = pkg?.path();
|
||||
let name = name.file_name().unwrap().to_str().unwrap();
|
||||
if name.ends_with(".pkg.tar.zst") {
|
||||
std::fs::rename(name, testdata.join("pkg").join(name))?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok((tmp, ret))
|
||||
}
|
||||
|
||||
|
@ -156,6 +226,8 @@ pub fn alpm(tmp: &TempDir) -> Result<Alpm> {
|
|||
|
||||
pub fn assert_in_local_repo(alpm: &Alpm, pkg: &str) {
|
||||
if let Some(repo) = alpm.syncdbs().iter().find(|db| db.name() == "repo") {
|
||||
repo.pkg(pkg).unwrap();
|
||||
repo.pkg(pkg)
|
||||
.context(pkg.to_string())
|
||||
.expect("pkg not in local repo");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,3 +188,14 @@ async fn pkgbuild_repo() {
|
|||
assert_eq!(b.reason(), PackageReason::Depend);
|
||||
assert_eq!(c.reason(), PackageReason::Depend);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn devel() {
|
||||
let (tmp, ret) = run(&["-Sua", "--devel"]).await.unwrap();
|
||||
assert_eq!(ret, 0);
|
||||
let alpm = alpm(&tmp).unwrap();
|
||||
|
||||
let db = alpm.localdb();
|
||||
let a = db.pkg("devel").unwrap();
|
||||
assert_eq!(a.version().as_str(), "2-1");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user