mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-18 19:03:28 +00:00
wine, winetricks: add updateScript
This commit is contained in:
parent
836c2dfde5
commit
729486a667
@ -185,6 +185,7 @@ stdenv.mkDerivation ((lib.optionalAttrs (buildScript != null) {
|
||||
|
||||
passthru = {
|
||||
inherit pkgArches;
|
||||
inherit (src) updateScript;
|
||||
tests = { inherit (nixosTests) wine; };
|
||||
};
|
||||
meta = {
|
||||
|
@ -12,6 +12,15 @@ let fetchurl = args@{url, sha256, ...}:
|
||||
pkgs.fetchFromGitHub { inherit owner repo rev sha256; } // args;
|
||||
fetchFromGitLab = args@{domain, owner, repo, rev, sha256, ...}:
|
||||
pkgs.fetchFromGitLab { inherit domain owner repo rev sha256; } // args;
|
||||
|
||||
updateScriptPreamble = ''
|
||||
set -eou pipefail
|
||||
PATH=${with pkgs; lib.makeBinPath [ common-updater-scripts coreutils curl gnugrep gnused jq nix ]}
|
||||
sources_file=${__curPos.file}
|
||||
source ${./update-lib.sh}
|
||||
'';
|
||||
|
||||
inherit (pkgs) writeShellScript;
|
||||
in rec {
|
||||
|
||||
stable = fetchurl rec {
|
||||
@ -42,6 +51,24 @@ in rec {
|
||||
# Also look for root certificates at $NIX_SSL_CERT_FILE
|
||||
./cert-path.patch
|
||||
];
|
||||
|
||||
updateScript = writeShellScript "update-wine-stable" (''
|
||||
${updateScriptPreamble}
|
||||
major=''${UPDATE_NIX_OLD_VERSION%.*}
|
||||
latest_stable=$(get_latest_wine_version "$major.0")
|
||||
latest_gecko=$(get_latest_lib_version wine-gecko)
|
||||
|
||||
# Can't use autobump on stable because we don't want the path
|
||||
# <source/7.0/wine-7.0.tar.xz> to become <source/7.0.1/wine-7.0.1.tar.xz>.
|
||||
if [[ "$UPDATE_NIX_OLD_VERSION" != "$latest_stable" ]]; then
|
||||
set_version_and_sha256 stable "$latest_stable" "$(nix-prefetch-url "$wine_url_base/source/$major.0/wine-$latest_stable.tar.xz")"
|
||||
fi
|
||||
|
||||
autobump stable.gecko32 "$latest_gecko"
|
||||
autobump stable.gecko64 "$latest_gecko"
|
||||
|
||||
do_update
|
||||
'');
|
||||
};
|
||||
|
||||
unstable = fetchurl rec {
|
||||
@ -56,6 +83,23 @@ in rec {
|
||||
url = "https://dl.winehq.org/wine/wine-mono/${version}/wine-mono-${version}-x86.msi";
|
||||
sha256 = "sha256-ZBP/Mo679+x2icZI/rNUbYEC3thlB50fvwMxsUs6sOw=";
|
||||
};
|
||||
|
||||
updateScript = writeShellScript "update-wine-unstable" ''
|
||||
${updateScriptPreamble}
|
||||
major=''${UPDATE_NIX_OLD_VERSION%.*}
|
||||
latest_unstable=$(get_latest_wine_version "$major.x")
|
||||
latest_mono=$(get_latest_lib_version wine-mono)
|
||||
|
||||
update_staging() {
|
||||
staging_url=$(get_source_attr staging.url)
|
||||
set_source_attr staging sha256 "\"$(to_sri "$(nix-prefetch-url --unpack "''${staging_url//$1/$2}")")\""
|
||||
}
|
||||
|
||||
autobump unstable "$latest_unstable" "" update_staging
|
||||
autobump unstable.mono "$latest_mono"
|
||||
|
||||
do_update
|
||||
'';
|
||||
};
|
||||
|
||||
staging = fetchFromGitHub rec {
|
||||
@ -81,6 +125,22 @@ in rec {
|
||||
inherit (unstable) gecko32 gecko64;
|
||||
|
||||
inherit (unstable) mono;
|
||||
|
||||
updateScript = writeShellScript "update-wine-wayland" ''
|
||||
${updateScriptPreamble}
|
||||
wayland_rev=$(get_source_attr wayland.rev)
|
||||
|
||||
latest_wayland_rev=$(curl -s 'https://gitlab.collabora.com/api/v4/projects/2847/repository/branches/wayland' | jq -r .commit.id)
|
||||
|
||||
if [[ "$wayland_rev" != "$latest_wayland_rev" ]]; then
|
||||
latest_wayland=$(curl -s 'https://gitlab.collabora.com/alf/wine/-/raw/wayland/VERSION' | cut -f3 -d' ')
|
||||
wayland_url=$(get_source_attr wayland.url)
|
||||
set_version_and_sha256 wayland "$latest_wayland" "$(nix-prefetch-url --unpack "''${wayland_url/$wayland_rev/$latest_wayland_rev}")"
|
||||
set_source_attr wayland rev "\"$latest_wayland_rev\""
|
||||
fi
|
||||
|
||||
do_update
|
||||
'';
|
||||
};
|
||||
|
||||
winetricks = fetchFromGitHub rec {
|
||||
@ -90,5 +150,16 @@ in rec {
|
||||
owner = "Winetricks";
|
||||
repo = "winetricks";
|
||||
rev = version;
|
||||
|
||||
updateScript = writeShellScript "update-winetricks" ''
|
||||
${updateScriptPreamble}
|
||||
winetricks_repourl=$(get_source_attr winetricks.gitRepoUrl)
|
||||
|
||||
latest_winetricks=$(list-git-tags --url="$winetricks_repourl" | grep -E '^[0-9]{8}$' | sort --reverse --numeric-sort | head -n 1)
|
||||
|
||||
autobump winetricks "$latest_winetricks" 'nix-prefetch-url --unpack'
|
||||
|
||||
do_update
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
49
pkgs/applications/emulators/wine/update-lib.sh
Normal file
49
pkgs/applications/emulators/wine/update-lib.sh
Normal file
@ -0,0 +1,49 @@
|
||||
wine_url_base=https://dl.winehq.org/wine
|
||||
|
||||
sed_exprs=()
|
||||
|
||||
get_source_attr() {
|
||||
nix-instantiate --eval --json -E "(let pkgs = import ./. {}; in pkgs.callPackage $sources_file { inherit pkgs; }).$1" | jq -r
|
||||
}
|
||||
|
||||
set_source_attr() {
|
||||
path="$1"
|
||||
name="$2"
|
||||
value="$3"
|
||||
line=$(nix-instantiate --eval -E "(builtins.unsafeGetAttrPos \"$name\" (let pkgs = import ./. {}; in pkgs.callPackage $sources_file { inherit pkgs; }).$path).line")
|
||||
sed_exprs+=(-e "${line}s@[^ ].*\$@$name = $value;@")
|
||||
}
|
||||
|
||||
set_version_and_sha256() {
|
||||
set_source_attr "$1" version "\"$2\""
|
||||
set_source_attr "$1" sha256 "\"$(to_sri "$3")\""
|
||||
}
|
||||
|
||||
get_latest_wine_version() {
|
||||
list-directory-versions --pname=wine --url="$wine_url_base/source/$1" | grep -v 'diff\|rc\|tar' | sort --reverse --version-sort -u | head -n 1
|
||||
}
|
||||
|
||||
get_latest_lib_version() {
|
||||
curl -s "$wine_url_base/$1/" | grep -o 'href="[0-9.]*/"' | sed 's_^href="\(.*\)/"_\1_' | sort --reverse --version-sort -u | head -n 1
|
||||
}
|
||||
|
||||
to_sri() {
|
||||
nix --extra-experimental-features nix-command hash to-sri --type sha256 "$1"
|
||||
}
|
||||
|
||||
autobump() {
|
||||
attr="$1"
|
||||
latest="$2"
|
||||
fetcher="${3:-nix-prefetch-url}"
|
||||
more="${4:-}"
|
||||
version=$(get_source_attr "$attr.version")
|
||||
if [[ "$version" != "$latest" ]]; then
|
||||
url=$(get_source_attr "$attr.url")
|
||||
set_version_and_sha256 "$attr" "$latest" "$($fetcher "${url//$version/$latest}")"
|
||||
[[ -z "$more" ]] || $more "$version" "$latest"
|
||||
fi
|
||||
}
|
||||
|
||||
do_update() {
|
||||
[[ "${#sed_exprs[@]}" -eq 0 ]] || sed -i "${sed_exprs[@]}" "$sources_file"
|
||||
}
|
@ -24,6 +24,10 @@ stdenv.mkDerivation rec {
|
||||
"$out/bin/winetricks"
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit (src) updateScript;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "A script to install DLLs needed to work around problems in Wine";
|
||||
license = lib.licenses.lgpl21;
|
||||
|
Loading…
Reference in New Issue
Block a user