Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making get.sh work on alpine #11

Open
VictorKoenders opened this issue May 14, 2021 · 2 comments
Open

Making get.sh work on alpine #11

VictorKoenders opened this issue May 14, 2021 · 2 comments

Comments

@VictorKoenders
Copy link

VictorKoenders commented May 14, 2021

I'm trying to set up msvc-wine-rust in an alpine container. This is mostly documentation on what I needed to go to get it to work.

When it gets to the sha256sum --quiet --check dl.sha256 || exit 2 step, the script exits out with the message

sha256sum: unrecognized option: quiet
BusyBox v1.31.1 () multi-call binary.

Usage: sha256sum [-c[sw]] [FILE]...

Print or check SHA256 checksums

        -c      Check sums against list in FILEs
        -s      Don't output anything, status code shows success
        -w      Warn about improperly formatted checksum lines

Replacing the call with sha256sum -s -c dl.sha256 || exit 2 does seem to work. I used this sed script:

RUN sed -i "s/sha256sum --quiet --check/sha256sum -s -c/g" get.sh

Then I got the error

sha256sum: can't open 'dl/Universal CRT Headers Libraries and Sources-x86_en-us.msi': No such file or directory
sha256sum: can't open 'dl/Windows SDK Desktop Libs x64-x86_en-us.msi': No such file or directory
sha256sum: can't open 'dl/Windows SDK Desktop Libs x86-x86_en-us.msi': No such file or directory
sha256sum: can't open 'dl/Windows SDK for Windows Store Apps Libs-x86_en-us.msi': No such file or directory

When checking the dl folder it seems like the files are there but the space is replaced by a %20

/app/msvc-wine-rust # ls dl/*.msi
dl/Universal%20CRT%20Headers%20Libraries%20and%20Sources-x86_en-us.msi
dl/Windows%20SDK%20Desktop%20Libs%20x64-x86_en-us.msi
dl/Windows%20SDK%20Desktop%20Libs%20x86-x86_en-us.msi
dl/Windows%20SDK%20for%20Windows%20Store%20Apps%20Libs-x86_en-us.msi

Simply replacing the files with a \ works:

RUN sh get.sh licenses-accepted || true # make sure it doesn't exit  the docker script
RUN mv dl/Universal%20CRT%20Headers%20Libraries%20and%20Sources-x86_en-us.msi \
     dl/Universal\ CRT\ Headers\ Libraries\ and\ Sources-x86_en-us.msi
RUN mv dl/Windows%20SDK%20Desktop%20Libs%20x64-x86_en-us.msi \
     dl/Windows\ SDK\ Desktop\ Libs\ x64-x86_en-us.msi
RUN mv dl/Windows%20SDK%20Desktop%20Libs%20x86-x86_en-us.msi \
     dl/Windows\ SDK\ Desktop\ Libs\ x86-x86_en-us.msi
RUN mv dl/Windows%20SDK%20for%20Windows%20Store%20Apps%20Libs-x86_en-us.msi \
     dl/Windows\ SDK\ for\ Windows\ Store\ Apps\ Libs-x86_en-us.msi

After that I get the error unzip: can't open tracted/tools[.zip]

This seems to be fixed by replacing the entire extract_vsix function with the following code:

# Extracts the given .vsix files                                                                                
function extract_vsix() {                                                                            
        DIR=$1                                                                                                  
        shift                                                                                                   
        echo $1                                                                                                 
        while [ -n "$1" ]; do                                                                           
                unzip $1 'Contents/*' -d $DIR                                                                   
                shift                                                                                           
        done                                                                                         
        cp -Ra $DIR/Contents/. $DIR                                                                             
        rm -rf $DIR/Contents                                                                                    
}

After fiddling some time with missing alpine packages, I ended up on cargo trying to build x86_64-pc-windows-msvc, but it resulted in this error:

The following warnings were emitted during compilation:

warning: src/wrapper.cpp:2: warning: ignoring #pragma warning  [-Wunknown-pragmas]
warning:     2 | #pragma warning(disable : 4996 4101)
warning:       | 

error: failed to run custom build command for `spirv_cross v0.23.1`

