Skip to content

Commit

Permalink
Update Schema, Improve Code
Browse files Browse the repository at this point in the history
  • Loading branch information
naman-crabnebula committed Jan 11, 2024
1 parent 7663eb6 commit 3138889
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changes/priority-and-section.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cargo-packager": minor
---

Add the support for priority and section in Debian Config
14 changes: 14 additions & 0 deletions bindings/packager/nodejs/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,20 @@
"null"
]
},
"section": {
"description": "Define the section in Debian Control file. See : https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections",
"type": [
"string",
"null"
]
},
"priority": {
"description": "Change the priority of the Debian Package. By default, it is set to optional. Recognized Priorities as of now are : required, important, standard, optional, extra",
"type": [
"string",
"null"
]
},
"files": {
"description": "List of custom files to add to the deb package. Maps a dir/file to a dir/file inside the debian package.",
"type": [
Expand Down
14 changes: 14 additions & 0 deletions crates/packager/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,20 @@
"null"
]
},
"section": {
"description": "Define the section in Debian Control file. See : https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections",
"type": [
"string",
"null"
]
},
"priority": {
"description": "Change the priority of the Debian Package. By default, it is set to optional. Recognized Priorities as of now are : required, important, standard, optional, extra",
"type": [
"string",
"null"
]
},
"files": {
"description": "List of custom files to add to the deb package. Maps a dir/file to a dir/file inside the debian package.",
"type": [
Expand Down
19 changes: 7 additions & 12 deletions crates/packager/src/package/deb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::{
fs::File,
io::Write,
path::{Path, PathBuf},
os::unix::fs::MetadataExt,
};

use handlebars::Handlebars;
Expand All @@ -18,6 +19,7 @@ use image::{codecs::png::PngDecoder, ImageDecoder};
use relative_path::PathExt;
use serde::Serialize;
use walkdir::WalkDir;
use tar::HeaderMode;

use super::Context;
use crate::{
Expand Down Expand Up @@ -426,22 +428,15 @@ fn create_tar_from_dir<P: AsRef<Path>, W: Write>(src_dir: P, dest_file: W) -> cr
continue;
}
let dest_path = src_path.strip_prefix(src_dir)?;
let stat = std::fs::metadata(src_path)?;
let mut header = tar::Header::new_gnu();
header.set_metadata_in_mode(&stat, HeaderMode::Deterministic);
header.set_mtime(stat.mtime() as u64);

if entry.file_type().is_dir() {
let stat = std::fs::metadata(src_path)?;
let mut header = tar::Header::new_gnu();
header.set_mode(0o755);
header.set_metadata(&stat);
header.set_uid(0);
header.set_gid(0);
tar_builder.append_data(&mut header, dest_path, &mut std::io::empty())?;
} else {
let mut src_file = std::fs::File::open(src_path)?;
let stat = src_file.metadata()?;
let mut header = tar::Header::new_gnu();
header.set_mode(0o644);
header.set_metadata(&stat);
header.set_uid(0);
header.set_gid(0);
tar_builder.append_data(&mut header, dest_path, &mut src_file)?;
}
}
Expand Down

0 comments on commit 3138889

Please sign in to comment.