mkgmap: use SRI hashes and finalAttrs pattern

This commit is contained in:
Aliaksandr
2026-02-10 03:43:47 +02:00
parent 662079646e
commit 511328020e
3 changed files with 62 additions and 61 deletions
+7 -7
View File
@@ -2,30 +2,30 @@
{
fastutil = fetchurl {
url = "http://ivy.mkgmap.org.uk/repo/it.unimi.dsi/fastutil/6.5.15-mkg.1b/jars/fastutil.jar";
sha256 = "0d88m0rpi69wgxhnj5zh924q4zsvxq8m4ybk7m9mr3gz1hx0yx8c";
hash = "sha256-DHUPOgz/jVxTPXN5UhHuW3+CiUjwF2lhfzyZeDOoCDU=";
};
osmpbf = fetchurl {
url = "http://ivy.mkgmap.org.uk/repo/crosby/osmpbf/1.3.3/jars/osmpbf.jar";
sha256 = "0zb4pqkwly5z30ww66qhhasdhdrzwmrw00347yrbgyk2ii4wjad3";
hash = "sha256-oynJSYxi+reyP2QAwHPlPzfYtIIQG8M5GL94yie+ZH0=";
};
protobuf = fetchurl {
url = "mirror://maven/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar";
sha256 = "0x6c4pbsizvk3lm6nxcgi1g2iqgrxcna1ip74lbn01f0fm2wdhg0";
hash = "sha256-4MHGRXXABWAXJefGoCzr+eEoXoiPdWsqHXP/qNclzHQ=";
};
xpp3 = fetchurl {
url = "mirror://maven/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar";
sha256 = "1f9ifnxxj295xb1494jycbfm76476xm5l52p7608gf0v91d3jh83";
hash = "sha256-A0E5WkgbuIeAOVcUWmo3h5hT3WJekkTC6iUJ2bt1Mbk=";
};
jaxb-api = fetchurl {
url = "mirror://maven/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar";
sha256 = "00rxpc0m30d3jc572ni01ryxq8gcbnr955xsabrijg9pknc0fc48";
hash = "sha256-iDAHmJ03PRnzUrqXkrJd7CHcfQ4gWnEKk6OBUQG7PQM=";
};
junit = fetchurl {
url = "mirror://maven/junit/junit/4.11/junit-4.11.jar";
sha256 = "1zh6klzv8w30dx7jg6pkhllk4587av4znflzhxz8x97c7rhf3a4h";
hash = "sha256-kKjhYD7spI5+h586+8lWBxUyKYXzmidPb2BwtD+dBv4=";
};
hamcrest-core = fetchurl {
url = "mirror://maven/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar";
sha256 = "1sfqqi8p5957hs9yik44an3lwpv8ln2a6sh9gbgli4vkx68yzzb6";
hash = "sha256-Zv3vkelzk0jfeglqo4SlaF9Oh1WEzOiThqekclHE2Ok=";
};
}
+39 -38
View File
@@ -11,18 +11,19 @@
doCheck ? true,
withExamples ? false,
}:
let
deps = import ./deps.nix { inherit fetchurl; };
testInputs = import ./testinputs.nix { inherit fetchurl; };
in
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "mkgmap";
version = "4924";
src = fetchsvn {
url = "https://svn.mkgmap.org.uk/mkgmap/mkgmap/trunk";
rev = version;
sha256 = "sha256-4DGGAWgyIvK5pcopwlO4YDGDc73lOsL0Ljy/kFUY2As=";
rev = finalAttrs.version;
hash = "sha256-4DGGAWgyIvK5pcopwlO4YDGDc73lOsL0Ljy/kFUY2As=";
};
patches = [
@@ -31,36 +32,34 @@ stdenv.mkDerivation rec {
./ignore-impure-test.patch
];
postPatch =
with deps;
''
# Manually create version properties file for reproducibility
mkdir -p build/classes
cat > build/classes/mkgmap-version.properties << EOF
svn.version=${version}
build.timestamp=unknown
EOF
postPatch = ''
# Manually create version properties file for reproducibility
mkdir -p build/classes
cat > build/classes/mkgmap-version.properties << EOF
svn.version=${finalAttrs.version}
build.timestamp=unknown
EOF
# Put pre-fetched dependencies into the right place
mkdir -p lib/compile
cp ${fastutil} lib/compile/${fastutil.name}
cp ${osmpbf} lib/compile/${osmpbf.name}
cp ${protobuf} lib/compile/${protobuf.name}
''
+ lib.optionalString doCheck ''
mkdir -p lib/test
cp ${fastutil} lib/test/${fastutil.name}
cp ${osmpbf} lib/test/${osmpbf.name}
cp ${protobuf} lib/test/${protobuf.name}
cp ${jaxb-api} lib/test/${jaxb-api.name}
cp ${junit} lib/test/${junit.name}
cp ${hamcrest-core} lib/test/${hamcrest-core.name}
# Put pre-fetched dependencies into the right place
mkdir -p lib/compile
cp ${deps.fastutil} lib/compile/${deps.fastutil.name}
cp ${deps.osmpbf} lib/compile/${deps.osmpbf.name}
cp ${deps.protobuf} lib/compile/${deps.protobuf.name}
''
+ lib.optionalString doCheck ''
mkdir -p lib/test
cp ${deps.fastutil} lib/test/${deps.fastutil.name}
cp ${deps.osmpbf} lib/test/${deps.osmpbf.name}
cp ${deps.protobuf} lib/test/${deps.protobuf.name}
cp ${deps.jaxb-api} lib/test/${deps.jaxb-api.name}
cp ${deps.junit} lib/test/${deps.junit.name}
cp ${deps.hamcrest-core} lib/test/${deps.hamcrest-core.name}
mkdir -p test/resources/in/img
${lib.concatMapStringsSep "\n" (res: ''
cp ${res} test/resources/in/${builtins.replaceStrings [ "__" ] [ "/" ] res.name}
'') testInputs}
'';
mkdir -p test/resources/in/img
${lib.concatMapStringsSep "\n" (res: ''
cp ${res} test/resources/in/${builtins.replaceStrings [ "__" ] [ "/" ] res.name}
'') testInputs}
'';
nativeBuildInputs = [
jdk
@@ -100,11 +99,14 @@ stdenv.mkDerivation rec {
runHook postInstall
'';
passthru.updateScript = [
./update.sh
"mkgmap"
meta.downloadPage
];
passthru = {
inherit deps;
updateScript = [
./update.sh
"mkgmap"
finalAttrs.meta.downloadPage
];
};
meta = {
description = "Create maps for Garmin GPS devices from OpenStreetMap (OSM) data";
@@ -119,5 +121,4 @@ stdenv.mkDerivation rec {
binaryBytecode # deps
];
};
}
})
+16 -16
View File
@@ -1,9 +1,9 @@
{ fetchurl }:
let
fetchTestInput =
{ res, sha256 }:
{ res, hash }:
fetchurl {
inherit sha256;
inherit hash;
url = "https://www.mkgmap.org.uk/testinput/${res}";
name = builtins.replaceStrings [ "/" ] [ "__" ] res;
};
@@ -11,58 +11,58 @@ in
[
(fetchTestInput {
res = "osm/lon1.osm.gz";
sha256 = "1r8sl67hayjgybxy9crqwp7f1w0ljxvxh0apqcvr888yhsbb8drv";
hash = "sha256-Oze0loYeIZQ3w1cB2HeXFPDgzuU4s+T78k96BY+hGuU=";
})
(fetchTestInput {
res = "osm/uk-test-1.osm.gz";
sha256 = "0jdngkjn22jvi8q7hrzpqb9mnjlz82h1dwdmc4qrb64kkhzm4dfk";
hash = "sha256-0zVSP5yTmJUxYbXxFqBAn0pb08L3Z3gwilsKYeV8tkk=";
})
(fetchTestInput {
res = "osm/uk-test-2.osm.gz";
sha256 = "05mw0qcdgki151ldmxayry0gqlb72jm5wrvxq3dkwq5i7jb21qs4";
hash = "sha256-ROMgljyxYD7bwH1nXqoUZ1H8gM9e9dpoKCHO1xgGvBY=";
})
(fetchTestInput {
res = "osm/is-in-samples.osm";
sha256 = "18vqfbq25ys59bj6dl6dq3q4m2ri3ki2xazim14fm94k1pbyhbh3";
hash = "sha256-Ay7o1w2TpOpIqPGrLuIcMYtK8MDN0GbkSkX7IvByeKM=";
})
(fetchTestInput {
res = "mp/test1.mp";
sha256 = "1dykr0z84c3fqgm9kdp2dzvxc3galjbx0dn9zxjw8cfk7mvnspj2";
hash = "sha256-Ql5tdz3TMcRl/8k20Jek6g3W92/itpnqw24wgj7I07c=";
})
(fetchTestInput {
res = "img/63240001.img";
sha256 = "1wmqgy940q1svazw85z8di20xyjm3vpaiaj9hizr47b549klw74q";
hash = "sha256-mBxOZyJlHZJ/hEmqqO4eVfoORGzoF8S/2jpgQJJ/uPI=";
})
(fetchTestInput {
res = "img/63240002.img";
sha256 = "12ivywkiw6lrglyk0clnx5ff2wqj4z0c3f5yqjsqlsaawbmxqa1f";
hash = "sha256-Lijc6+JKaYq1xL64wcAnEnPhXOmWMjA9fZkaHif3O4o=";
})
(fetchTestInput {
res = "img/63240003.img";
sha256 = "19mgxqv6kqk8ahs8s819sj7cc79id67373ckwfsq7vvqyfrbasz1";
hash = "sha256-4Wu1svN474O145ONM45pMR3GjtQpII00VGjiaTbur6Y=";
})
(fetchTestInput {
res = "hgt/N00W090.hgt.zip";
sha256 = "16hb06bgf47sz2mfbbx3xqmrh1nmm04wj4ngm512sng4rjhksxgn";
hash = "sha256-9nU9oczkWS1Cqc8SyQmo1QaYK+6jr+Wq+PoQ95YBC5o=";
})
(fetchTestInput {
res = "hgt/N00W091.hgt.zip";
sha256 = "153j4wj7170qj81nr7sr6dp9zar62gnrkh6ww62bygpfqqyzdr1x";
hash = "sha256-PeT2PcbuPr+E4dzAme0TJqufbjNZn2wDkhiccCQncpQ=";
})
(fetchTestInput {
res = "hgt/S01W090.hgt.zip";
sha256 = "0czgs9rhp7bnzmzm7907vprj3nhm2lj6q1piafk8dm9rcqkfg8sj";
hash = "sha256-UqPnJmY51YamU/EGbCQVFdoh890HpFN//XadC3PS7zM=";
})
(fetchTestInput {
res = "hgt/S01W091.hgt.zip";
sha256 = "0z58q3ai499mflxfjqhqv9i1di3fmp05pkv39886k1na107g3wbn";
hash = "sha256-dvHxDgjKhmkQSmPPW8CtbsQWYtoYYuk6dTUlEtXAqHw=";
})
(fetchTestInput {
res = "hgt/S02W090.hgt.zip";
sha256 = "0q7817gdxk2vq73ci6ffks288zqywc21f5ns73b6p5ds2lrxhf5n";
hash = "sha256-tjjYMxW6lWvWONoWFwTjHn+EhJ7OmcjGwVvM3t4J6GA=";
})
(fetchTestInput {
res = "hgt/S02W091.hgt.zip";
sha256 = "1mwpgd85v9n99gmx2bn8md7d312wvhq86w3c9k92y8ayrs20lmdr";
hash = "sha256-uVUKhM5eIS/STGxwgzDcXITRTqvILtHrS8mmXVB7l9c=";
})
]