mirror of
https://github.com/ryantm/nixpkgs-update.git
synced 2024-12-17 16:31:47 +03:00
add src url fixer; tail of nix build failures
This commit is contained in:
parent
6de0466d29
commit
08de2bff36
54
fix-src-url.sh
Executable file
54
fix-src-url.sh
Executable file
@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euxo pipefail
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
GITHUB_TOKEN="$(cat "$SCRIPT_DIR"/github_token.txt)"
|
||||
export GITHUB_TOKEN
|
||||
|
||||
# shellcheck source=setup-nixpkgs.sh
|
||||
source "$SCRIPT_DIR/setup-nixpkgs.sh"
|
||||
|
||||
PACKAGE_NAME=$1
|
||||
OLD_VERSION=$2
|
||||
NEW_VERSION=$3
|
||||
DERIVATION_FILE=$4
|
||||
ATTR_PATH=$5
|
||||
OLD_SRC_URL=$6
|
||||
|
||||
|
||||
DOWNLOADS=$(curl "https://repology.org/api/v1/metapackage/$PACKAGE_NAME" | jq '.[].downloads | select(values) | .[] ' | grep "$NEW_VERSION" | sed 's|"||g')
|
||||
|
||||
# if [ -z "$DOWNLOADS" ]
|
||||
# then
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
OLD_DERIVATION_NAME=$(nix eval -f ~/p/nixpkgs --raw "pkgs.$ATTR_PATH.name")
|
||||
NEW_DERIVATION_NAME=$(sed "s|$OLD_VERSION|$NEW_VERSION|" <<< "$OLD_DERIVATION_NAME")
|
||||
NAME=$(nix eval --raw "(let pkgs = import ./. {}; in (builtins.parseDrvName pkgs.$ATTR_PATH.name).name)")
|
||||
|
||||
if grep -q "name = \"$NEW_DERIVATION_NAME\"" "$DERIVATION_FILE"
|
||||
then
|
||||
# Separate name and version
|
||||
sed -i "s|$NEW_DERIVATION_NAME|$NAME-\${version}|" "$DERIVATION_FILE"
|
||||
grep -q "name = \"$NAME-\${version}\"" "$DERIVATION_FILE"
|
||||
# shellcheck disable=SC2016
|
||||
sed -i 's|^\([ ]*\)\(name = "'"$NAME"'-\${version}";\)|\1\2\n\1version = "'"$NEW_VERSION"'";|' "$DERIVATION_FILE"
|
||||
grep -q "version = \"$NEW_VERSION\";" "$DERIVATION_FILE"
|
||||
fi
|
||||
|
||||
for d in $DOWNLOADS
|
||||
do
|
||||
OLD_URL="$OLD_SRC_URL"
|
||||
OLD_URL=$(sed "s|$OLD_DERIVATION_NAME|\${name}|" <<< "$OLD_URL")
|
||||
OLD_URL=$(sed "s|$OLD_VERSION|\${version}|" <<< "$OLD_URL")
|
||||
|
||||
NEW_URL=$(sed "s|$NEW_DERIVATION_NAME|\${name}|" <<< "$d" | sed "s|$NEW_VERSION|\${version}|")
|
||||
sed -i "s|$OLD_URL|$NEW_URL|" "$DERIVATION_FILE"
|
||||
grep -q 'url = "'"$NEW_URL"'";' "$DERIVATION_FILE" || continue
|
||||
|
||||
nix-prefetch-url -A "$ATTR_PATH.src" && exit 0
|
||||
done
|
||||
|
||||
exit 1
|
12
up.sh
12
up.sh
@ -160,18 +160,21 @@ git checkout "$(git merge-base upstream/master upstream/staging)"
|
||||
git checkout -B "$BRANCH_NAME"
|
||||
OLD_HASH=$(nix eval -f . --raw "pkgs.$ATTR_PATH.src.drvAttrs.outputHash" || error_exit "Couldn't find old output hash at ATTR_PATH.src.drvAttrs.outputHash.")
|
||||
|
||||
OLD_SRC_URL=$(nix eval -f . '(let pkgs = import ./. {}; in builtins.elemAt pkgs.'"$ATTR_PATH"'.src.drvAttrs.urls 0)')
|
||||
OLD_SRC_URL=$(nix eval -f . --raw '(let pkgs = import ./. {}; in builtins.elemAt pkgs.'"$ATTR_PATH"'.src.drvAttrs.urls 0)')
|
||||
|
||||
sed -i "s/${OLD_VERSION//\./\\.}/$NEW_VERSION/g" "$DERIVATION_FILE" || error_exit "Could not replace OLD_VERSION with NEW_VERSION."
|
||||
|
||||
NEW_SRC_URL=$(nix eval -f . '(let pkgs = import ./. {}; in builtins.elemAt pkgs.'"$ATTR_PATH"'.src.drvAttrs.urls 0)')
|
||||
NEW_SRC_URL=$(nix eval -f . --raw '(let pkgs = import ./. {}; in builtins.elemAt pkgs.'"$ATTR_PATH"'.src.drvAttrs.urls 0)')
|
||||
|
||||
if [ "$OLD_SRC_URL" == "$NEW_SRC_URL" ]
|
||||
then
|
||||
error_exit "Source url did not change."
|
||||
fi
|
||||
|
||||
NEW_HASH=$(nix-prefetch-url -A "$ATTR_PATH.src" || error_exit "Could not prefetch new version URL.")
|
||||
NEW_HASH=$(
|
||||
nix-prefetch-url -A "$ATTR_PATH.src" || \
|
||||
"$SCRIPT_DIR"/fix-src-url.sh "$PACKAGE_NAME" "$OLD_VERSION" "$NEW_VERSION" "$DERIVATION_FILE" "$ATTR_PATH" "$OLD_SRC_URL" || \
|
||||
error_exit "Could not prefetch new version URL.")
|
||||
|
||||
if [ "$OLD_HASH" = "$NEW_HASH" ]
|
||||
then
|
||||
@ -182,7 +185,8 @@ sed -i "s/$OLD_HASH/$NEW_HASH/g" "$DERIVATION_FILE" || error_exit "Could not rep
|
||||
|
||||
rm -f result*
|
||||
|
||||
nix build -f . "$ATTR_PATH" || error_exit "nix build failed."
|
||||
nix build -f . "$ATTR_PATH" || error_exit "nix build failed.
|
||||
$(nix log -f . "$ATTR_PATH" | tail -n 30)"
|
||||
|
||||
RESULT=$(readlink ./result || readlink ./result-bin || error_exit "Couldn't find result link.")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user