Skip to content
Permalink
Browse files
build: actually mount source dir read-only
From https://unix.stackexchange.com/a/128388/181634:

To achieve the desired result one needs to run two commands […]:

  mount SRC DST -o bind
  mount DST -o remount,ro,bind
  • Loading branch information
stapelberg committed Feb 13, 2020
1 parent 9a794f4 commit a0041ffcb523ad6f4cab2c2002594c25d02cdffb
Showing 15 changed files with 154 additions and 92 deletions.
@@ -1249,6 +1249,9 @@ func (b *buildctx) build() (*pb.Meta, error) {
if err := syscall.Mount(b.SourceDir, src, "none", syscall.MS_BIND|syscall.MS_RDONLY, ""); err != nil {
return nil, xerrors.Errorf("bind mount %s %s: %v", b.SourceDir, src, err)
}
if err := syscall.Mount("", src, "", syscall.MS_REMOUNT|syscall.MS_BIND|syscall.MS_RDONLY, ""); err != nil {
return nil, xerrors.Errorf("bind remount read-only %s %s: %v", b.SourceDir, src, err)
}
b.SourceDir = strings.TrimPrefix(src, b.ChrootDir)

wrappersSrc := filepath.Join(b.PkgDir, "wrappers")
@@ -8,10 +8,18 @@ import (
)

func (b *buildctx) buildcmake(opts *pb.CMakeBuilder, env []string) (newSteps []*pb.BuildStep, newEnv []string, _ error) {
steps := [][]string{
dir := "${DISTRI_SOURCEDIR}"
var steps [][]string
if opts.GetCopyToBuilddir() {
dir = "."
steps = [][]string{
[]string{"cp", "-T", "-ar", "${DISTRI_SOURCEDIR}/", "."},
}
}
steps = append(steps, [][]string{
append([]string{
"/bin/cmake",
"${DISTRI_SOURCEDIR}",
dir,
"-DCMAKE_INSTALL_PREFIX:PATH=${DISTRI_PREFIX}",
"-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON",
"-G", "Ninja",
@@ -25,6 +33,6 @@ func (b *buildctx) buildcmake(opts *pb.CMakeBuilder, env []string) (newSteps []*
"-c",
"DESTDIR=${DISTRI_DESTDIR} ninja -v -j " + strconv.Itoa(runtime.NumCPU()) + " install",
},
}
}...)
return stepsToProto(steps), env, nil
}

Some generated files are not rendered by default. Learn more.

@@ -32,6 +32,11 @@ message CMakeBuilder {
// Additional flag to pass to cmake(1), e.g.:
// extra_cmake_flag: "-DKICAD_SCRIPTING_WXPYTHON_PHOENIX:BOOL=true"
repeated string extra_cmake_flag = 1;

// Enable if this package does not support building from a separate directory
// (sometimes called “out-of-tree build”). A bug should be reported with the
// package upstream.
optional bool copy_to_builddir = 2;
}

message MesonBuilder {
@@ -2,7 +2,9 @@ source: "https://ftp.gnu.org/gnu/bc/bc-1.07.1.tar.gz"
hash: "62adfca89b0a1c0164c2cdca59ca210c1d44c3ffc46daf9931cf4942664cb02a"
version: "1.07.1-3"

cbuilder: {}
cbuilder: {
copy_to_builddir: true # modifies source
}

# build dependencies:
dep: "ed"
@@ -3,6 +3,7 @@ hash: "1cf4fc240cd77c25309d15e18593789c8dbfba5c2b44d8f77c886542300fd32c"
version: "26.1-11"

cbuilder: {
copy_to_builddir: true # modifies source
extra_configure_flag: "--with-gnutls=no" # TODO: why doesn’t configure locate gnutls?
extra_configure_flag: "--with-x-toolkit=gtk3"
}
@@ -29,20 +29,32 @@ build_step: {
build_step: {
argv: "/bin/sh"
argv: "-c"
argv: "meson --prefix=${DISTRI_PREFIX} . ${DISTRI_SOURCEDIR} -Dinstalled_tests=false -Dman=false"
argv: "cp -T -ar ${DISTRI_SOURCEDIR}/ ."
}

build_step: {
argv: "/bin/sh"
argv: "-c"
argv: "mkdir build"
}

build_step: {
argv: "/bin/sh"
argv: "-c"
argv: "meson --prefix=${DISTRI_PREFIX} build . -Dinstalled_tests=false -Dman=false"
}

# kludge: the LD_LIBRARY_PATH change is required because we patched rpath handling out of meson.
build_step: {
argv: "/bin/sh"
argv: "-c"
argv: "LD_LIBRARY_PATH=$PWD/gdk-pixbuf:$PWD/gobject:$PWD/glib:$LD_LIBRARY_PATH ninja -j ${DISTRI_JOBS} -v"
argv: "(cd build && LD_LIBRARY_PATH=$PWD/gdk-pixbuf:$PWD/gobject:$PWD/glib:$LD_LIBRARY_PATH ninja -j ${DISTRI_JOBS} -v)"
}

build_step: {
argv: "/bin/sh"
argv: "-c"
argv: "DESTDIR=${DISTRI_DESTDIR} ninja -j ${DISTRI_JOBS} -v install"
argv: "(cd build && DESTDIR=${DISTRI_DESTDIR} ninja -j ${DISTRI_JOBS} -v install)"
}

build_step: {
@@ -12,9 +12,15 @@ dep: "libglvnd"

# Debian/Ubuntu/Mint: `$ sudo apt-get install build-essential libxmu-dev libxi-dev libgl-dev libosmesa-dev`

build_step: {
argv: "/bin/sh"
argv: "-c"
argv: "cp -T -ar ${DISTRI_SOURCEDIR}/ ."
}

build_step: {
argv: "/bin/cmake"
argv: "${DISTRI_SOURCEDIR}/build/cmake"
argv: "build/cmake"
argv: "-DCMAKE_INSTALL_PREFIX:PATH=${DISTRI_PREFIX}"
argv: "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
argv: "-DOPENGL_opengl_LIBRARY=/ro/${DISTRI_RESOLVE:libglvnd}/out/lib/libOpenGL.so"
@@ -8,7 +8,13 @@ cbuilder: {}
dep: "perl"

build_step: {
argv: "${DISTRI_SOURCEDIR}/configure"
argv: "/bin/sh"
argv: "-c"
argv: "cp -T -ar ${DISTRI_SOURCEDIR}/ ."
}

build_step: {
argv: "./configure"
argv: "--prefix=${DISTRI_PREFIX}"
}

@@ -2,7 +2,9 @@ source: "https://s3.amazonaws.com/json-c_releases/releases/json-c-0.13.1.tar.gz"
hash: "b87e608d4d3f7bfdd36ef78d56d53c74e66ab278d318b71e6002a369d36f4873"
version: "0.13.1-4"

cbuilder: {}
cbuilder: {
copy_to_builddir: true # modifies source
}

# build dependencies:
dep: "autoconf"
@@ -6,6 +6,7 @@ cherry_pick: "cmake.patch"
cherry_pick: "cmakewxwidgets.patch"

cmakebuilder: {
copy_to_builddir: true # modifies source
extra_cmake_flag: "-DOPENGL_gl_LIBRARY=/ro/${DISTRI_RESOLVE:mesa}/out/lib"
extra_cmake_flag: "-DOPENGL_glu_LIBRARY=/ro/${DISTRI_RESOLVE:glu}/out/lib"
extra_cmake_flag: "-DGLEW_LIBRARY=/ro/${DISTRI_RESOLVE:glew}/out/lib64"
@@ -2,22 +2,28 @@ source: "https://mirrors.edge.kernel.org/pub/linux/libs/security/linux-privs/lib
hash: "693c8ac51e983ee678205571ef272439d83afe62dd8e424ea14ad9790bc35162"
version: "2.25-3"

cbuilder: {}
cbuilder: {
copy_to_builddir: true # modifies source
}

# build dependencies:
dep: "perl"
dep: "gperf" # NOTE that libcap fails silently without gperf :(

build_step: {
argv: "/bin/sh"
argv: "-c"
argv: "cp -T -ar ${DISTRI_SOURCEDIR}/ ."
}

build_step: {
argv: "make"
argv: "-C"
argv: "${DISTRI_SOURCEDIR}"
argv: "-j${DISTRI_JOBS}"
argv: "prefix=${DISTRI_PREFIX}"
}

build_step: {
argv: "/bin/sh"
argv: "-c"
argv: "DESTDIR=${DISTRI_DESTDIR} make -C ${DISTRI_SOURCEDIR} install prefix=${DISTRI_PREFIX} lib=lib RAISE_SETFCAP=no"
argv: "DESTDIR=${DISTRI_DESTDIR} make install prefix=${DISTRI_PREFIX} lib=lib RAISE_SETFCAP=no"
}
@@ -18,18 +18,20 @@ dep: "perl"
dep: "gzip"
dep: "kmod"

build_step: {
argv: "/bin/sh"
argv: "-c"
argv: "cp -T -ar ${DISTRI_SOURCEDIR}/ ."
}

build_step: {
argv: "make"
argv: "-C"
argv: "${DISTRI_SOURCEDIR}"
argv: "olddefconfig"
argv: "ARCH=i386"
}

build_step: {
argv: "make"
argv: "-C"
argv: "${DISTRI_SOURCEDIR}"
argv: "headers_install"
argv: "INSTALL_HDR_PATH=${DISTRI_DESTDIR}/${DISTRI_PREFIX}"
argv: "ARCH=i386"

0 comments on commit a0041ff

Please sign in to comment.