yield Path(f.name)
+def check_script(config: Config, script: Path) -> None:
+ if not os.access(script, os.X_OK):
+ if config.make_scripts_executable:
+ logging.warning(f"{script} is not executable, attempting to chmod it")
+ os.chmod(script, os.stat(script).st_mode | stat.S_IXUSR)
+ else:
+ die(f"{script} is not executable")
+
+
def run_configure_scripts(config: Config) -> Config:
if not config.configure_scripts:
return config
for script in config.configure_scripts:
- if not os.access(script, os.X_OK):
- die(f"{script} is not executable")
+ check_script(config, script)
env = dict(
DISTRIBUTION=str(config.distribution),
return
for script in config.sync_scripts:
- if not os.access(script, os.X_OK):
- die(f"{script} is not executable")
+ check_script(config, script)
env = dict(
DISTRIBUTION=str(config.distribution),
config.finalize_scripts,
config.postoutput_scripts,
):
- if not os.access(script, os.X_OK):
- die(f"{script} is not executable")
+ check_script(config, script)
if config.secure_boot and not config.secure_boot_key:
die(
return
for script in config.clean_scripts:
- if not os.access(script, os.X_OK):
- die(f"{script} is not executable")
+ check_script(config, script)
env = dict(
DISTRIBUTION=str(config.distribution),
proxy_peer_certificate: Optional[Path]
proxy_client_certificate: Optional[Path]
proxy_client_key: Optional[Path]
+ make_scripts_executable: bool
nspawn_settings: Optional[Path]
ephemeral: bool
help="Set the proxy client key",
scope=SettingScope.multiversal,
),
+ ConfigSetting(
+ dest="make_scripts_executable",
+ metavar="BOOL",
+ section="Build",
+ parse=config_parse_boolean,
+ default=False,
+ help="Whether mkosi will try to make build/postinst/finalize scripts executable if they are not",
+ ),
# Runtime section
ConfigSetting(
dest="nspawn_settings",
Proxy Client Certificate: {none_to_none(config.proxy_client_certificate)}
Proxy Client Key: {none_to_none(config.proxy_client_key)}
+ Automatically set +x on scripts: {yes_no(config.make_scripts_executable)}
+
{bold("HOST CONFIGURATION")}:
NSpawn Settings: {none_to_none(config.nspawn_settings)}
Ephemeral: {config.ephemeral}
Currently, setting a proxy client key is only supported when **dnf** or
**dnf5** is used to build the image.
+`MakeScriptsExecutable=`, `--make-scripts-executable=`
+: If one of the hook scripts (see `SCRIPTS` section) is not marked as executable, attempt to chmod it
+ instead of failing outright. Defaults to `no`.
+
### [Runtime] Section (previously known as the [Host] section)
`NSpawnSettings=`, `--settings=`
"Machine": "machine",
"MachineId": "b58253b0-cc92-4a34-8782-bcd99b20d07f",
"MakeInitrd": false,
+ "MakeScriptsExecutable": false,
"ManifestFormat": [
"json",
"changelog"
locale="en_C.UTF-8",
machine_id=uuid.UUID("b58253b0cc924a348782bcd99b20d07f"),
machine="machine",
+ make_scripts_executable=False,
make_initrd=False,
manifest_format=[ManifestFormat.json, ManifestFormat.changelog],
maxmem=123,