merge

Simple tool to quickly merge datasets for statistical analysis
git clone git://git.wrycode.com/wrycode/archive/merge.git
Log | Files | Refs | README | LICENSE

winbuild.sh (2814B)


      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 go mingw32-binutils mingw32-nsiswrapper # glib2-devel gtk3-devel
      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     # Download gotk3
     13     buildah run $container go get -u github.com/gotk3/gotk3/gtk
     14 
     15     # Compile gotk3
     16     buildah run $container bash -c "PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go install -v github.com/gotk3/gotk3/gtk"
     17 
     18     # Cache image to avoid re-downloading dependencies every time
     19     buildah commit $container my-gotk3-app
     20 
     21     # Clean up
     22     buildah rm $container
     23 }
     24 
     25 build () {
     26     # Create a new container from the base one we created
     27     container=$(buildah from localhost/my-gotk3-app)
     28 
     29     # Folder to hold everything needed for the windows installer:
     30     output_folder=windows
     31     yes | rm -r $output_folder
     32     mkdir $output_folder
     33     
     34     # Directory of your package in the container
     35     folder=$(go list) 
     36     folder=/root/go/src/$folder
     37 
     38     # Copy program into container
     39     buildah copy $container . $folder
     40 
     41     # Pull dependencies for your program.
     42     buildah run $container bash -c "cd $folder && go get ./... &>/dev/null"&>/dev/null
     43 
     44     # default name the go compiler produces
     45     original_name="merge.exe"
     46     # Name for the executable file on Windows
     47     executable_name="dataset-merge-tool.exe"
     48 
     49     # Compile your program
     50     buildah run $container bash -c "cd $folder && PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -ldflags -H=windowsgui -o $folder/$output_folder/$executable_name" 
     51 
     52     # Copy resources into installation folder
     53     buildah run $container bash -c "cd $folder && mv trash.png $output_folder/"
     54 
     55     # Copy mingw dlls into installation folder
     56     # This part may need to be personalized
     57     buildah run $container bash -c "yes | cp -r /usr/x86_64-w64-mingw32/sys-root/mingw/{bin/*.dll,share} $folder/$output_folder/"
     58 
     59     # Generate an installer
     60     buildah run $container bash -ic "cd $folder/$output_folder && nsiswrapper --run $executable_name ./*"
     61 
     62     # Copy the output from the container
     63     cp -ru $(buildah unshare buildah mount $container)$folder/$output_folder .
     64 
     65     # Clean up
     66     buildah rm $container
     67 }
     68 
     69 # This just checks whether the container already exists on your drive
     70 buildah inspect localhost/my-gotk3-app &>/dev/null
     71 return_value=$?
     72 
     73 if [ $return_value -eq 1 ]
     74 then
     75     echo "Initial container setup"
     76     setup
     77 fi
     78 
     79 # Build project
     80 build