uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead

https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948
this can do it nicely.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
Anton Arapov 2021-04-03 12:58:10 +02:00 committed by Alan Daniels
commit 56de2bcd43
30691 changed files with 3076956 additions and 0 deletions

View file

@ -0,0 +1,140 @@
{ stdenv
, lib
, buildEnv
, substituteAll
, runCommand
, coreutils
, dwarf-fortress
, dwarf-therapist
, enableDFHack ? false
, dfhack
, enableSoundSense ? false
, soundSense
, jdk
, enableStoneSense ? false
, enableTWBT ? false
, twbt
, themes ? { }
, theme ? null
# General config options:
, enableIntro ? true
, enableTruetype ? true
, enableFPS ? false
, enableTextMode ? false
, enableSound ? true
}:
let
dfhack_ = dfhack.override {
inherit enableStoneSense;
inherit enableTWBT;
};
ptheme =
if builtins.isString theme
then builtins.getAttr theme themes
else theme;
unBool = b: if b then "YES" else "NO";
# These are in inverse order for first packages to override the next ones.
themePkg = lib.optional (theme != null) ptheme;
pkgs = lib.optional enableDFHack dfhack_
++ lib.optional enableSoundSense soundSense
++ lib.optional enableTWBT twbt.art
++ [ dwarf-fortress ];
fixup = lib.singleton (runCommand "fixup" { } (''
mkdir -p $out/data/init
'' + (if (theme != null) then ''
cp ${lib.head themePkg}/data/init/init.txt $out/data/init/init.txt
'' else ''
cp ${dwarf-fortress}/data/init/init.txt $out/data/init/init.txt
'') + lib.optionalString enableDFHack ''
mkdir -p $out/hack
# Patch the MD5
orig_md5=$(cat "${dwarf-fortress}/hash.md5.orig")
patched_md5=$(cat "${dwarf-fortress}/hash.md5")
input_file="${dfhack_}/hack/symbols.xml"
output_file="$out/hack/symbols.xml"
echo "[DFHack Wrapper] Fixing Dwarf Fortress MD5:"
echo " Input: $input_file"
echo " Search: $orig_md5"
echo " Output: $output_file"
echo " Replace: $patched_md5"
substitute "$input_file" "$output_file" --replace "$orig_md5" "$patched_md5"
'' + lib.optionalString enableTWBT ''
substituteInPlace $out/data/init/init.txt \
--replace '[PRINT_MODE:2D]' '[PRINT_MODE:TWBT]'
'' +
lib.optionalString enableTextMode ''
substituteInPlace $out/data/init/init.txt \
--replace '[PRINT_MODE:2D]' '[PRINT_MODE:TEXT]'
'' + ''
substituteInPlace $out/data/init/init.txt \
--replace '[INTRO:YES]' '[INTRO:${unBool enableIntro}]' \
--replace '[TRUETYPE:YES]' '[TRUETYPE:${unBool enableTruetype}]' \
--replace '[FPS:NO]' '[FPS:${unBool enableFPS}]' \
--replace '[SOUND:YES]' '[SOUND:${unBool enableSound}]'
''));
env = buildEnv {
name = "dwarf-fortress-env-${dwarf-fortress.dfVersion}";
paths = fixup ++ themePkg ++ pkgs;
pathsToLink = [ "/" "/hack" "/hack/scripts" ];
ignoreCollisions = true;
};
in
stdenv.mkDerivation {
pname = "dwarf-fortress";
version = dwarf-fortress.dfVersion;
dfInit = substituteAll {
name = "dwarf-fortress-init";
src = ./dwarf-fortress-init.in;
inherit env;
exe =
if stdenv.isLinux then "libs/Dwarf_Fortress"
else "dwarfort.exe";
stdenv_shell = "${stdenv.shell}";
cp = "${coreutils}/bin/cp";
rm = "${coreutils}/bin/rm";
ln = "${coreutils}/bin/ln";
cat = "${coreutils}/bin/cat";
mkdir = "${coreutils}/bin/mkdir";
};
runDF = ./dwarf-fortress.in;
runDFHack = ./dfhack.in;
runSoundSense = ./soundSense.in;
passthru = { inherit dwarf-fortress dwarf-therapist; };
buildCommand = ''
mkdir -p $out/bin
substitute $runDF $out/bin/dwarf-fortress \
--subst-var-by stdenv_shell ${stdenv.shell} \
--subst-var dfInit
chmod 755 $out/bin/dwarf-fortress
'' + lib.optionalString enableDFHack ''
substitute $runDFHack $out/bin/dfhack \
--subst-var-by stdenv_shell ${stdenv.shell} \
--subst-var dfInit
chmod 755 $out/bin/dfhack
'' + lib.optionalString enableSoundSense ''
substitute $runSoundSense $out/bin/soundsense \
--subst-var-by stdenv_shell ${stdenv.shell} \
--subst-var-by jre ${jdk.jre} \
--subst-var dfInit
chmod 755 $out/bin/soundsense
'';
preferLocalBuild = true;
}

View file

@ -0,0 +1,11 @@
#!@stdenv_shell@ -e
source @dfInit@
for i in dfhack.init-example dfhack-config/default hack/* stonesense/*; do
update_path "$i"
done
cd "$DF_DIR"
LD_LIBRARY_PATH="$env_dir/hack/libs:$env_dir/hack${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" \
LD_PRELOAD="$env_dir/hack/libdfhack.so:$LD_PRELOAD" exec $env_dir/libs/Dwarf_Fortress "$@"

View file

@ -0,0 +1,45 @@
#!@stdenv_shell@ -e
shopt -s extglob
[ -z "$DF_DIR" ] && export DF_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/df_linux"
env_dir="@env@"
exe="$env_dir/@exe@"
update_path() {
local path="$1"
@mkdir@ -p "$DF_DIR/$(dirname "$path")"
# If user has replaced these data directories, let them stay.
if [ ! -e "$DF_DIR/$path" ] || [ -L "$DF_DIR/$path" ]; then
@rm@ -f "$DF_DIR/$path"
@ln@ -s "$env_dir/$path" "$DF_DIR/$path"
fi
}
forcecopy_path() {
local path="$1"
@mkdir@ -p "$DF_DIR/$(dirname "$path")"
@rm@ -rf "$DF_DIR/$path"
@cp@ -rL --no-preserve=all "$env_dir/$path" "$DF_DIR/$path"
}
@mkdir@ -p "$DF_DIR"
@cat@ <<EOF >&2
Using $DF_DIR as Dwarf Fortress overlay directory.
If you do any changes in it, don't forget to clean it when updating the game version!
We try to detect changes based on data directories being symbolic links -- keep this in mind.
EOF
cd "$env_dir"
for i in data/init/* data/!(init|index|announcement) raw; do
update_path "$i"
done
forcecopy_path data/index
# For some reason, it's needed to be writable...
forcecopy_path data/announcement
forcecopy_path data/help
forcecopy_path data/dipscript

View file

@ -0,0 +1,9 @@
#!@stdenv_shell@ -e
source @dfInit@
export DYLD_LIBRARY_PATH="$env_dir/libs"
export DYLD_FRAMEWORK_PATH="$env_dir/libs"
cd "$DF_DIR"
exec "$exe" "$@"

View file

@ -0,0 +1,10 @@
#!@stdenv_shell@ -e
source @dfInit@
for p in soundsense/*; do
update_path "$p"
done
cd "$DF_DIR"
PATH=@jre@/bin exec $DF_DIR/soundsense/soundSense.sh