3
0
Fork 0
forked from mirrors/nixpkgs

common-updater, firefox: fix updater for firefox

This commit is contained in:
taku0 2018-11-16 23:04:54 +09:00
parent fa138b55a6
commit 4bb9af228e
3 changed files with 13 additions and 4 deletions

View file

@ -43,6 +43,7 @@ rec {
};
updateScript = callPackage ./update.nix {
attrPath = "firefox-unwrapped";
versionKey = "ffversion";
};
};
@ -67,6 +68,7 @@ rec {
updateScript = callPackage ./update.nix {
attrPath = "firefox-esr-52-unwrapped";
ffversionSuffix = "esr";
versionKey = "ffversion";
};
};
@ -92,6 +94,7 @@ rec {
updateScript = callPackage ./update.nix {
attrPath = "firefox-esr-60-unwrapped";
versionSuffix = "esr";
versionKey = "ffversion";
};
};

View file

@ -9,6 +9,7 @@
, attrPath
, baseUrl ? "http://archive.mozilla.org/pub/firefox/releases/"
, versionSuffix ? ""
, versionKey ? "version"
}:
writeScript "update-${attrPath}" ''
@ -28,5 +29,5 @@ writeScript "update-${attrPath}" ''
sort --version-sort | \
tail -n 1`
update-source-version ${attrPath} "$version"
update-source-version ${attrPath} "$version" "" "" ${versionKey}
''

View file

@ -6,11 +6,16 @@ die() {
exit 1
}
# Usage: update-source-hash <attr> <version> [<new-source-hash>] [<new-source-url>]
# Usage: update-source-hash <attr> <version> [<new-source-hash>] [<new-source-url>] [<version-key>]
attr=$1
newVersion=$2
newHash=$3
newUrl=$4
versionKey=$5
if [ -z "$versionKey" ]; then
versionKey=version
fi
nixFile=$(nix-instantiate --eval --strict -A "$attr.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
if [ ! -f "$nixFile" ]; then
@ -50,8 +55,8 @@ fi
oldVersion=$(echo "$oldVersion" | sed -re 's|[.+]|\\&|g')
oldUrl=$(echo "$oldUrl" | sed -re 's|[${}.+]|\\&|g')
if [ $(grep -c -E "^\s*(let\b)?\s*version\s*=\s*\"$oldVersion\"" "$nixFile") = 1 ]; then
pattern="/\bversion\b\s*=/ s|\"$oldVersion\"|\"$newVersion\"|"
if [ $(grep -c -E "^\s*(let\b)?\s*$versionKey\s*=\s*\"$oldVersion\"" "$nixFile") = 1 ]; then
pattern="/\b$versionKey\b\s*=/ s|\"$oldVersion\"|\"$newVersion\"|"
elif [ $(grep -c -E "^\s*(let\b)?\s*name\s*=\s*\"[^\"]+-$oldVersion\"" "$nixFile") = 1 ]; then
pattern="/\bname\b\s*=/ s|-$oldVersion\"|-$newVersion\"|"
else