-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jovian-support-scripts: Init with format scripts
The support scripts are intended to replace vendor scripts for the little details we can't do the same way. We're adding the pair of scripts required to format external devices. Note that the scripts end-up relying on the steamos-manager service, which in turn already knows how to launch the hw-support scripts. How convenient.
- Loading branch information
Showing
4 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ stdenv | ||
, resholve | ||
|
||
, bash | ||
, jq | ||
, systemd | ||
, util-linux | ||
}: | ||
|
||
let | ||
solution = { | ||
scripts = [ "bin/steamos-polkit-helpers/*" ]; | ||
interpreter = "${bash}/bin/bash"; | ||
inputs = [ | ||
# coreutils | ||
# dmidecode | ||
# gawk | ||
# gnugrep | ||
# "${jupiter-dock-updater-bin}/lib/jupiter-dock-updater" | ||
# jovian-stubs | ||
# jupiter-hw-support | ||
# "${jupiter-hw-support}/lib/hwsupport" | ||
jq | ||
# steamdeck-firmware | ||
systemd | ||
util-linux | ||
# wirelesstools | ||
# | ||
# #"${placeholder "out"}/bin/steamos-polkit-helpers" | ||
]; | ||
execer = [ | ||
# "cannot:${jovian-stubs}/bin/jupiter-biosupdate" | ||
# "cannot:${jovian-stubs}/bin/steamos-reboot" | ||
# "cannot:${jovian-stubs}/bin/steamos-factory-reset-config" | ||
# "cannot:${jovian-stubs}/bin/steamos-select-branch" | ||
# "cannot:${jovian-stubs}/bin/steamos-update" | ||
# "cannot:${jupiter-dock-updater-bin}/lib/jupiter-dock-updater/jupiter-dock-updater.sh" | ||
# "cannot:${jupiter-hw-support}/bin/jupiter-check-support" | ||
# "cannot:${jupiter-hw-support}/lib/hwsupport/format-device.sh" | ||
# "cannot:${jupiter-hw-support}/lib/hwsupport/format-sdcard.sh" | ||
# "cannot:${jupiter-hw-support}/lib/hwsupport/trim-devices.sh" | ||
# "cannot:${steamdeck-firmware}/bin/jupiter-biosupdate" | ||
# "cannot:${systemd}/bin/poweroff" | ||
# "cannot:${systemd}/bin/reboot" | ||
# "cannot:${systemd}/bin/systemctl" | ||
# "cannot:${systemd}/bin/systemd-cat" | ||
]; | ||
fake = { | ||
external = ["pkexec"]; | ||
}; | ||
fix = { | ||
"/usr/bin/jupiter-biosupdate" = true; | ||
"/usr/bin/jupiter-check-support" = true; | ||
"/usr/bin/steamos-factory-reset-config" = true; | ||
"/usr/bin/steamos-reboot" = true; | ||
"/usr/bin/steamos-select-branch" = true; | ||
"/usr/bin/steamos-update" = true; | ||
"/usr/lib/hwsupport/format-device.sh" = true; | ||
"/usr/lib/hwsupport/format-sdcard.sh" = true; | ||
"/usr/lib/hwsupport/trim-devices.sh" = true; | ||
"/usr/lib/jupiter-dock-updater/jupiter-dock-updater.sh" = true; | ||
#"${placeholder "out"}/bin/steamos-polkit-helpers/steamos-format-device" = true; | ||
}; | ||
keep = { | ||
# this file is removed in latest versions of hwsupport | ||
"/usr/lib/hwsupport/jupiter-amp-control" = true; | ||
"${placeholder "out"}/bin/steamos-polkit-helpers/steamos-format-device" = true; | ||
}; | ||
}; | ||
in | ||
stdenv.mkDerivation { | ||
name = "jovian-support-scripts"; | ||
|
||
buildCommand = '' | ||
install -D -m 755 ${./steamos-format-sdcard} $out/bin/steamos-format-sdcard | ||
install -D -m 755 ${./steamos-format-device} $out/bin/steamos-format-device | ||
substituteInPlace $out/bin/steamos-format-sdcard \ | ||
--replace-fail "/usr/bin/steamos-polkit-helpers/steamos-format-device" "$out/bin/steamos-polkit-helpers/steamos-format-device" | ||
( | ||
cd $out/bin | ||
mkdir -v steamos-polkit-helpers | ||
cd steamos-polkit-helpers | ||
ln -v -t . ../steamos-format-* | ||
) | ||
${resholve.phraseSolution "steamos-format-sdcard" solution} | ||
${resholve.phraseSolution "steamos-format-device" solution} | ||
''; | ||
|
||
meta = { | ||
# Any script defined here should be prioritized over Steam's own. | ||
priority = -10; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
# [Jovian] | ||
# | ||
# Not a polkit helper anymore, this calls the steamos-manager system service | ||
# to poke through the fhsenv used here. | ||
# | ||
# Note that this is uh... quite a hack, but uh... works? | ||
# | ||
# The TLDR is: | ||
# | ||
# - We poke the steamos-manager to run the dbus endpoint for formatting | ||
# - We `tail` the journal for the output from the script | ||
# | ||
# And uh, this fulfills the requirements for Steam (stage=... flags). | ||
# | ||
|
||
cleanup() { | ||
>/dev/null 2>&1 \ | ||
kill -9 % || : | ||
} | ||
|
||
trap cleanup EXIT SIGINT SIGTERM | ||
|
||
_call() { | ||
object="$1"; shift | ||
interface="$1"; shift | ||
busctl --timeout=99y --expect-reply=yes -j \ | ||
call \ | ||
com.steampowered.SteamOSManager1 \ | ||
"$object" \ | ||
com.steampowered.SteamOSManager1."${interface}" \ | ||
"$@" \ | ||
| jq -r .data[0] | ||
} | ||
|
||
# Only supported flags, from the DBUS interface shape (ssb) | ||
# • --skip-validation|--force) | ||
# • --device) | ||
# • --label) | ||
|
||
DEVICE="" | ||
LABEL="STEAM-$RANDOM" | ||
VALIDATE="true" | ||
|
||
OPTS=$(getopt -l force,skip-validation,device:,label: -n steamos-format-device -- "" "$@") | ||
|
||
eval set -- "$OPTS" | ||
|
||
while true; do | ||
case "$1" in | ||
--force) | ||
# yes, this is just like --skip-validate in the vendor script | ||
VALIDATE="false" | ||
shift | ||
;; | ||
--skip-validation) | ||
# yes, this is just like --force in the vendor script | ||
VALIDATE="false" | ||
shift | ||
;; | ||
--label) | ||
LABEL="$2"; | ||
shift 2 | ||
;; | ||
--device) | ||
DEVICE="$2" | ||
shift 2 | ||
;; | ||
--) shift; break ;; | ||
esac | ||
done | ||
|
||
if [[ "$DEVICE" == "" ]]; then | ||
>&2 printf "Error: --device flag mandatory\n" | ||
exit 1 | ||
fi | ||
|
||
journalctl --lines=0 --follow \ | ||
--output cat \ | ||
--unit steamos-manager.service \ | ||
SYSLOG_IDENTIFIER=steamos-format-device & | ||
|
||
process=$(_call "/com/steampowered/SteamOSManager1" Manager FormatDevice ssb "$DEVICE" "$LABEL" "$VALIDATE") | ||
res="$(_call "${process}" "SubProcess" Wait)" | ||
|
||
exit "$res" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
# [Jovian] | ||
# Not a polkit helper anymore, this calls the `format-device` helper following | ||
# the same semantics as `usr/lib/hwsupport/format-sdcard.sh`. | ||
|
||
exec /usr/bin/steamos-polkit-helpers/steamos-format-device \ | ||
--device /dev/mmcblk0 "$@" |