Skip to content

Commit

Permalink
Merge pull request #2842 from cgwalters/remove-more-rojig-bits
Browse files Browse the repository at this point in the history
  • Loading branch information
jlebon authored May 25, 2021
2 parents 9244d7a + 7082822 commit f3ccb97
Show file tree
Hide file tree
Showing 20 changed files with 50 additions and 684 deletions.
1 change: 0 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ echo "
$PACKAGE $VERSION

introspection: $found_introspection
rojig: ${enable_rojig:-no}
ASAN + UBSAN: ${enable_sanitizers:-no}
gtk-doc: $enable_gtk_doc
rust: $rust_debug_release
Expand Down
2 changes: 0 additions & 2 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,6 @@ pub mod ffi {
fn format_install_langs_macro(&self) -> String;
fn get_lockfile_repos(&self) -> Vec<String>;
fn get_ref(&self) -> &str;
fn get_rojig_spec_path(&self) -> String;
fn get_rojig_name(&self) -> String;
fn get_cliwrap(&self) -> bool;
fn get_readonly_executables(&self) -> bool;
fn get_documentation(&self) -> bool;
Expand Down
58 changes: 4 additions & 54 deletions rust/src/origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ use std::result::Result as StdResult;

use std::collections::{BTreeMap, BTreeSet};

const ROJIG_PREFIX: &str = "rojig://";
const ORIGIN: &str = "origin";
const OVERRIDE_COMMIT: &str = "override-commit";

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub(crate) enum RefspecType {
Checksum,
Ostree,
Rojig,
}

#[derive(Clone, Debug, PartialEq, Eq)]
Expand All @@ -37,9 +35,6 @@ struct Cache {
override_commit: Option<String>,
#[allow(dead_code)]
unconfigured_state: Option<String>,
rojig_override_version: Option<String>,
#[allow(dead_code)]
rojig_description: Option<String>,

packages: BTreeSet<String>,
packages_local: BTreeMap<String, String>,
Expand Down Expand Up @@ -135,14 +130,13 @@ impl Origin {

fn new_parse(kf: &KeyFile) -> Result<Box<Self>> {
let kf = keyfile_dup(kf);
let rojig = keyfile_get_optional_string(&kf, "origin", "rojig")?;
let refspec_str = if let Some(r) = keyfile_get_optional_string(&kf, "origin", "refspec")? {
Some(r)
} else {
keyfile_get_optional_string(&kf, "origin", "baserefspec")?
};
let refspec = match (refspec_str, rojig) {
(Some(refspec), None) => {
let refspec = match refspec_str {
Some(refspec) => {
if ostree::validate_checksum_string(&refspec).is_ok() {
Refspec {
kind: RefspecType::Checksum,
Expand All @@ -155,12 +149,7 @@ impl Origin {
}
}
},
(None, Some(rojig)) => Refspec {
kind: RefspecType::Rojig,
value: rojig
},
(None, None) => bail!("No origin/refspec, origin/rojig, or origin/baserefspec in current deployment origin; cannot handle via rpm-ostree"),
(Some(_), Some(_)) => bail!("Duplicate origin/refspec and origin/rojig in deployment origin"),
None => bail!("No origin/refspec, or origin/baserefspec in current deployment origin; cannot handle via rpm-ostree"),
};
let override_commit = keyfile_get_optional_string(&kf, "origin", "override-commit")?;
let unconfigured_state = keyfile_get_optional_string(&kf, "origin", "unconfigured-state")?;
Expand All @@ -176,17 +165,12 @@ impl Origin {
r
})
.unwrap_or_default();
let rojig_override_version =
keyfile_get_optional_string(&kf, ORIGIN, "rojig-override-version")?;
let rojig_description = keyfile_get_optional_string(&kf, ORIGIN, "rojig-description")?;
Ok(Box::new(Self {
kf,
cache: Cache {
refspec: refspec,
override_commit,
unconfigured_state,
rojig_override_version,
rojig_description,
packages,
packages_local,
override_remove,
Expand Down Expand Up @@ -233,30 +217,12 @@ impl Origin {
}
}

pub(crate) fn set_rojig_version(&mut self, version: Option<&str>) {
match version {
Some(version) => {
self.kf
.set_string(ORIGIN, "rojig-override-version", version);
self.cache.rojig_override_version = Some(version.to_string());
}
None => {
let _ = self.kf.remove_key(ORIGIN, "rojig-override-version");
self.cache.rojig_override_version = None;
}
}
}

pub(crate) fn get_refspec_type(&self) -> RefspecType {
self.cache.refspec.kind
}

pub(crate) fn get_prefixed_refspec(&self) -> String {
let val = self.cache.refspec.value.as_str();
match self.cache.refspec.kind {
RefspecType::Rojig => format!("{}{}", ROJIG_PREFIX, val),
_ => val.to_string(),
}
self.cache.refspec.value.as_str().to_string()
}

pub(crate) fn get_custom_url(&self) -> Result<String> {
Expand All @@ -275,15 +241,6 @@ impl Origin {
)
}

pub(crate) fn get_rojig_description(&self) -> String {
// FIXME(cxx-rs) propagate Option once supported
self.cache
.rojig_description
.as_ref()
.map(String::from)
.unwrap_or_default()
}

pub(crate) fn get_regenerate_initramfs(&self) -> bool {
match map_keyfile_optional(self.kf.get_boolean("rpmostree", "regenerate-initramfs")) {
Ok(Some(v)) => v,
Expand All @@ -309,10 +266,6 @@ impl Origin {
|| !self.cache.override_remove.is_empty()
}

pub(crate) fn is_rojig(&self) -> bool {
self.cache.refspec.kind == RefspecType::Rojig
}

// Binding for cxx
pub(crate) fn get_override_local_pkgs(&self) -> Vec<String> {
let mut r = Vec::new();
Expand Down Expand Up @@ -344,8 +297,6 @@ refspec=foo:bar/x86_64/baz
assert!(!o.may_require_local_assembly());
assert!(!o.get_regenerate_initramfs());
assert!(o.get_initramfs_etc_files().is_empty());
assert!(!o.is_rojig());
assert_eq!(o.get_rojig_description(), "");
assert_eq!(o.get_custom_url()?, "");
assert_eq!(o.get_custom_description()?, "");
assert!(o.get_override_local_pkgs().is_empty());
Expand All @@ -354,7 +305,6 @@ refspec=foo:bar/x86_64/baz
let mut o = o.duplicate();
assert_eq!(o.get_refspec_type(), RefspecType::Ostree);
o.remove_transient_state();
o.set_rojig_version(Some("42"));

let mut o = Origin::new_from_str(indoc! {"
[origin]
Expand Down
78 changes: 1 addition & 77 deletions rust/src/treefile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ pub struct Treefile {
primary_dfd: openat::Dir,
#[allow(dead_code)] // Not used in tests
pub(crate) parsed: TreeComposeConfig,
// This is a copy of rojig.name to avoid needing to convert to CStr when reading
rojig_name: Option<String>,
rojig_spec: Option<String>,
serialized: CUtf8Buf,
pub(crate) externals: TreefileExternals,
}
Expand Down Expand Up @@ -484,20 +481,11 @@ impl Treefile {
parsed.config = parsed.config.substitute_vars()?;
Treefile::validate_config(&parsed.config)?;
let dfd = openat::Dir::open(utils::parent_dir(filename).unwrap())?;
let (rojig_name, rojig_spec) = match (workdir.as_ref(), parsed.config.rojig.as_ref()) {
(Some(workdir), Some(rojig)) => (
Some(rojig.name.clone()),
Some(Treefile::write_rojig_spec(workdir, rojig)?),
),
_ => (None, None),
};
let serialized = Treefile::serialize_json_string(&parsed.config)?;
Ok(Box::new(Treefile {
primary_dfd: dfd,
parsed: parsed.config,
_workdir: workdir,
rojig_name,
rojig_spec,
serialized,
externals: parsed.externals,
}))
Expand Down Expand Up @@ -590,14 +578,6 @@ impl Treefile {
self.parsed.treeref.as_deref().unwrap_or_default()
}

pub(crate) fn get_rojig_spec_path(&self) -> String {
self.rojig_spec.clone().unwrap_or_default()
}

pub(crate) fn get_rojig_name(&self) -> String {
self.rojig_name.clone().unwrap_or_default()
}

pub(crate) fn get_cliwrap(&self) -> bool {
self.parsed.cliwrap.unwrap_or(false)
}
Expand Down Expand Up @@ -752,59 +732,6 @@ impl Treefile {
Ok(hasher.get_string().expect("hash"))
}

/// Generate a rojig spec file.
fn write_rojig_spec(workdir: &openat::Dir, r: &Rojig) -> CxxResult<String> {
let description = r
.description
.as_ref()
.and_then(|v| {
if !v.is_empty() {
Some(v.as_str())
} else {
None
}
})
.unwrap_or_else(|| r.summary.as_str());
let name: String = format!("{}.spec", r.name);
{
let mut f = workdir.write_file(name.as_str(), 0o644)?;
write!(
f,
r###"
# The canonical version of this is maintained by rpm-ostree.
# Suppress most build root processing we are just carrying
# binary data.
%global __os_install_post /usr/lib/rpm/brp-compress %{{nil}}
Name: {rpmostree_rojig_name}
Version: %{{ostree_version}}
Release: 1%{{?dist}}
Summary: {rpmostree_rojig_summary}
License: {rpmostree_rojig_license}
#@@@rpmostree_rojig_meta@@@
%description
{rpmostree_rojig_description}
%prep
%build
%install
mkdir -p %{{buildroot}}%{{_prefix}}/lib/ostree-jigdo/%{{name}}
for x in *; do mv ${{x}} %{{buildroot}}%{{_prefix}}/lib/ostree-jigdo/%{{name}}; done
%files
%{{_prefix}}/lib/ostree-jigdo/%{{name}}
"###,
rpmostree_rojig_name = r.name,
rpmostree_rojig_summary = r.summary,
rpmostree_rojig_license = r.license,
rpmostree_rojig_description = description,
)?;
}
Ok(name)
}

/// Perform sanity checks on externally provided input, such
/// as the executability of `postprocess-script`.
pub(crate) fn sanitycheck_externals(&self) -> Result<()> {
Expand Down Expand Up @@ -1568,7 +1495,6 @@ pub(crate) mod tests {
let workdir = tempfile::tempdir().unwrap();
let tf = new_test_treefile(workdir.path(), VALID_PRELUDE, None).unwrap();
assert!(tf.parsed.rojig.is_none());
assert!(tf.rojig_spec.is_none());
assert!(tf.parsed.machineid_compat.is_none());
}

Expand All @@ -1579,6 +1505,7 @@ pub(crate) mod tests {
summary: "ExampleOS rojig base image"
"#};

// We need to support rojig: for a long time because it's used by fedora-coreos-config/coreos-assembler at least.
#[test]
fn test_treefile_new_rojig() {
let workdir = tempfile::tempdir().unwrap();
Expand All @@ -1587,9 +1514,6 @@ pub(crate) mod tests {
let tf = new_test_treefile(workdir.path(), buf.as_str(), None).unwrap();
let rojig = tf.parsed.rojig.as_ref().unwrap();
assert!(rojig.name == "exampleos");
let rojig_spec_str = tf.rojig_spec.as_ref().unwrap().as_str();
let rojig_spec = Path::new(rojig_spec_str);
assert!(rojig_spec.file_name().unwrap() == "exampleos.spec");
}

#[test]
Expand Down
4 changes: 1 addition & 3 deletions src/app/rpmostree-builtin-rebase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,8 @@ rpmostree_builtin_rebase (int argc,
RpmOstreeRefspecType refspectype;
if (!rpmostree_refspec_classify (new_provided_refspec, &refspectype, &remainder, error))
return FALSE;
if (!opt_experimental && refspectype == RPMOSTREE_REFSPEC_TYPE_ROJIG)
return glnx_throw (error, "rojig:// refspec requires --experimental");

/* catch "ostree://" or "rojig://"; we'd error out much later in the daemon otherwise */
/* catch "ostree://"; we'd error out much later in the daemon otherwise */
if (strlen (remainder) == 0)
return glnx_throw (error, "Refspec is empty");

Expand Down
2 changes: 0 additions & 2 deletions src/app/rpmostree-builtin-status.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,6 @@ print_one_deployment (RPMOSTreeSysroot *sysroot_proxy,
g_print ("%s", canonrefspec);
}
break;
case RPMOSTREE_REFSPEC_TYPE_ROJIG:
g_assert_not_reached ();
}
}
else
Expand Down
8 changes: 2 additions & 6 deletions src/app/rpmostree-compose-builtin-tree.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ typedef struct {
OstreeRepo *pkgcache_repo; /* unified mode: pkgcache repo where we import pkgs */
OstreeRepoDevInoCache *devino_cache;
const char *ref;
char *rojig_spec;
char *previous_checksum;

std::optional<rust::Box<rpmostreecxx::Treefile>> treefile_rs;
Expand Down Expand Up @@ -295,8 +294,7 @@ install_packages (RpmOstreeTreeComposeContext *self,
}

/* By default, retain packages in addition to metadata with --cachedir, unless
* we're doing unified core, in which case the pkgcache repo is the cache. But
* the rojigSet build still requires the original RPMs too.
* we're doing unified core, in which case the pkgcache repo is the cache.
*/
if (opt_cachedir && !opt_unified_core)
dnf_context_set_keep_cache (dnfctx, TRUE);
Expand Down Expand Up @@ -448,9 +446,7 @@ install_packages (RpmOstreeTreeComposeContext *self,
return FALSE;

/* Now reload the policy from the tmproot, and relabel the pkgcache - this
* is the same thing done in rpmostree_context_commit(). But here we want
* to ensure our pkgcache labels are accurate, since that will
* be important for the ostree-rojig work.
* is the same thing done in rpmostree_context_commit().
*/
g_autoptr(OstreeSePolicy) sepolicy = ostree_sepolicy_new_at (rootfs_dfd, cancellable, error);
if (sepolicy == NULL)
Expand Down
Loading

0 comments on commit f3ccb97

Please sign in to comment.