Merge pull request #201917 from rhendric/rhendric/wine-updateScript

wine, winetricks: add updateScript

authored by 7c6f434c and committed by GitHub 489a94fd 9072614c

+125
+1
pkgs/applications/emulators/wine/base.nix
··· 185 185 186 186 passthru = { 187 187 inherit pkgArches; 188 + inherit (src) updateScript; 188 189 tests = { inherit (nixosTests) wine; }; 189 190 }; 190 191 meta = {
+71
pkgs/applications/emulators/wine/sources.nix
··· 12 12 pkgs.fetchFromGitHub { inherit owner repo rev sha256; } // args; 13 13 fetchFromGitLab = args@{domain, owner, repo, rev, sha256, ...}: 14 14 pkgs.fetchFromGitLab { inherit domain owner repo rev sha256; } // args; 15 + 16 + updateScriptPreamble = '' 17 + set -eou pipefail 18 + PATH=${with pkgs; lib.makeBinPath [ common-updater-scripts coreutils curl gnugrep gnused jq nix ]} 19 + sources_file=${__curPos.file} 20 + source ${./update-lib.sh} 21 + ''; 22 + 23 + inherit (pkgs) writeShellScript; 15 24 in rec { 16 25 17 26 stable = fetchurl rec { ··· 42 51 # Also look for root certificates at $NIX_SSL_CERT_FILE 43 52 ./cert-path.patch 44 53 ]; 54 + 55 + updateScript = writeShellScript "update-wine-stable" ('' 56 + ${updateScriptPreamble} 57 + major=''${UPDATE_NIX_OLD_VERSION%.*} 58 + latest_stable=$(get_latest_wine_version "$major.0") 59 + latest_gecko=$(get_latest_lib_version wine-gecko) 60 + 61 + # Can't use autobump on stable because we don't want the path 62 + # <source/7.0/wine-7.0.tar.xz> to become <source/7.0.1/wine-7.0.1.tar.xz>. 63 + if [[ "$UPDATE_NIX_OLD_VERSION" != "$latest_stable" ]]; then 64 + set_version_and_sha256 stable "$latest_stable" "$(nix-prefetch-url "$wine_url_base/source/$major.0/wine-$latest_stable.tar.xz")" 65 + fi 66 + 67 + autobump stable.gecko32 "$latest_gecko" 68 + autobump stable.gecko64 "$latest_gecko" 69 + 70 + do_update 71 + ''); 45 72 }; 46 73 47 74 unstable = fetchurl rec { ··· 56 83 url = "https://dl.winehq.org/wine/wine-mono/${version}/wine-mono-${version}-x86.msi"; 57 84 sha256 = "sha256-ZBP/Mo679+x2icZI/rNUbYEC3thlB50fvwMxsUs6sOw="; 58 85 }; 86 + 87 + updateScript = writeShellScript "update-wine-unstable" '' 88 + ${updateScriptPreamble} 89 + major=''${UPDATE_NIX_OLD_VERSION%.*} 90 + latest_unstable=$(get_latest_wine_version "$major.x") 91 + latest_mono=$(get_latest_lib_version wine-mono) 92 + 93 + update_staging() { 94 + staging_url=$(get_source_attr staging.url) 95 + set_source_attr staging sha256 "\"$(to_sri "$(nix-prefetch-url --unpack "''${staging_url//$1/$2}")")\"" 96 + } 97 + 98 + autobump unstable "$latest_unstable" "" update_staging 99 + autobump unstable.mono "$latest_mono" 100 + 101 + do_update 102 + ''; 59 103 }; 60 104 61 105 staging = fetchFromGitHub rec { ··· 81 125 inherit (unstable) gecko32 gecko64; 82 126 83 127 inherit (unstable) mono; 128 + 129 + updateScript = writeShellScript "update-wine-wayland" '' 130 + ${updateScriptPreamble} 131 + wayland_rev=$(get_source_attr wayland.rev) 132 + 133 + latest_wayland_rev=$(curl -s 'https://gitlab.collabora.com/api/v4/projects/2847/repository/branches/wayland' | jq -r .commit.id) 134 + 135 + if [[ "$wayland_rev" != "$latest_wayland_rev" ]]; then 136 + latest_wayland=$(curl -s 'https://gitlab.collabora.com/alf/wine/-/raw/wayland/VERSION' | cut -f3 -d' ') 137 + wayland_url=$(get_source_attr wayland.url) 138 + set_version_and_sha256 wayland "$latest_wayland" "$(nix-prefetch-url --unpack "''${wayland_url/$wayland_rev/$latest_wayland_rev}")" 139 + set_source_attr wayland rev "\"$latest_wayland_rev\"" 140 + fi 141 + 142 + do_update 143 + ''; 84 144 }; 85 145 86 146 winetricks = fetchFromGitHub rec { ··· 90 150 owner = "Winetricks"; 91 151 repo = "winetricks"; 92 152 rev = version; 153 + 154 + updateScript = writeShellScript "update-winetricks" '' 155 + ${updateScriptPreamble} 156 + winetricks_repourl=$(get_source_attr winetricks.gitRepoUrl) 157 + 158 + latest_winetricks=$(list-git-tags --url="$winetricks_repourl" | grep -E '^[0-9]{8}$' | sort --reverse --numeric-sort | head -n 1) 159 + 160 + autobump winetricks "$latest_winetricks" 'nix-prefetch-url --unpack' 161 + 162 + do_update 163 + ''; 93 164 }; 94 165 }
+49
pkgs/applications/emulators/wine/update-lib.sh
··· 1 + wine_url_base=https://dl.winehq.org/wine 2 + 3 + sed_exprs=() 4 + 5 + get_source_attr() { 6 + nix-instantiate --eval --json -E "(let pkgs = import ./. {}; in pkgs.callPackage $sources_file { inherit pkgs; }).$1" | jq -r 7 + } 8 + 9 + set_source_attr() { 10 + path="$1" 11 + name="$2" 12 + value="$3" 13 + line=$(nix-instantiate --eval -E "(builtins.unsafeGetAttrPos \"$name\" (let pkgs = import ./. {}; in pkgs.callPackage $sources_file { inherit pkgs; }).$path).line") 14 + sed_exprs+=(-e "${line}s@[^ ].*\$@$name = $value;@") 15 + } 16 + 17 + set_version_and_sha256() { 18 + set_source_attr "$1" version "\"$2\"" 19 + set_source_attr "$1" sha256 "\"$(to_sri "$3")\"" 20 + } 21 + 22 + get_latest_wine_version() { 23 + list-directory-versions --pname=wine --url="$wine_url_base/source/$1" | grep -v 'diff\|rc\|tar' | sort --reverse --version-sort -u | head -n 1 24 + } 25 + 26 + get_latest_lib_version() { 27 + curl -s "$wine_url_base/$1/" | grep -o 'href="[0-9.]*/"' | sed 's_^href="\(.*\)/"_\1_' | sort --reverse --version-sort -u | head -n 1 28 + } 29 + 30 + to_sri() { 31 + nix --extra-experimental-features nix-command hash to-sri --type sha256 "$1" 32 + } 33 + 34 + autobump() { 35 + attr="$1" 36 + latest="$2" 37 + fetcher="${3:-nix-prefetch-url}" 38 + more="${4:-}" 39 + version=$(get_source_attr "$attr.version") 40 + if [[ "$version" != "$latest" ]]; then 41 + url=$(get_source_attr "$attr.url") 42 + set_version_and_sha256 "$attr" "$latest" "$($fetcher "${url//$version/$latest}")" 43 + [[ -z "$more" ]] || $more "$version" "$latest" 44 + fi 45 + } 46 + 47 + do_update() { 48 + [[ "${#sed_exprs[@]}" -eq 0 ]] || sed -i "${sed_exprs[@]}" "$sources_file" 49 + }
+4
pkgs/applications/emulators/wine/winetricks.nix
··· 24 24 "$out/bin/winetricks" 25 25 ''; 26 26 27 + passthru = { 28 + inherit (src) updateScript; 29 + }; 30 + 27 31 meta = { 28 32 description = "A script to install DLLs needed to work around problems in Wine"; 29 33 license = lib.licenses.lgpl21;