Fixed install_package except WHERE TF IS IT PUTTING THE SYMLINKS
This commit is contained in:
parent
af2897efb1
commit
aa66e60019
1 changed files with 52 additions and 34 deletions
|
@ -6,6 +6,7 @@
|
||||||
clippy::missing_panics_doc
|
clippy::missing_panics_doc
|
||||||
)]
|
)]
|
||||||
#![feature(str_as_str)]
|
#![feature(str_as_str)]
|
||||||
|
#![feature(impl_trait_in_bindings)]
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
ffi::OsString,
|
ffi::OsString,
|
||||||
|
@ -1076,47 +1077,64 @@ pub fn install_package(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fuck me.
|
||||||
|
#[derive(Clone)]
|
||||||
|
struct VisitDir<'a> {
|
||||||
|
/// Fuck me.
|
||||||
|
f: &'a dyn Fn(std::io::Result<std::fs::DirEntry>, VisitDir) -> std::io::Result<()>
|
||||||
|
}
|
||||||
|
|
||||||
|
let diritem = VisitDir {
|
||||||
|
f: &|entry: std::io::Result<std::fs::DirEntry>, visit_dir: VisitDir| -> std::io::Result<()> {
|
||||||
|
let entry = entry?;
|
||||||
|
|
||||||
|
if entry.file_name() == *".BUILDINFO"
|
||||||
|
|| entry.file_name() == *".MTREE"
|
||||||
|
|| entry.file_name() == *".PKGINFO"
|
||||||
|
{
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
if entry.file_type()?.is_dir() {
|
||||||
|
std::fs::create_dir_all(out.join(entry.path()))?;
|
||||||
|
for entry in std::fs::read_dir(path.join(entry.path()))? {
|
||||||
|
(visit_dir.clone().f)(entry, visit_dir.clone())?;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::fs::create_dir_all(out.join(entry.path().parent().unwrap()))?;
|
||||||
|
std::fs::remove_file(out.join(entry.path()))?;
|
||||||
|
std::os::unix::fs::symlink(path.join(entry.path()), out.join(entry.path()))?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
for entry in std::fs::read_dir(&path)? {
|
for entry in std::fs::read_dir(&path)? {
|
||||||
println!("entry");
|
(diritem.clone().f)(entry, diritem.clone())?;
|
||||||
let entry = entry?;
|
}
|
||||||
|
|
||||||
if entry.file_name() == *".BUILDINFO"
|
if std::fs::exists(out.join(".INSTALL"))? {
|
||||||
|| entry.file_name() == *".MTREE"
|
std::os::unix::fs::chroot(&out)?;
|
||||||
|| entry.file_name() == *".PKGINFO"
|
|
||||||
|
if !std::process::Command::new("/usr/bin/bash")
|
||||||
|
.arg("-c")
|
||||||
|
.arg("source /.INSTALL && post_install && post_upgrade")
|
||||||
|
.current_dir(&out)
|
||||||
|
.spawn()?
|
||||||
|
.wait()?
|
||||||
|
.success()
|
||||||
{
|
{
|
||||||
continue;
|
println!(
|
||||||
|
"[WARN] .INSTALL script for package {} failed!",
|
||||||
|
path.file_name().unwrap().to_string_lossy()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
println!("{}", entry.file_name().to_string_lossy());
|
|
||||||
|
|
||||||
if entry.file_type()?.is_dir() {
|
std::os::unix::fs::chroot(".")?;
|
||||||
std::fs::create_dir_all(out.join(entry.path()))?;
|
|
||||||
} else {
|
std::fs::remove_file(out.join(".INSTALL"))?;
|
||||||
std::fs::create_dir_all(out.join(entry.path().parent().unwrap()))?;
|
|
||||||
std::fs::remove_file(out.join(entry.path()))?;
|
|
||||||
std::os::unix::fs::symlink(path.join(entry.path()), out.join(entry.path()))?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::os::unix::fs::chroot(&out)?;
|
|
||||||
|
|
||||||
if !std::process::Command::new("/usr/bin/bash")
|
|
||||||
.arg("-c")
|
|
||||||
.arg("source /.INSTALL && post_install && post_upgrade")
|
|
||||||
.current_dir(&out)
|
|
||||||
.spawn()?
|
|
||||||
.wait()?
|
|
||||||
.success()
|
|
||||||
{
|
|
||||||
println!(
|
|
||||||
"[WARN] .INSTALL script for package {} failed!",
|
|
||||||
path.file_name().unwrap().to_string_lossy()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::os::unix::fs::chroot(".")?;
|
|
||||||
|
|
||||||
std::fs::remove_file(out.join(".INSTALL"))?;
|
|
||||||
|
|
||||||
let mut packages = std::fs::OpenOptions::new()
|
let mut packages = std::fs::OpenOptions::new()
|
||||||
.create(true)
|
.create(true)
|
||||||
.append(true)
|
.append(true)
|
||||||
|
|
Loading…
Add table
Reference in a new issue