summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author7c6f434c <7c6f434c@mail.ru>2022-12-12 20:32:34 +0000
committerGitHub <noreply@github.com>2022-12-12 20:32:34 +0000
commit489a94fd0e49909a65a8a93395b252cadd780c7f (patch)
tree757549b7cfc51e5a1212500b628e4d18ee14bac3
parentMerge pull request #205795 from Mic92/sysdig (diff)
parentwine, winetricks: add updateScript (diff)
downloadnixpkgs-489a94fd0e49909a65a8a93395b252cadd780c7f.tar.gz
Merge pull request #201917 from rhendric/rhendric/wine-updateScript
wine, winetricks: add updateScript
-rw-r--r--pkgs/applications/emulators/wine/base.nix1
-rw-r--r--pkgs/applications/emulators/wine/sources.nix71
-rw-r--r--pkgs/applications/emulators/wine/update-lib.sh49
-rw-r--r--pkgs/applications/emulators/wine/winetricks.nix4
4 files changed, 125 insertions, 0 deletions
diff --git a/pkgs/applications/emulators/wine/base.nix b/pkgs/applications/emulators/wine/base.nix
index 699aa303462a..f1ae106df46a 100644
--- a/pkgs/applications/emulators/wine/base.nix
+++ b/pkgs/applications/emulators/wine/base.nix
@@ -185,6 +185,7 @@ stdenv.mkDerivation ((lib.optionalAttrs (buildScript != null) {
passthru = {
inherit pkgArches;
+ inherit (src) updateScript;
tests = { inherit (nixosTests) wine; };
};
meta = {
diff --git a/pkgs/applications/emulators/wine/sources.nix b/pkgs/applications/emulators/wine/sources.nix
index 7306112ce259..e00f39406719 100644
--- a/pkgs/applications/emulators/wine/sources.nix
+++ b/pkgs/applications/emulators/wine/sources.nix
@@ -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
+ '';
};
}
diff --git a/pkgs/applications/emulators/wine/update-lib.sh b/pkgs/applications/emulators/wine/update-lib.sh
new file mode 100644
index 000000000000..8192d3b5ab58
--- /dev/null
+++ b/pkgs/applications/emulators/wine/update-lib.sh
@@ -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"
+}
diff --git a/pkgs/applications/emulators/wine/winetricks.nix b/pkgs/applications/emulators/wine/winetricks.nix
index 61ca6515c448..c5d8e9bd95b3 100644
--- a/pkgs/applications/emulators/wine/winetricks.nix
+++ b/pkgs/applications/emulators/wine/winetricks.nix
@@ -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;