Skip to content

Commit ed3bd76

Browse files
committed
docker: fix fatal: unsafe repository
1 parent b0f4f5e commit ed3bd76

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

common.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@
4949
consts['p9_dir'] = os.path.join(consts['data_dir'], '9p')
5050
consts['gem5_non_default_source_root_dir'] = os.path.join(consts['data_dir'], 'gem5')
5151
if consts['in_docker']:
52+
# fatal: unsafe repository ('/root/lkmc' is owned by someone else)
53+
# Fuck these error checks, let me shoot my feet in peace.
54+
# The best solution would be to actually get Docker to mount
55+
# the current diretory as root. But I've never been able to do that:
56+
# * https://stackoverflow.com/questions/51973179/docker-mount-volumes-as-root
57+
# * https://unix.stackexchange.com/questions/523492/how-to-mount-files-as-specific-user-when-using-docker-namespace-remapping
58+
# * https://stackoverflow.com/questions/35291520/docker-and-userns-remap-how-to-manage-volume-permissions-to-share-data-betwee
59+
# So for now we see as owner e.g. 1000:1000 on the volume, and root:root on /.
60+
# '*' to ignore all was added on Git 2.36... Without that we would need to add every single submodule to the list.
61+
# * https://stackoverflow.com/questions/71901632/fatal-unsafe-repository-home-repon-is-owned-by-someone-else
62+
# * https://stackoverflow.com/questions/71849415/i-cannot-add-the-parent-directory-to-safe-directory-in-git/71904131#71904131
63+
# * https://www.reddit.com/r/docker/comments/o8bnft/is_it_possible_to_mount_files_with_readwrite/
64+
subprocess.check_output(['git', 'config', '--global', '--add', 'safe.directory', '*'])
5265
consts['out_dir'] = os.path.join(consts['root_dir'], 'out.docker')
5366
else:
5467
consts['out_dir'] = os.path.join(consts['root_dir'], 'out')

setup

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
#!/usr/bin/env bash
22
# Minimum requirements to run ./build --download-dependencies
3+
set -ex
34
if [ $# -eq 1 ]; then
45
y=-y
56
else
67
y=
78
fi
89
if [ -f /.dockerenv ]; then
910
sudo=
11+
export DEBIAN_FRONTEND=noninteractive
1012
else
1113
sudo=sudo
1214
fi
1315
$sudo apt-get update
16+
if [ -f /.dockerenv ]; then
17+
apt install -y software-properties-common
18+
add-apt-repository -y ppa:git-core/ppa
19+
$sudo apt update
20+
git=git=1:2.36.0-0ppa1~ubuntu20.04.1
21+
else
22+
git=git
23+
fi
1424
$sudo apt-get install $y \
15-
git \
25+
$git \
1626
python3 \
1727
python3-pip \
1828
python3-distutils \

0 commit comments

Comments
 (0)