veracrypt / VeraCrypt

Disk encryption with strong security based on TrueCrypt
https://www.veracrypt.fr
Other
6.92k stars 949 forks source link

personal improvement to build_veracrypt_macosx.sh #1417

Closed Mattoje closed 1 month ago

Mattoje commented 1 month ago

I needed a way to disable universal binaries and to use my own wxWidgets. To disable universal binaries currently you have to use -b (brew) which implies using brew-wxwidgets.

Veracrypt + brew-wxwidgets breaks when brew-wxwidgets are updated.

This little patch did the trick (at least for me):

index 5319fa6a..efdc4a86 100755
--- a/src/Build/build_veracrypt_macosx.sh
+++ b/src/Build/build_veracrypt_macosx.sh
@@ -14,16 +14,23 @@ SOURCEPATH=$(cd "$(dirname "$SCRIPTPATH/../.")"; pwd)
 # directory where the VeraCrypt project has been checked out
 PARENTDIR=$(cd "$(dirname "$SCRIPTPATH/../../../.")"; pwd)

-while getopts bpf flag
+while getopts bpfl flag
 do
     case "${flag}" in
         b) brew=true;;
         p) package=true;;
         f) fuset=true;;
+        l) local=true;;
     esac
 done

 export VC_OSX_FUSET=0
+export WX_VERSION=3.2.6
+
+if [ -n "$local" ]; then
+    echo "Building VeraCrypt with local wxWidgets support and no universal binary"
+    export LOCAL_DEVELOPMENT_BUILD=true
+fi

 if [ -n "$fuset" ]; then
     echo "Building VeraCrypt with FUSE-T support"
@@ -55,29 +62,29 @@ if [ -n "$brew" ]; then
     exit 0
 fi

-# Check the condition of wxBuildConsole and wxWidgets-3.2.5 in the original PARENTDIR
+# Check the condition of wxBuildConsole and wxWidgets-$WX_VERSION in the original PARENTDIR
 if [ -d "$PARENTDIR/wxBuildConsole" ]; then
     echo "Using existing PARENTDIR: $PARENTDIR, wxBuildConsole is present."
-elif [ -d "$PARENTDIR/wxWidgets-3.2.5" ]; then
-    echo "Using existing PARENTDIR: $PARENTDIR, wxWidgets-3.2.5 is present."
+elif [ -d "$PARENTDIR/wxWidgets-$WX_VERSION" ]; then
+    echo "Using existing PARENTDIR: $PARENTDIR, wxWidgets-$WX_VERSION is present."
 else
     # Change PARENTDIR to /tmp and check conditions again
     export PARENTDIR="/tmp"
     if [ -d "$PARENTDIR/wxBuildConsole" ]; then
         echo "Switched to PARENTDIR: /tmp, wxBuildConsole is present in /tmp."
-    elif [ -d "$PARENTDIR/wxWidgets-3.2.5" ]; then
-        echo "Switched to PARENTDIR: /tmp, wxWidgets-3.2.5 is present in /tmp."
+    elif [ -d "$PARENTDIR/wxWidgets-$WX_VERSION" ]; then
+        echo "Switched to PARENTDIR: /tmp, wxWidgets-$WX_VERSION is present in /tmp."
     else
-        echo "Error: Neither wxBuildConsole nor wxWidgets-3.2.5 found in /tmp. Exiting."
+        echo "Error: Neither wxBuildConsole nor wxWidgets-$WX_VERSION found in /tmp. Exiting."
         exit 1
     fi
 fi

-# The sources of wxWidgets 3.2.5 must be extracted to the parent directory
-export WX_ROOT=$PARENTDIR/wxWidgets-3.2.5
+# The sources of wxWidgets $WX_VERSION must be extracted to the parent directory
+export WX_ROOT=$PARENTDIR/wxWidgets-$WX_VERSION

 # this will be the temporary wxWidgets directory
-export WX_BUILD_DIR=$PARENTDIR/wxBuild-3.2.5
+export WX_BUILD_DIR=$PARENTDIR/wxBuild-$WX_VERSION

 # define the SDK version to use and OSX minimum target. We target 12 by default
 export VC_OSX_TARGET=12
idrassi commented 1 month ago

Thank you for sharing this enhancement. I have pushed a commit that implements changes based on your approach. I have added a -v switch to allow overriding the wxWidgets version to use. You can check the new script and share your feedback.

Mattoje commented 1 month ago

It wasn't working at the begininnig.

It was still looking for osxfuse even though i did toggle the -f switch

so after adding those lines to the script

echo fuset=$fuset
echo VC_OSX_FUSET=$VC_OSX_FUSET

i found out that, no matter the fuset value, this expression

export VC_OSX_FUSET=$((fuset ? 1 : 0))

is always false

so i came up with this solution which works for me

export VC_OSX_FUSET=$([ $fuset == "true" ] && echo 1 || echo 0)
idrassi commented 1 month ago

My bad! I didn't test it enough before pushing the changes. The one line syntax was tempting. Thank you for the fix, I have integrated it: https://github.com/veracrypt/VeraCrypt/commit/866fc8f5137925e684ea855111affe2d71612b88