Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make: pkg: introduce git-cache #5112

Merged
merged 2 commits into from
Mar 21, 2016
Merged

Conversation

kaspar030
Copy link
Contributor

Currently, every package get's checked out from remote repositories on every build, sometimes multiple times.

This PR adds support for git-cache [1], transparently using a local copy of the requested SHA1, or reverting to the remote location if the cache doesn't exist, fails, or doesn't have the commit.

This should not affect anything unless git-cache is actually used.

In order to make use of the cache, install the git-cache binary into path.
Currently, repositories have to be added to the cache manually by executing
# git cache init once per user, then # git cache add <name> <url> once per repository.

git cache update fetches new commits from cached remote repos.

[1] https://github.com/kaspar030/git-cache

@kaspar030 kaspar030 added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: build system Area: Build system Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Area: CI Area: Continuous Integration of RIOT components labels Mar 20, 2016
@kaspar030
Copy link
Contributor Author

One thing I don't know how to handle nicely is the git exec path. git picks up anything starting with "git-" as command, so in order for the build system to pick up git-cache, it has to be in PATH or GIT_EXEC_PATH has to point to it. I opted for the latter, but then git cannot find it's "https" remote helper, so currently I'm unsetting GIT_EXEC_PATH within git-cache, which seems hacky.
The other option would be to change PATH, which I somehow don't like either.
Ideas?

@kaspar030 kaspar030 added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Mar 20, 2016
@kaspar030
Copy link
Contributor Author

An open question would be if the build should still fail if the cache cannot be updated, as that might mean that a remote repository is actually dead.

@kaspar030
Copy link
Contributor Author

One thing I don't know how to handle nicely is the git exec path

Seems like in docker things are even more complicated.

@kaspar030 kaspar030 removed the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Mar 20, 2016
@kaspar030
Copy link
Contributor Author

Ok, modifying PATH is the only way I see.

@kaspar030
Copy link
Contributor Author

  • squashed WIP commits

@OlegHahm
Copy link
Member

Currently, every package get's checked out from remote repositories on every build, sometimes multiple times.

For the CI, you mean?

@@ -20,6 +20,10 @@ RIOTPKG ?= $(RIOTBASE)/pkg
RIOTPROJECT ?= $(shell git rev-parse --show-toplevel 2>/dev/null || pwd)
RIOTPROJECT := $(abspath $(RIOTPROJECT))

# add git tools directory to PATH so git can pick it up
PATH:=$(PATH):$(RIOTBASE)/dist/tools/git
export PATH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I would like it if a build script would modify my PATH variable. Maybe you can store the old value and restore it after the build?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: Wouldn't this line append the additional path on every run?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The export is only valid for sub-processes if make.

-----Original Message-----
From: Oleg Hahm notifications@github.com
To: RIOT-OS/RIOT RIOT@noreply.github.com
Cc: Kaspar Schleiser kaspar@schleiser.de
Sent: So., 20 März 2016 14:12
Subject: Re: [RIOT] make: pkg: introduce git-cache (#5112)

@@ -20,6 +20,10 @@ RIOTPKG ?= $(RIOTBASE)/pkg
RIOTPROJECT ?= $(shell git rev-parse --show-toplevel 2>/dev/null || pwd)
RIOTPROJECT := $(abspath $(RIOTPROJECT))

+# add git tools directory to PATH so git can pick it up
+PATH:=$(PATH):$(RIOTBASE)/dist/tools/git
+export PATH

I'm not sure I would like it if a build script would modify my PATH variable. Maybe you can store the old value and restore it after the build?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/5112/files/8b363905f6854a7f841f884bf5b6e71c4010782a#r56764211

@OlegHahm
Copy link
Member

Ok, modifying PATH is the only way I see.

Couldn't you replace the calls with absolute paths?

@kaspar030
Copy link
Contributor Author

yep.

-----Original Message-----
From: Oleg Hahm notifications@github.com
To: RIOT-OS/RIOT RIOT@noreply.github.com
Cc: Kaspar Schleiser kaspar@schleiser.de
Sent: So., 20 März 2016 14:10
Subject: Re: [RIOT] make: pkg: introduce git-cache (#5112)

Currently, every package get's checked out from remote repositories on every build, sometimes multiple times.

For the CI, you mean?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#5112 (comment)

@kaspar030
Copy link
Contributor Author

Couldn't you replace the calls with absolute paths?

Yeah, excellent idea!

@kaspar030 kaspar030 assigned OlegHahm and unassigned jnohlgard Mar 20, 2016
@kaspar030
Copy link
Contributor Author

@OlegHahm Better? Never have failed builds because of unreachable remote repositories anymore! :)

@OlegHahm
Copy link
Member

👍

@kaspar030 kaspar030 removed the Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR label Mar 20, 2016
@kaspar030
Copy link
Contributor Author

  • squashed

git clone "${REMOTE}" "${TARGET_PATH}"
git -C "${TARGET_PATH}" checkout $SHA1
fi
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set +ex

@OlegHahm
Copy link
Member

@kaspar030, it's not clear to me how I can test this locally. I tried with the microcoap_server example: building it, then disconnect my computer from the network and try to build again, but it failed. I would have assumed that the git-cache clone command would handle this.

@kaspar030
Copy link
Contributor Author

@OlegHahm did you see the instructions in the beginning of the pr?

  1. put git-cache in path
  2. run 'git cache init'
  3. run 'it cache add microcoap microcoap url
  4. run 'git cache update'
  5. can be skipped if you call the script with its full path.

@OlegHahm
Copy link
Member

No I didn't. From looking at the diff it was clear to me if this information was still up to date and I couldn't figure if I would have to run this from pkg or $RIOTBASE.

run 'git cache add microcoap

Isn't there the URL parameter missing?

@OlegHahm
Copy link
Member

Okay, got it. Can you add these instructions to the README? ACK once this is addressed.

@kaspar030
Copy link
Contributor Author

  • addressed comments, immediately squashed

OlegHahm added a commit that referenced this pull request Mar 21, 2016
@OlegHahm OlegHahm merged commit 16a3f13 into RIOT-OS:master Mar 21, 2016
@kaspar030 kaspar030 deleted the use_git_cache branch February 7, 2017 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Area: CI Area: Continuous Integration of RIOT components CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants