fetchRepoProject: Fetch into $out and make it deterministic

Fetch into $out and remove all version control files to make it
deterministic (.repo and all .git subdirectories - e.g. the .git/index
files change every time).

Additionally I've changed the default of "useArchive" to false because
fetching with "--archive" will fail for some projects (e.g.
"platform/external/iosched" from the AOSP).

Now, this function should hopefully work for every tag of the AOSP.
This commit is contained in:
Michael Weiss 2017-09-17 23:16:33 +02:00
parent 7db2916648
commit 018a5ae2f4

View File

@ -1,8 +1,9 @@
{ stdenv, gitRepo, cacert, copyPathsToStore }: { stdenv, gitRepo, cacert, copyPathsToStore }:
{ name, manifest, rev ? "HEAD", sha256 { name, manifest, rev ? "HEAD", sha256
# Optional parameters:
, repoRepoURL ? "", repoRepoRev ? "", referenceDir ? "" , repoRepoURL ? "", repoRepoRev ? "", referenceDir ? ""
, localManifests ? [], createMirror ? false, useArchive ? !createMirror , localManifests ? [], createMirror ? false, useArchive ? false
}: }:
assert repoRepoRev != "" -> repoRepoURL != ""; assert repoRepoRev != "" -> repoRepoURL != "";
@ -51,6 +52,9 @@ in stdenv.mkDerivation {
# Path must be absolute (e.g. for GnuPG: ~/.repoconfig/gnupg/pubring.kbx) # Path must be absolute (e.g. for GnuPG: ~/.repoconfig/gnupg/pubring.kbx)
export HOME="$(pwd)" export HOME="$(pwd)"
mkdir $out
cd $out
mkdir .repo mkdir .repo
${optionalString (local_manifests != []) '' ${optionalString (local_manifests != []) ''
mkdir .repo/local_manifests mkdir .repo/local_manifests
@ -61,6 +65,13 @@ in stdenv.mkDerivation {
repo init ${concatStringsSep " " repoInitFlags} repo init ${concatStringsSep " " repoInitFlags}
repo sync --jobs=$NIX_BUILD_CORES --current-branch repo sync --jobs=$NIX_BUILD_CORES --current-branch
${optionalString (!createMirror) "rm -rf $out/.repo"}
# TODO: The git-index files (and probably the files in .repo as well) have
# different contents each time and will therefore change the final hash
# (i.e. creating a mirror probably won't work).
${optionalString (!createMirror) ''
rm -rf .repo
find -type d -name '.git' -prune -exec rm -rf {} +
''}
''; '';
} }