Skip to content

Commit

Permalink
[antlir][rpm] Add param to explictly define directories
Browse files Browse the repository at this point in the history
Summary:
A new, safer approach to adding dirs to package.rpm after failed attempt in D66033287.

While dirs that include files get automatically packaged into the rpm, we don't mark them with `%dir` so that the rpm doesn't "own" lots of paths that are prone to conflict on installation (like `/usr/lib`). However, if a user wants their rpm to explicitly "own" a dir, most likely in the case of an empty dir, we provide that here.

As indicated in the comment, the dir must exist in the package contents (usually antlir layer) or else the rpm build will fail as we dont automatically `mkdir` any dirs in `dirs`

Test Plan: see above diff

Reviewed By: justintrudell

Differential Revision: D66365747

fbshipit-source-id: 765f40a3f3485e2bf465ff8bbd931c08bd097473
  • Loading branch information
Naveed Golafshani authored and facebook-github-bot committed Dec 5, 2024
1 parent dcb1e11 commit 898f3a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions antlir/antlir2/antlir2_packager/src/rpm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ pub struct Rpm {
#[serde(default)]
extra_files: Vec<String>,
#[serde(default)]
dirs: Vec<String>,
#[serde(default)]
python_bytecompile: bool,
#[serde(default)]
autoreq: bool,
Expand Down Expand Up @@ -329,6 +331,9 @@ AutoProv: {autoprov}
spec.push_str(extra_file);
spec.push('\n');
}
for dir in &self.dirs {
spec.push_str(&format!("%dir {dir}\n"));
}

let output_dir = tempfile::tempdir().context("while creating temp dir for rpm output")?;
// create the arch-specific output dir explicitly so that it'll be
Expand Down
5 changes: 5 additions & 0 deletions antlir/antlir2/bzl/package/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ _rpm, _rpm_anon = _new_package_rule(
"changelog": attrs.option(attrs.string(), default = None),
"conflicts": attrs.list(attrs.string(), default = []),
"description": attrs.option(attrs.string(), default = None),
"dirs": attrs.list(
attrs.string(),
default = [],
doc = "List of directories that will be explictly 'owned' by the rpm. Dirs must already exist in the package contents.",
),
"disable_build_id_links": attrs.bool(default = False),
"disable_ldconfig": attrs.bool(default = False),
"disable_strip": attrs.bool(default = False),
Expand Down

0 comments on commit 898f3a0

Please sign in to comment.