Skip to content

Commit

Permalink
fetchRepoProject: Fetch into $out and make it deterministic
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
primeos committed Sep 17, 2017
1 parent 7db2916 commit 018a5ae
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkgs/build-support/fetchrepoproject/default.nix
@@ -1,8 +1,9 @@
{ stdenv, gitRepo, cacert, copyPathsToStore }:

{ name, manifest, rev ? "HEAD", sha256
# Optional parameters:
, repoRepoURL ? "", repoRepoRev ? "", referenceDir ? ""
, localManifests ? [], createMirror ? false, useArchive ? !createMirror
, localManifests ? [], createMirror ? false, useArchive ? false
}:

assert repoRepoRev != "" -> repoRepoURL != "";
Expand Down Expand Up @@ -51,6 +52,9 @@ in stdenv.mkDerivation {
# Path must be absolute (e.g. for GnuPG: ~/.repoconfig/gnupg/pubring.kbx)
export HOME="$(pwd)"
mkdir $out
cd $out
mkdir .repo
${optionalString (local_manifests != []) ''
mkdir .repo/local_manifests
Expand All @@ -61,6 +65,13 @@ in stdenv.mkDerivation {
repo init ${concatStringsSep " " repoInitFlags}
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 {} +
''}
'';
}

0 comments on commit 018a5ae

Please sign in to comment.