aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/common-updater
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2020-05-20 01:39:43 +0200
committerKatharina Fey <kookie@spacekookie.de>2020-05-20 01:39:43 +0200
commit1849de11ec1e32e9eebb83f24d5339bea88b7ed7 (patch)
tree0aaf3cead09c2d55c67c6f6a86ad20af399797d8 /nixpkgs/pkgs/common-updater
parent304c06d7a7ea3f5c84031d325ece8d38b8c1d829 (diff)
parent0f5ce2fac0c726036ca69a5524c59a49e2973dd4 (diff)
Merge commit '0f5ce2fac0c726036ca69a5524c59a49e2973dd4'
Diffstat (limited to 'nixpkgs/pkgs/common-updater')
-rw-r--r--nixpkgs/pkgs/common-updater/generic-updater.nix24
-rw-r--r--nixpkgs/pkgs/common-updater/scripts.nix4
-rwxr-xr-xnixpkgs/pkgs/common-updater/scripts/mark-broken86
3 files changed, 105 insertions, 9 deletions
diff --git a/nixpkgs/pkgs/common-updater/generic-updater.nix b/nixpkgs/pkgs/common-updater/generic-updater.nix
index 8e8153d9a33..8483f9bbd1d 100644
--- a/nixpkgs/pkgs/common-updater/generic-updater.nix
+++ b/nixpkgs/pkgs/common-updater/generic-updater.nix
@@ -4,9 +4,10 @@
, version
, attrPath ? pname
, versionLister
+, ignoredVersions ? ""
, rev-prefix ? ""
-, odd-unstable ? true
-, patchlevel-unstable ? true
+, odd-unstable ? false
+, patchlevel-unstable ? false
}:
let
@@ -23,13 +24,19 @@ let
version="$2"
attr_path="$3"
version_lister="$4"
- rev_prefix="$5"
- odd_unstable="$6"
- patchlevel_unstable="$7"
+ ignored_versions="$5"
+ rev_prefix="$6"
+ odd_unstable="$7"
+ patchlevel_unstable="$8"
# print header
echo "# $pname-$version" >> ${fileForGitCommands}
+ function version_is_ignored() {
+ local tag="$1"
+ [ -n "$ignored_versions" ] && grep -E "$ignored_versions" <<< "$tag"
+ }
+
function version_is_unstable() {
local tag="$1"
local enforce="$2"
@@ -68,7 +75,10 @@ let
# find the newest tag
# do not consider development versions
for latest_tag in $tags; do
- if version_is_unstable "$latest_tag"; then
+ if version_is_ignored "$latest_tag"; then
+ echo "# skip ignored version: $pname-$latest_tag" >> ${fileForGitCommands}
+ latest_tag=
+ elif version_is_unstable "$latest_tag"; then
echo "# skip development version: $pname-$latest_tag" >> ${fileForGitCommands}
latest_tag=
else
@@ -95,4 +105,4 @@ let
'';
in
-[ updateScript pname version attrPath versionLister rev-prefix odd-unstable patchlevel-unstable ]
+[ updateScript pname version attrPath versionLister ignoredVersions rev-prefix odd-unstable patchlevel-unstable ]
diff --git a/nixpkgs/pkgs/common-updater/scripts.nix b/nixpkgs/pkgs/common-updater/scripts.nix
index 655924e5f28..739f44387b3 100644
--- a/nixpkgs/pkgs/common-updater/scripts.nix
+++ b/nixpkgs/pkgs/common-updater/scripts.nix
@@ -1,4 +1,4 @@
-{ stdenv, makeWrapper, coreutils, gnused, gnugrep, diffutils, nix, git }:
+{ stdenv, makeWrapper, coreutils, gnused, gnugrep, diffutils, nix, git, jq }:
stdenv.mkDerivation {
name = "common-updater-scripts";
@@ -12,7 +12,7 @@ stdenv.mkDerivation {
cp ${./scripts}/* $out/bin
for f in $out/bin/*; do
- wrapProgram $f --prefix PATH : ${stdenv.lib.makeBinPath [ coreutils gnused gnugrep nix diffutils git ]}
+ wrapProgram $f --prefix PATH : ${stdenv.lib.makeBinPath [ coreutils gnused gnugrep nix diffutils git jq ]}
done
'';
}
diff --git a/nixpkgs/pkgs/common-updater/scripts/mark-broken b/nixpkgs/pkgs/common-updater/scripts/mark-broken
new file mode 100755
index 00000000000..d128d0d458b
--- /dev/null
+++ b/nixpkgs/pkgs/common-updater/scripts/mark-broken
@@ -0,0 +1,86 @@
+#!/usr/bin/env bash
+set -e
+
+scriptName=mark-broken # do not use the .wrapped name
+
+die() {
+ echo "$scriptName: error: $1" >&2
+ exit 1
+}
+
+usage() {
+ echo "Usage: $scriptName <attr> [--new-value=<new-value>]"
+}
+
+args=()
+
+for arg in "$@"; do
+ case $arg in
+ --new-value=*)
+ newValue="${arg#*=}"
+ ;;
+ --help)
+ usage
+ exit 0
+ ;;
+ --*)
+ echo "$scriptName: Unknown argument: $arg"
+ usage
+ exit 1
+ ;;
+ *)
+ args["${#args[*]}"]=$arg
+ ;;
+ esac
+done
+
+attr=${args[0]}
+
+if (( "${#args[*]}" < 1 )); then
+ echo "$scriptName: Too few arguments"
+ usage
+ exit 1
+fi
+
+if (( "${#args[*]}" > 1 )); then
+ echo "$scriptName: Too many arguments"
+ usage
+ exit 1
+fi
+
+if [ -z $newValue ]; then
+ newValue="true"
+fi
+
+nixFile=$(nix-instantiate --eval --json -E "with import ./. {}; (builtins.unsafeGetAttrPos \"description\" $attr.meta).file" | jq -r .)
+if [[ ! -f "$nixFile" ]]; then
+ die "Couldn't evaluate 'builtins.unsafeGetAttrPos \"description\" $attr.meta' to locate the .nix file!"
+fi
+
+# Insert broken attribute
+sed -i.bak "$nixFile" -r \
+ -e "/^\s*broken\s*=.*$/d" \
+ -e "s/(\s*)meta\s*=.*\{/&\n\1 broken = $newValue;/"
+
+if cmp -s "$nixFile" "$nixFile.bak"; then
+ mv "$nixFile.bak" "$nixFile"
+ die "Failed to mark the package as broken! Does it have a meta attribute?"
+fi
+
+if [[ "$newValue" == "true" ]]; then
+ # broken should evaluate to true in any case now
+ markedSuccessfully=$(nix-instantiate --eval -E "with import ./. {}; $attr.meta.broken" || true)
+ if [[ ! "$markedSuccessfully" == "true" ]]; then
+ mv "$nixFile.bak" "$nixFile"
+ die "Couldn't verify the broken attribute to be set correctly, restoring backup!"
+ fi
+else
+ # we can not check if broken evaluates to the correct value, but we can check that it does evaluate
+ if ! nix-instantiate --eval -E "with import ./. {}; $attr.meta.broken" >/dev/null; then
+ mv "$nixFile.bak" "$nixFile"
+ die "Couldn't verify the broken attribute to be set correctly, restoring backup!"
+ fi
+fi
+
+rm -f "$nixFile.bak"
+rm -f "$attr.fetchlog"