Skip to content

Commit

Permalink
patch module
Browse files Browse the repository at this point in the history
  • Loading branch information
nihil-admirari committed Feb 18, 2025
1 parent 9bac2a6 commit fa686f4
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 26 deletions.
File renamed without changes.
11 changes: 11 additions & 0 deletions files/patches/run0gvfsadmin.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/usr/share/gvfs/mounts/admin.mount
+++ b/usr/share/gvfs/mounts/admin.mount
@@ -1,7 +1,7 @@
[Mount]
Type=admin
# Add a dummy argument after pkexec, or '/bin/sh -c' will eat the first argument in '$@'
-Exec=/bin/sh -c 'pkexec /usr/libexec/gvfsd-admin "$@" --address $DBUS_SESSION_BUS_ADDRESS --dir $XDG_RUNTIME_DIR' gvfsd-admin
+Exec=/bin/sh -c 'run0 --setenv=PKEXEC_UID="$UID" /usr/libexec/gvfsd-admin "$@" --address $DBUS_SESSION_BUS_ADDRESS --dir $XDG_RUNTIME_DIR' gvfsd-admin
AutoMount=false
DBusName=org.gtk.vfs.mountpoint_admin
MountPerClient=true
10 changes: 0 additions & 10 deletions files/scripts/patchcommonconf.sh

This file was deleted.

15 changes: 0 additions & 15 deletions files/scripts/patchconf.sh

This file was deleted.

6 changes: 6 additions & 0 deletions modules/patch/module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: patch
shortdesc: This module is used to apply patches to files at image build image.
example: |
type: patch
patches:
- hardenlogindefs.patch
17 changes: 17 additions & 0 deletions modules/patch/patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -euo pipefail
shopt -s nullglob

get_json_array PATCHES 'try .["patches"][]' "$1"
PATCH_DIR="$CONFIG_DIRECTORY/patches"
readonly PATCHES PATCH_DIR

main() {
local p
for p in "${PATCHES[@]}"; do
patch --forward --directory=/ --strip=1 --no-backup-if-mismatch < "$PATCH_DIR/$p"
done
}

main "$@"
19 changes: 19 additions & 0 deletions modules/patch/patch.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import "@typespec/json-schema";
using TypeSpec.JsonSchema;

@jsonSchema("/modules/script-latest.json")
model ScriptModuleLatest {
...ScriptModuleV1;
}

@jsonSchema("/modules/script-v1.json")
model ScriptModuleV1 {
/** The patch module can be used to to apply patches to files at image build image. */
type: "patch" | "patch@v1" | "patch@latest";

/**
* List of patches to apply. Each patch has path components till the first / stripped
* and is then applied relative to image's root.
*/
patches: Array<string>;
}
4 changes: 4 additions & 0 deletions recipes/common/common-modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ modules:
- type: script
scripts:
- enablecommonautoupdate.sh
- type: patch
patches:
- hardenlogindefs.patch
- run0gvfsadmin.patch
- type: secureblue-signing
source: local
1 change: 0 additions & 1 deletion recipes/common/common-scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ scripts:
- disablegeoclue.sh
- enablesecurebluefirstrun.sh
- createjustcompletions.sh
- patchcommonconf.sh

0 comments on commit fa686f4

Please sign in to comment.