flatpak / flatpak-builder

Tool to build flatpaks from source
GNU Lesser General Public License v2.1
139 stars 91 forks source link

--build-shell: file failed to open for writing #346

Open roipoussiere opened 4 years ago

roipoussiere commented 4 years ago

I want to test a flatpak module after its successfully build. But when I do a flatpak-builder cadquery3 org.foo.bar.yaml --build-shell=my_module, I get this error:

CMake Error at CMakeLists.txt:894 (file):
  file failed to open for writing (Read-only file system):

    /app/bin/custom.sh

So I tried to add:

    ensure-writable:
      - /app/bin/custom.sh

and also:

    post-install:
      - chmod u+w /app/bin/custom.sh

...but same error for both solutions. Why?

Platform

roipoussiere commented 4 years ago

I can not reproduce this, maybe it was a caching problem.

I will re-open this if necessary.

roipoussiere commented 4 years ago

Ok, I can reproduce the issue (and this time I deleted the flatpak folder before building again to be sure).

To be clear, flatpak-builder opencascade com.opencascade.occt.yaml --force-clean builds the flatpak successfully;

But flatpak-builder opencascade com.opencascade.occt.yaml --build-shell=opencascade fails with the error described above.

You can take a look the corresponding lines in the work-in-progress manifest.

I need to access the console in the sandbox in order to debug my application (which strangely works with flatpak-builder --run but not with flatpak --run).

dumblob commented 4 years ago

Would passing -v to flatpak-builder help a bit more? I found similar issue: https://github.com/flatpak/flatpak/issues/546 .

roipoussiere commented 4 years ago

Here is the fulll stacktrace for flatpak-builder --verbose .app com.opencascade.occt.yaml --build-shell=opencascade:

click to expand
FB: Running: git config --get user.email
FB: Running: git config --get user.name
FB: Running: flatpak info --arch=x86_64 --show-commit org.freedesktop.Sdk 19.08
FB: Running: flatpak info --show-location --arch=x86_64 org.freedesktop.Sdk 19.08
FB: Running: flatpak info --arch=x86_64 --show-commit org.freedesktop.Platform 19.08
Downloading sources
FB: starting: rofiles-fuse /home/nath/divers/flatpaks/com.opencascade.occt/.app /home/nath/divers/flatpaks/com.opencascade.occt/.flatpak-builder/rofiles/rofiles-fO4uWB
========================================================================
Building module opencascade in /home/nath/divers/flatpaks/com.opencascade.occt/.flatpak-builder/build/opencascade-1
========================================================================
FB: Running: tar xf /home/nath/divers/flatpaks/com.opencascade.occt/.flatpak-builder/downloads/9aadceedd2062dfc1af071a26e66186e/opencascade-7.4.0.tgz --no-same-owner --strip-components=1 -z
FB: Running: flatpak build --die-with-parent --env=FLATPAK_BUILDER_BUILDDIR=/run/build/opencascade --nofilesystem=host --filesystem=/home/nath/divers/flatpaks/com.opencascade.occt/.flatpak-builder/build/opencascade-1 --bind-mount=/run/build/opencascade=/home/nath/divers/flatpaks/com.opencascade.occt/.flatpak-builder/build/opencascade-1 --build-dir=/run/build/opencascade --bind-mount=/run/ccache=/home/nath/divers/flatpaks/com.opencascade.occt/.flatpak-builder/ccache --env=SOURCE_DATE_EPOCH=1588962223 '--env=CFLAGS=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' '--env=CXXFLAGS=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' '--env=LDFLAGS=-L/app/lib -Wl,-z,relro,-z,now -Wl,--as-needed' --env=CCACHE_DIR=/run/ccache/disabled --env=PATH=/app/bin:/usr/bin --env=LD_LIBRARY_PATH=/app/lib --env=PKG_CONFIG_PATH=/app/lib/pkgconfig:/app/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig --env=FLATPAK_BUILDER_N_JOBS=8 /home/nath/divers/flatpaks/com.opencascade.occt/.flatpak-builder/rofiles/rofiles-fO4uWB cmake '-DCMAKE_INSTALL_PREFIX:PATH='\''/app'\''' -G 'Unix Makefiles' . -DINSTALL_DIR=/app -DINSTALL_TEST_CASES=1
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Info. Detecting doxygen
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) (Required is at least version "1.8.4")
-- Info: TCL is used by OCCT
-- Found Tclsh: /app/bin/tclsh8.6 (found version "8.6") 
-- Info: TK is used by OCCT
-- Info: Freetype is used by OCCT
-- Found Freetype: /usr/lib/x86_64-linux-gnu/libfreetype.so (found version "2.10.1") 
-- Info: TKIVtk and TKIVtkDraw toolkits excluded due to VTK usage is disabled
-- Info: The directories of 3rdparty headers: 
    /app/include
    /usr/include/freetype2
-- Info: The directories of 3rdparty libraries: 
    /app/lib
    /usr/lib/x86_64-linux-gnu
-- 
Info: (20:23:43) Start collecting all OCCT header files into /run/build/opencascade/inc ...
-- Info: (20:23:43) Compare FILES with files in package directories...
-- Info: (20:23:43) Create header-links in inc folder...
-- Info: (20:23:43) Checking headers in inc folder...
-- Info: (20:23:43) End the collecting
CMake Error at CMakeLists.txt:894 (file):
  file failed to open for writing (Read-only file system):

    /app/bin/custom.sh

-- Info: (20:23:43) OCCT toolkits processed
-- Info: (20:23:43) OCCT configuration files prepared
-- Configuring incomplete, errors occurred!
See also "/run/build/opencascade/CMakeFiles/CMakeOutput.log".
Failed to setup module: module opencascade: Child process exited with code 1
FB: unmounting rofiles-fuse /home/nath/divers/flatpaks/com.opencascade.occt/.flatpak-builder/rofiles/rofiles-fO4uWB

I don't know if it's related, but the problem that makes me want to use the --build-shell option is that my application seems to look at some files in /usr/share instead of /app/share when I execute the installed app, but not if I execute it if flatpak-builder --run.

ferdnyc commented 9 months ago

@roipoussiere

I know this is a very old issue, but...

It's a bit hard to follow all of those crazy-long, unwrapped lines. (Not your fault. [insert standard rant about GitHub not supporting any sort of wrapping for comment <PRE> blocks].)

But, the behavior you were seeing sounds correct to me, because AFAICT the build script was trying to write to the INSTALL directory during build time. (Actually, not even build time, earlier than that, when CMake was still configuring the build.) I'd be very surprised if Flatpak permitted that.

The right thing to do there would be to generate the custom.sh in the build directory, and then install(FILES custom.sh DESTINATION ${CMAKE_INSTALL_BINDIR}) so that the file is copied into the install dir later, during cmake install.

Writing to the install directory during the build/pre-build process is no bueno, it's an attempt to break out of the build sandbox. Which fails because, AIUI, Flatpak keeps the install directory (/app) read-only during the build, and only makes it writable at install time. (The end of your log even shows it unmounting a readonly fuse filesystem, no doubt the prospective /app directory.)

Anyway, I'm sure it's long past the point where this would be remotely relevant, but I happened to stumble across this issue just now.