Skip to content

Commit

Permalink
demo: use fakeroot to avoid needing sudo
Browse files Browse the repository at this point in the history
    ==================== Test output for //:mount_tmpfs_without_fakeroot:
    ++ mkdir -p /tmp/target
    ++ mount -t tmpfs none /tmp/target
    mount: /tmp/target: must be superuser to use mount.

    ==================== Test output for //:mount_tmpfs_fakeroot:
    ++ mkdir -p /tmp/target
    ++ mount -t tmpfs none /tmp/target
    ++ findmnt /tmp/target
    TARGET      SOURCE FSTYPE OPTIONS
    /tmp/target none   tmpfs  rw,relatime,uid=1000,gid=1000,inode64
  • Loading branch information
wade-arista committed Nov 28, 2024
1 parent 8ce2e76 commit ffca16f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

test --announce_rc
common --lockfile_mode=off
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.0.0rc6
26 changes: 21 additions & 5 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
v = """
#!/bin/bash
set -uxeo pipefail
mkdir -p /tmp/target
mount -t tmpfs none /tmp/target
findmnt /tmp/target
"""

genrule(
name = "test_sh",
outs = ["test.sh"],
cmd = "touch $@",
name = "create_script",
srcs = [],
outs = ["mount_tmpfs.sh"],
cmd = "echo \"{}\" > $@".format(v),
executable = True,
)

sh_test(
name = "mount_tmpfs_fakeroot",
srcs = ["mount_tmpfs.sh"],
tags = ["requires-fakeroot"],
)

sh_test(
name = "test",
srcs = ["test.sh"],
name = "mount_tmpfs_without_fakeroot",
srcs = ["mount_tmpfs.sh"],
)

0 comments on commit ffca16f

Please sign in to comment.