Caused by:
  process didn't exit successfully: `/app/src/target/release/build/spirv_cross-4b95b6f3b81aebbc/build-script-build` (exit code: 1)
  --- stdout
  OPT_LEVEL = Some("3")
  TARGET = Some("x86_64-pc-windows-msvc")
  HOST = Some("x86_64-unknown-linux-musl")
  CXX_x86_64-pc-windows-msvc = None
  CXX_x86_64_pc_windows_msvc = None
  TARGET_CXX = None
  CXX = None
  CROSS_COMPILE = None
  CXXFLAGS_x86_64-pc-windows-msvc = None
  CXXFLAGS_x86_64_pc_windows_msvc = None
  TARGET_CXXFLAGS = None
  CXXFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  CXX_x86_64-pc-windows-msvc = None
  CXX_x86_64_pc_windows_msvc = None
  TARGET_CXX = None
  CXX = None
  CROSS_COMPILE = None
  CXXFLAGS_x86_64-pc-windows-msvc = None
  CXXFLAGS_x86_64_pc_windows_msvc = None
  TARGET_CXXFLAGS = None
  CXXFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-Wall" "-Wextra" "-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS" "-DSPIRV_CROSS_WRAPPER_NO_EXCEPTIONS" "-DSPIRV_CROSS_WRAPPER_GLSL" "-DSPIRV_CROSS_WRAPPER_HLSL" "-DSPIRV_CROSS_WRAPPER_MSL" "-std=c++14" "-Fo/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/wrapper.o" "-c" "src/wrapper.cpp"
  cargo:warning=src/wrapper.cpp:2: warning: ignoring #pragma warning  [-Wunknown-pragmas]
  cargo:warning=    2 | #pragma warning(disable : 4996 4101)
  cargo:warning=      | 
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-Wall" "-Wextra" "-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS" "-DSPIRV_CROSS_WRAPPER_NO_EXCEPTIONS" "-DSPIRV_CROSS_WRAPPER_GLSL" "-DSPIRV_CROSS_WRAPPER_HLSL" "-DSPIRV_CROSS_WRAPPER_MSL" "-std=c++14" "-Fo/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_cfg.o" "-c" "src/vendor/SPIRV-Cross/spirv_cfg.cpp"
  exit code: 0
  exit code: 0
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-Wall" "-Wextra" "-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS" "-DSPIRV_CROSS_WRAPPER_NO_EXCEPTIONS" "-DSPIRV_CROSS_WRAPPER_GLSL" "-DSPIRV_CROSS_WRAPPER_HLSL" "-DSPIRV_CROSS_WRAPPER_MSL" "-std=c++14" "-Fo/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_cross.o" "-c" "src/vendor/SPIRV-Cross/spirv_cross.cpp"
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-Wall" "-Wextra" "-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS" "-DSPIRV_CROSS_WRAPPER_NO_EXCEPTIONS" "-DSPIRV_CROSS_WRAPPER_GLSL" "-DSPIRV_CROSS_WRAPPER_HLSL" "-DSPIRV_CROSS_WRAPPER_MSL" "-std=c++14" "-Fo/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_cross_parsed_ir.o" "-c" "src/vendor/SPIRV-Cross/spirv_cross_parsed_ir.cpp"
  exit code: 0
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-Wall" "-Wextra" "-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS" "-DSPIRV_CROSS_WRAPPER_NO_EXCEPTIONS" "-DSPIRV_CROSS_WRAPPER_GLSL" "-DSPIRV_CROSS_WRAPPER_HLSL" "-DSPIRV_CROSS_WRAPPER_MSL" "-std=c++14" "-Fo/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_parser.o" "-c" "src/vendor/SPIRV-Cross/spirv_parser.cpp"
  exit code: 0
  exit code: 0
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-Wall" "-Wextra" "-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS" "-DSPIRV_CROSS_WRAPPER_NO_EXCEPTIONS" "-DSPIRV_CROSS_WRAPPER_GLSL" "-DSPIRV_CROSS_WRAPPER_HLSL" "-DSPIRV_CROSS_WRAPPER_MSL" "-std=c++14" "-Fo/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_cross_util.o" "-c" "src/vendor/SPIRV-Cross/spirv_cross_util.cpp"
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-Wall" "-Wextra" "-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS" "-DSPIRV_CROSS_WRAPPER_NO_EXCEPTIONS" "-DSPIRV_CROSS_WRAPPER_GLSL" "-DSPIRV_CROSS_WRAPPER_HLSL" "-DSPIRV_CROSS_WRAPPER_MSL" "-std=c++14" "-Fo/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_glsl.o" "-c" "src/vendor/SPIRV-Cross/spirv_glsl.cpp"
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-Wall" "-Wextra" "-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS" "-DSPIRV_CROSS_WRAPPER_NO_EXCEPTIONS" "-DSPIRV_CROSS_WRAPPER_GLSL" "-DSPIRV_CROSS_WRAPPER_HLSL" "-DSPIRV_CROSS_WRAPPER_MSL" "-std=c++14" "-Fo/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_hlsl.o" "-c" "src/vendor/SPIRV-Cross/spirv_hlsl.cpp"
  exit code: 0
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-Wall" "-Wextra" "-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS" "-DSPIRV_CROSS_WRAPPER_NO_EXCEPTIONS" "-DSPIRV_CROSS_WRAPPER_GLSL" "-DSPIRV_CROSS_WRAPPER_HLSL" "-DSPIRV_CROSS_WRAPPER_MSL" "-std=c++14" "-Fo/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_msl.o" "-c" "src/vendor/SPIRV-Cross/spirv_msl.cpp"
  exit code: 0
  exit code: 0
  exit code: 0
  AR_x86_64-pc-windows-msvc = None
  AR_x86_64_pc_windows_msvc = None
  TARGET_AR = None
  AR = None
  running: "lib.exe" "-out:/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/libspirv-cross-rust-wrapper.a" "-nologo" "/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/wrapper.o" "/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_cfg.o" "/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_cross.o" "/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_cross_parsed_ir.o" "/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_parser.o" "/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_cross_util.o" "/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_glsl.o" "/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_hlsl.o" "/app/src/target/x86_64-pc-windows-msvc/release/build/spirv_cross-8fe711e988b75110/out/src/vendor/SPIRV-Cross/spirv_msl.o"

  --- stderr


  error occurred: Failed to find tool. Is `lib.exe` installed?

