winbuild.sh (2704B)
1 #!/bin/bash 2 setup () { 3 # Create a fedora container 4 container=$(buildah from fedora) 5 6 # Install dependencies 7 buildah run $container dnf -y install mingw64-gtk3 mingw32-binutils mingw32-nsiswrapper 8 9 # Fix typo in mingw library 10 buildah run $container bash -c "sed -i -e 's/-Wl,-luuid/-luuid/g' /usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/gdk-3.0.pc" 11 12 # Cache image to avoid re-downloading dependencies every time 13 buildah commit $container my-tutorial-app 14 15 # Clean up 16 buildah rm $container 17 } 18 19 build () { 20 # Create a new container from the base one we created 21 container=$(buildah from localhost/my-tutorial-app) 22 23 # Folder to hold everything needed for the windows installer: 24 output_folder=windows 25 yes | rm -r $output_folder 26 mkdir $output_folder 27 28 # Directory of your package in the container 29 folder=/root/app 30 31 # Copy program into container 32 buildah copy $container . $folder 33 34 # Name for the executable file on Windows 35 executable_name="Demo.exe" 36 37 # make some folders we'll need 38 buildah run $container bash -c "cd $folder && mkdir -p $output_folder/share/themes $output_folder/etc/gtk-3.0" 39 40 # generate a RC file with the windres utility to embed an icon into the .exe later on 41 buildah run $container bash -c "cd $folder && x86_64-w64-mingw32-windres icon.rc -O coff -o icon.res" 42 43 # copy some project resources 44 buildah run $container bash -c "cd $folder && cp -r Windows10 $output_folder/share/themes && \ 45 cp settings.ini $output_folder/etc/gtk-3.0/ &&\ 46 cp icon.ico $output_folder" 47 48 # Compile program 49 buildah run $container bash -c "cd $folder && x86_64-w64-mingw32-gcc -mwindows -o $executable_name main.c icon.res \`mingw64-pkg-config --cflags gtk+-3.0 --libs gtk+-3.0\`" 50 51 # Copy executable into installation folder 52 buildah run $container bash -c "cd $folder && cp $executable_name $output_folder" 53 54 # Copy mingw dlls into installation folder 55 # This part may need to be personalized 56 buildah run $container bash -c "yes | cp -r /usr/x86_64-w64-mingw32/sys-root/mingw/{bin/*.dll,share} $folder/$output_folder/" 57 58 # Generate an installer 59 buildah run $container bash -ic "cd $folder/$output_folder && nsiswrapper --run $executable_name ./*" 60 61 # Copy the output from the container 62 cp -ru $(buildah unshare buildah mount $container)$folder/$output_folder . 63 64 # Clean up 65 buildah rm $container 66 } 67 68 # This just checks whether the container already exists on your drive 69 buildah inspect localhost/my-tutorial-app &>/dev/null 70 return_value=$? 71 72 if [ $return_value -eq 1 ] 73 then 74 echo "Initial container setup" 75 setup 76 fi 77 78 # Build project 79 build