diff --git a/cloud-build.py b/cloud-build.py index 7765cd4..12492a9 100755 --- a/cloud-build.py +++ b/cloud-build.py @@ -301,9 +301,18 @@ Dir::Etc::preferencesparts "/var/empty"; def scripts_by_image(self, image: str) -> Dict[str, str]: scripts = {} - for name, contents in self._scripts.items(): - if name in self._images[image]['scripts']: - scripts[name] = contents + for name, value in self._scripts.items(): + number = value.get('number') + if ( + value.get('global', False) + and name not in self._images[image].get('no_scripts', []) + or name in self._images[image].get('scripts', []) + ): + if number is not None: + if isinstance(number, int): + number = f'{number:02}' + name = f'{number}-{name}' + scripts[name] = value['contents'] return scripts def skip_arch(self, image: str, arch: str) -> bool: diff --git a/example-config.yaml b/example-config.yaml index f4e017c..e5807aa 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -28,13 +28,14 @@ images: target: ve/docker kinds: - tar.xz + no_scripts: + - var rootfs-systemd: target: ve/systemd-base kinds: - tar.xz scripts: - securetty - - var branches: Sisyphus: @@ -67,17 +68,23 @@ branches: # - p8 scripts: - securetty: | - #!/bin/sh + securetty: + contents: | + #!/bin/sh - echo pts/0 >> /etc/securetty - var: | - #!/bin/sh + echo pts/0 >> /etc/securetty + global: no + number: 1 + var: + contents: | + #!/bin/sh - for dir in run lock; do - mkdir -p "/$dir" - mv /var/"$dir"/* "/$dir" - rmdir "/var/$dir" - ln -sf "/$dir" /var - done + for dir in run lock; do + mkdir -p "/$dir" + mv /var/"$dir"/* "/$dir" + rmdir "/var/$dir" + ln -sf "/$dir" /var + done + global: yes + number: 27 ...