|
|
@ -9,10 +9,22 @@ pub fn generate(verbose: bool) {
|
|
|
|
let config = parse_cfg(verbose);
|
|
|
|
let config = parse_cfg(verbose);
|
|
|
|
log!(verbose, "Config: {:?}", config);
|
|
|
|
log!(verbose, "Config: {:?}", config);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get signing from config
|
|
|
|
|
|
|
|
let signing = &config.mode.repository.as_ref().unwrap().signing.enabled;
|
|
|
|
|
|
|
|
log!(verbose, "Signing: {:?}", signing);
|
|
|
|
|
|
|
|
|
|
|
|
// Get repository name from config
|
|
|
|
// Get repository name from config
|
|
|
|
let name = &config.mode.repository.as_ref().unwrap().name;
|
|
|
|
let name = &config.mode.repository.as_ref().unwrap().name;
|
|
|
|
log!(verbose, "Name: {}", name);
|
|
|
|
log!(verbose, "Name: {}", name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Read on_gen from config
|
|
|
|
|
|
|
|
let on_gen = &config.mode.repository.as_ref().unwrap().signing.on_gen;
|
|
|
|
|
|
|
|
log!(verbose, "On gen: {:?}", on_gen);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Read key from config
|
|
|
|
|
|
|
|
let key = &config.mode.repository.as_ref().unwrap().signing.key;
|
|
|
|
|
|
|
|
log!(verbose, "Key: {:?}", key);
|
|
|
|
|
|
|
|
|
|
|
|
info!("Generating repository: {}", name);
|
|
|
|
info!("Generating repository: {}", name);
|
|
|
|
|
|
|
|
|
|
|
|
// If repository exists, delete it
|
|
|
|
// If repository exists, delete it
|
|
|
@ -39,61 +51,19 @@ pub fn generate(verbose: bool) {
|
|
|
|
log!(verbose, "Current dir: {:?}", env::current_dir().unwrap());
|
|
|
|
log!(verbose, "Current dir: {:?}", env::current_dir().unwrap());
|
|
|
|
|
|
|
|
|
|
|
|
// Sign all package files in repository if signing and on_gen are true
|
|
|
|
// Sign all package files in repository if signing and on_gen are true
|
|
|
|
if config.mode.repository.as_ref().unwrap().signing.enabled
|
|
|
|
if *signing && on_gen.is_some() && on_gen.unwrap() {
|
|
|
|
&& config
|
|
|
|
|
|
|
|
.mode
|
|
|
|
|
|
|
|
.repository
|
|
|
|
|
|
|
|
.as_ref()
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.signing
|
|
|
|
|
|
|
|
.on_gen
|
|
|
|
|
|
|
|
.is_some()
|
|
|
|
|
|
|
|
&& config
|
|
|
|
|
|
|
|
.mode
|
|
|
|
|
|
|
|
.repository
|
|
|
|
|
|
|
|
.as_ref()
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.signing
|
|
|
|
|
|
|
|
.on_gen
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Get a list of all .tar.* files in repository
|
|
|
|
// Get a list of all .tar.* files in repository
|
|
|
|
let files = fs::read_dir(".").unwrap();
|
|
|
|
let files = fs::read_dir(".").unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
for file in files {
|
|
|
|
for file in files {
|
|
|
|
// Get file name
|
|
|
|
// Get file name
|
|
|
|
let file = file.unwrap();
|
|
|
|
let file = file.unwrap();
|
|
|
|
let path = file.path();
|
|
|
|
let path = file.path();
|
|
|
|
|
|
|
|
|
|
|
|
let sign_command = if config
|
|
|
|
let sign_command = if key.is_some() && !key.as_ref().unwrap().is_empty() {
|
|
|
|
.mode
|
|
|
|
|
|
|
|
.repository
|
|
|
|
|
|
|
|
.as_ref()
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.signing
|
|
|
|
|
|
|
|
.key
|
|
|
|
|
|
|
|
.is_some()
|
|
|
|
|
|
|
|
&& !config
|
|
|
|
|
|
|
|
.mode
|
|
|
|
|
|
|
|
.repository
|
|
|
|
|
|
|
|
.as_ref()
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.signing
|
|
|
|
|
|
|
|
.key
|
|
|
|
|
|
|
|
.as_ref()
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.is_empty()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
format!(
|
|
|
|
format!(
|
|
|
|
"gpg --default-key {} --detach-sign {}",
|
|
|
|
"gpg --default-key {} --detach-sign {}",
|
|
|
|
config
|
|
|
|
key.as_ref().unwrap(),
|
|
|
|
.mode
|
|
|
|
|
|
|
|
.repository
|
|
|
|
|
|
|
|
.as_ref()
|
|
|
|
|
|
|
|
.unwrap()
|
|
|
|
|
|
|
|
.signing
|
|
|
|
|
|
|
|
.key
|
|
|
|
|
|
|
|
.as_ref()
|
|
|
|
|
|
|
|
.unwrap(),
|
|
|
|
|
|
|
|
path.to_str().unwrap()
|
|
|
|
path.to_str().unwrap()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -135,7 +105,7 @@ pub fn generate(verbose: bool) {
|
|
|
|
// This should never happen, crash and burn if it does
|
|
|
|
// This should never happen, crash and burn if it does
|
|
|
|
if zst.success() && xz.success() {
|
|
|
|
if zst.success() && xz.success() {
|
|
|
|
crash!(
|
|
|
|
crash!(
|
|
|
|
AppExitCode::InvalidRepo,
|
|
|
|
AppExitCode::RepoParseError,
|
|
|
|
"Both .tar.zst and .tar.xz files found in repository. You've done something wrong. Aborting"
|
|
|
|
"Both .tar.zst and .tar.xz files found in repository. You've done something wrong. Aborting"
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -147,7 +117,7 @@ pub fn generate(verbose: bool) {
|
|
|
|
true
|
|
|
|
true
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
crash!(
|
|
|
|
crash!(
|
|
|
|
AppExitCode::NoPkgs,
|
|
|
|
AppExitCode::PkgsNotFound,
|
|
|
|
"No .zst or .xz packages found in repository"
|
|
|
|
"No .zst or .xz packages found in repository"
|
|
|
|
);
|
|
|
|
);
|
|
|
|
// This should theoretically never be reached, but let's just give the compiler what it wants
|
|
|
|
// This should theoretically never be reached, but let's just give the compiler what it wants
|
|
|
|