Which might be an issue with spirv_cross, I'm not sure yet. Will investigate more

My current script is:

get.sh.patch
diff --git a/get.sh b/get.sh
index c378e61..65a5ffd 100755
--- a/get.sh
+++ b/get.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-set -e
+set -ex
 
 wine_exec=${WINE_EXEC:=wine}
 
@@ -16,7 +16,7 @@ function dl() {
 
 function download() {
 	mkdir -p dl
-	mkdir -p extracted
+	mkdir -p extracted/tools
 	
 	# Obtain the SDK installer. It contains the license
 
@@ -98,12 +98,15 @@ function download() {
 
 # Extracts the given .vsix files
 function extract_vsix() {
-	mkdir -p $1
-	for f in ${@:2}; do
-		unzip $f 'Contents/*' -d $1
+	DIR=$1
+	shift
+	echo $1
+	while [ -n "$1" ]; do
+			unzip $1 'Contents/*' -d $DIR
+			shift
 	done
-	cp -Ra $1/Contents/. $1
-	rm -rf $1/Contents
+	cp -Ra $DIR/Contents/. $DIR
+	rm -rf $DIR/Contents
 }
 
 # Extracts a given msi file
@@ -115,7 +118,7 @@ function extract_msi() {
 }
 
 function extract() {
-	mkdir -p extracted
+	mkdir -p extracted/tools
 
 	# Extract the tools
 	extract_vsix extracted/tools dl/microsoft.visualcpp.tools.*.vsix
@@ -143,7 +146,7 @@ case "$1" in
 	download
 
 	# Verify the downloaded files
-	sha256sum --quiet --check dl.sha256 || exit 2
+	sha256sum -s -c dl.sha256 || exit 2
 
 	# NOTE: Create the file using:
 	# sha256sum dl/* > dl.sha256
@@ -156,7 +159,7 @@ case "$1" in
 *)
 	# Extract, then download:
 	download
-	sha256sum --quiet --check dl.sha256 || exit 2
+	sha256sum -s -c dl.sha256 || exit 2
 	extract
 	;;
 esac
Dockerfile
from alpine:latest

ENV PATH=$PATH:/root/.cargo/bin
ENV WINE_EXEC=/usr/bin/wine64

RUN apk update
RUN apk add curl wine p7zip git msitools build-base cmake pkgconfig freetype-dev expat-dev
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
    sh -s -- -y --profile minimal
RUN rustup target add x86_64-pc-windows-msvc

WORKDIR /app/msvc-wine-rust

RUN git clone https://github.com/est31/msvc-wine-rust .
COPY .docker_msvc/get.sh.patch get.sh.patch
RUN git apply get.sh.patch
RUN sh get.sh licenses-accepted || true
RUN mv dl/Universal%20CRT%20Headers%20Libraries%20and%20Sources-x86_en-us.msi \
     dl/Universal\ CRT\ Headers\ Libraries\ and\ Sources-x86_en-us.msi
RUN mv dl/Windows%20SDK%20Desktop%20Libs%20x64-x86_en-us.msi \
     dl/Windows\ SDK\ Desktop\ Libs\ x64-x86_en-us.msi
RUN mv dl/Windows%20SDK%20Desktop%20Libs%20x86-x86_en-us.msi \
     dl/Windows\ SDK\ Desktop\ Libs\ x86-x86_en-us.msi
RUN mv dl/Windows%20SDK%20for%20Windows%20Store%20Apps%20Libs-x86_en-us.msi \
     dl/Windows\ SDK\ for\ Windows\ Store\ Apps\ Libs-x86_en-us.msi
RUN sha256sum -s -c dl.sha256 || exit 2
RUN sh get.sh extract

WORKDIR /app/src

ENTRYPOINT ls -lah && \
    mkdir -p .cargo && \
    echo "[target.x86_64-pc-windows-msvc]" >> .cargo/config && \
    echo "linker = \"/app/msvc-wine-rust/linker-scripts/linkx64.sh\"" >> .cargo/config && \
    cargo build --release --target x86_64-pc-windows-msvc
@VictorKoenders
Copy link
Author

The Failed to find tool. Is lib.exe installed? Seems to be related to rust-lang/cc-rs#523. Not sure how to fix this...

@VictorKoenders
Copy link
Author

The issue with the wget %20 is because alpine has it's own special little wget installed by default. Installing the "normal" wget fixes the naming issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant