Fix recipe and templates

This commit is contained in:
Gerald Pinder 2023-10-06 23:59:10 -04:00
parent c415f6a90a
commit 8668a7a442
2 changed files with 29 additions and 17 deletions

View file

@ -10,47 +10,53 @@ pub struct Recipe {
#[serde(alias = "fedora-version")]
pub fedora_version: u16,
pub scripts: Scripts,
pub scripts: Option<Scripts>,
pub rpm: Rpm,
pub rpm: Option<Rpm>,
#[serde(alias = "usr-dir-overlays")]
pub usr_dir_overlays: Option<Vec<String>>,
pub containerfiles: Option<Containerfiles>,
pub firstboot: FirstBoot,
pub firstboot: Option<FirstBoot>,
}
impl Recipe {
pub fn process_repos(mut self) -> Self {
self.rpm.repos = self
.rpm
.repos
.iter()
.map(|s| s.replace("%FEDORA_VERSION%", self.fedora_version.to_string().as_str()))
.collect();
if let Some(rpm) = &mut self.rpm {
if let Some(repos) = &rpm.repos {
rpm.repos = Some(
repos
.iter()
.map(|s| {
s.replace("%FEDORA_VERSION%", self.fedora_version.to_string().as_str())
})
.collect(),
);
}
}
self
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Scripts {
pub pre: Vec<String>,
pub post: Vec<String>,
pub pre: Option<Vec<String>>,
pub post: Option<Vec<String>>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Rpm {
pub repos: Vec<String>,
pub install: Vec<String>,
pub remove: Vec<String>,
pub repos: Option<Vec<String>>,
pub install: Option<Vec<String>>,
pub remove: Option<Vec<String>>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct FirstBoot {
pub yafti: bool,
pub flatpaks: Vec<String>,
pub flatpaks: Option<Vec<String>>,
}
#[derive(Debug, Serialize, Deserialize)]

View file

@ -34,15 +34,19 @@ RUN find /tmp/scripts -type f -exec chmod +x {} \;
{{ print_autorun_scripts(mode = "pre") }}
{% if scripts and scripts.pre %}
{% for script in scripts.pre %}
RUN /bin/bash -c '/tmp/scripts/{{ script }} pre'
{% endfor %}
{% endif %}
{% if rpm and rpm.repos %}
{% for repo in rpm.repos %}
RUN wget "{{ repo }}" -P "/etc/yum.repos.d/"
{% endfor %}
{% endif %}
{% if rpm.remove %}
{% if rpm and rpm.remove %}
RUN rpm-ostree override remove {% for app in rpm.remove %}{{ app }} {% endfor %}
{% endif %}
@ -68,15 +72,17 @@ RUN echo "-- firstboot: Removing all \"firstboot\" components --"; \
rm -rf "${FIRSTBOOT_DATA}"
{% endif %}
{% if rpm.install %}
{% if rpm and rpm.install %}
RUN rpm-ostree install {% for app in rpm.install %}{{ app }} {% endfor %}
{% endif %}
{{ print_autorun_scripts(mode = "post") }}
{% if scripts and scripts.pre %}
{% for script in scripts.post -%}
RUN /bin/bash -c '/tmp/scripts/{{ script }} post'
{% endfor -%}
{% endif %}
{% if containerfiles and containerfiles.post %}
{% for containerfile in containerfiles.post %}