-
Notifications
You must be signed in to change notification settings - Fork 13
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
Abuild keygen fixes #52
Open
clandmeter
wants to merge
2
commits into
alpinelinux:master
Choose a base branch
from
clandmeter:abuild-keygen-fixes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,10 +58,13 @@ else | |
esac | ||
fi | ||
|
||
## check $DABUILD_PACKAGES is a writable directory | ||
ABUILD_PACKAGES=${DABUILD_PACKAGES:-${PWD%/aports/*}/packages/${ABUILD_VERSION}} | ||
|
||
mkdir -p $ABUILD_PACKAGES | ||
# docker will create mount points as root if not available so create them first | ||
# use uid 1000 as this is the uid of the builder user in the container | ||
install -d -o 1000 -g 1000 "$ABUILD_PACKAGES" "$HOME"/.abuild | ||
|
||
## check $DABUILD_PACKAGES is a writable directory | ||
if [ ! \( -d "$ABUILD_PACKAGES" -a -w "$ABUILD_PACKAGES" \) ]; then | ||
die "Error: invalid or unwritable packages directory specified!" \ | ||
"ABUILD_PACKAGES = '$ABUILD_PACKAGES'" \ | ||
|
@@ -81,6 +84,11 @@ if [ -w "/var/cache/distfiles" ]; then | |
ABUILD_VOLUMES="$ABUILD_VOLUMES -v /var/cache/distfiles:/var/cache/distfiles" | ||
fi | ||
|
||
# pass over gitconfig for abuild-keygen | ||
if [ -f "$HOME/.gitconfig" ]; then | ||
ABUILD_VOLUMES="$ABUILD_VOLUMES -v $HOME/.gitconfig:/home/builder/.gitconfig" | ||
fi | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM. (Didn't realise |
||
if [ "$DABUILD_CACHE" = "true" ]; then | ||
for v in %%ABUILD_VOLUMES%% ; do | ||
vol=abuild-$ABUILD_VERSION-$DABUILD_ARCH-${v//\//_} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops -- thanks for catching that I don't check
"$HOME/".abuild
exists.Not sure about creating them with [UG]ID=1000 though. Maybe better to invoke
docker run ...
below with--user "$(id -u)":"$(id -g)"
? (I'm only on D4M here and it looks like some magic is being done to map through to my host user account in either case, so can't easily test.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is setting explicitly 1000 a problem? the first user is always assigned 1000?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, i was thinking only from a point of view from the container, its probably not smart to set 1000 if the current host user has a different uid (which is possible). I guess we need to rethink how to manage those bind mounts or instead use docker volumes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes-- mapping between the uid spaces in container and on host is always a fiddle.
AIUI, in general there are uids and gids defined in the container, some (typically, most) with corresponding user and group names; and there are uids and gids similarly on the host. None of these need to overlap. When the image is built, I create the
builder(1000):builder(1000)
user and that will be the user by which commands are executed by default.At this point, the script is running on the host so should (IMO) be creating files/directories using the default host's uid:gid (ie., no
-o
or-g
switches toinstall
).When we
docker run
then ideally we would create files using theuid:gid
of the user on the host. But the CLI mechanism for doing that (AIUI) is to use the numeric IDs by passing in--user $(id -u):$(id -g)
. Unfortunately, that may prevent use ofsudo
inside the container because there is a good chance that the uid that ends up being used will not exist in/etc/passwd
in the container and sosudo
will refuse to run.Perhaps a compromise would be to leave the uid in the container as-is (ie.,
builder(1000)
) but to add something like--group-add $(id -G | sed 's/ / --group-add /g')"
to thedocker run ...
command line -- assuming directories are created withg+w
then at least file creation from inside the container will work while still letting us usesudo
inside the container...?(Unfortunately I can't test any of this as D4M does magic to make the mappings work behind my back -- on Mac/Windows it's extra complicated because there are effectively three layers of namespace involved: the actual host (Mac/Windows), the Linux VM, container.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Or we could just give up using bind mounts at all, and use named volumes for everything. But extracting built packages becomes trickier then. Maybe that doesn't matter though?)