Skip to content

Commit

Permalink
mount symlink dirs in snapshot as host volumes
Browse files Browse the repository at this point in the history
Docker simply doesn't handle symlinks in host volumes properly. The
symlink target is essentially lost when host mounting the directory that
contains the symlink. So, this patch manually mounts all symlinks in the
ghw static snapshot as separate host mounts pointing to the original
target directory.

Nasty Bash and sed ensued.

Issue #758
  • Loading branch information
jaypipes committed Mar 8, 2020
1 parent c179162 commit f8ffd4d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion hack/run-against-snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ echo "building Docker image with ghwc ..."

docker build -f $root_dir/Dockerfile -t $ghwc_image_name:$IMAGE_VERSION $root_dir

echo "gathering symlink dirs in extracted snapshot to host volume mount ..."

linkdirs=""
for dirlink in `find -L $snap_tmp_dir -xtype l`; do
sourcelink=$( readlink $dirlink )
sourcelink=$( echo $sourcelink | sed "s/\/tmp\/ghw-snapshot[[:digit:]]\+/$tmp_snap_dir/")
target=$( echo "$dirlink" | sed "s/\/tmp\/ghw-snap-test-.../\/host/")
linkdirs+=" --mount type=bind,source=$sourcelink,destination=$target"
done

echo "running ghwc Docker image with volume mount to snapshot dir ..."

docker run -it -v $snap_tmp_dir:/host -e GHW_CHROOT="/host" $ghwc_image_name:$IMAGE_VERSION
docker run -it -v $snap_tmp_dir:/host $linkdirs -e GHW_CHROOT="/host" $ghwc_image_name:$IMAGE_VERSION

0 comments on commit f8ffd4d

Please sign in to comment.