# syntax=docker/dockerfile:1 # # 7-Zip 26.04 (Igor Pavlov; GNU LGPL 2.1, some files BSD) compiled to # WebAssembly for johnmcm.com's Archive Toolkit: the 7zz command-line program # (Bundles/Alone2), built single-threaded (ST_MODE) and WITHOUT the RAR code # (DISABLE_RAR), so no file under the unRAR licence restriction is in it, # with one small patch (patches/choose-partition.patch). # It adds MSI, DMG, WIM, VHD/VHDX, VMDK, QCOW2, disk images and filesystems, # installer EXEs, RPM, DEB, XAR and more; RAR stays with libarchive. # # Each run is a fresh instance, as from a command line: the archive is # mounted read-only with WORKERFS (read lazily, so a multi-GB disk image is # never copied into memory) and what is extracted is written to memory. # The Emscripten image is pinned by digest and the source tarball by # SHA-256; the tarball, these files and the build notes are published at # /source/7zip/. # # ./build.ps1 (or) docker build --target export --output type=local,dest=dist . ARG EMSDK_IMAGE=emscripten/emsdk:6.0.10@sha256:e077d54e2b8970575ebc4f185ac1de0b95c05f2b266134d4ba27449af7aebf65 FROM ${EMSDK_IMAGE} AS build ARG SZ_VERSION=26.04 ARG SZ_NODOT=2604 ARG SZ_SHA256=9691944c0fe0d01bb49373a704fb983fd33bc98b1738695179dfbf99ac1734f6 WORKDIR /src RUN curl -fsSL -o 7z-src.tar.xz https://github.com/ip7z/7zip/releases/download/${SZ_VERSION}/7z${SZ_NODOT}-src.tar.xz \ && echo "${SZ_SHA256} 7z-src.tar.xz" | sha256sum -c - \ && mkdir 7z && tar xJf 7z-src.tar.xz -C 7z # One patch (patches/choose-partition.patch): JOHNMCM_PARTITION= opens # partition n of a disk with several, as 7-Zip already does when there is one. # The two files are made LF first, so line endings never decide whether it applies. COPY patches/ /patches/ RUN cd 7z \ && sed -i 's/\r$//' CPP/7zip/Archive/GptHandler.cpp CPP/7zip/Archive/MbrHandler.cpp \ && sed 's/\r$//' /patches/choose-partition.patch | patch -p1 ARG LINK="-sMODULARIZE=1 -sEXPORT_ES6=1 -sEXPORT_NAME=create7z -sENVIRONMENT=worker,node \ -fwasm-exceptions -sINVOKE_RUN=0 -sEXIT_RUNTIME=1 -sALLOW_MEMORY_GROWTH=1 -sMAXIMUM_MEMORY=4294967296 \ -sSTACK_SIZE=2097152 -sDYNAMIC_EXECUTION=0 -sFORCE_FILESYSTEM=1 -lworkerfs.js \ -sINCOMING_MODULE_JS_API=print,printErr,locateFile,wasmBinary,instantiateWasm,preRun \ -sEXPORTED_RUNTIME_METHODS=callMain,FS,WORKERFS,ENV" # The one call Emscripten lacks (src/sysinfo.c). COPY src/sysinfo.c /src/sysinfo.c RUN emcc -O2 -c /src/sysinfo.c -o /src/sysinfo.o WORKDIR /src/7z/CPP/7zip/Bundles/Alone2 RUN emmake make -f makefile.gcc -j"$(nproc)" \ CC="emcc -fwasm-exceptions" CXX="em++ -fwasm-exceptions" O=b/em PROG=7zz.mjs STATIC_TARGET= \ DISABLE_RAR=1 ST_MODE=1 \ CFLAGS_WARN_WALL="-Wall -Wno-everything" LIB2="/src/sysinfo.o" MY_LIBS="${LINK}" \ && ls -l b/em/7zz.mjs b/em/7zz.wasm \ && ! ls b/em/Rar*.o 2>/dev/null RUN mkdir -p /out \ && cp b/em/7zz.mjs b/em/7zz.wasm /out/ \ && cp /src/7z/DOC/License.txt /out/License.txt \ && cp /src/7z-src.tar.xz /out/7z${SZ_NODOT}-src.tar.xz \ && sha256sum /out/* FROM scratch AS export COPY --from=build /out/ /