@@ -22,6 +22,7 @@ install_wolfssl_from_git() {
2222 local git_tag=" $2 "
2323 local debug_mode=" $3 "
2424 local reinstall_mode=" $4 "
25+ local main_branch=" master"
2526
2627 # If no working directory specified, create one using mktemp
2728 if [ -z " $work_dir " ]; then
@@ -58,36 +59,36 @@ install_wolfssl_from_git() {
5859 cd wolfssl
5960 git checkout " $git_tag "
6061 else
61- echo " Cloning master branch with depth 1"
62+ echo " Cloning $main_branch branch with depth 1"
6263 git clone https://github.com/wolfSSL/wolfssl --depth 1
6364 cd wolfssl
6465 fi
6566 fi
6667
6768 # Check if debian/rules.in exists, if not, we need to backport debian packaging
6869 if [ ! -f " debian/rules.in" ]; then
69- echo " debian/rules.in not found, backporting debian packaging from master ..."
70+ echo " debian/rules.in not found, backporting debian packaging from $main_branch ..."
7071
71- # Save current branch/tag
72- current_ref=$( git rev-parse HEAD)
73-
74- # Create a temporary directory for master checkout
75- temp_master_dir=$( mktemp -d)
76- cd " $temp_master_dir "
77-
78- echo " Cloning master branch to get debian directory..."
79- git clone https://github.com/wolfSSL/wolfssl master-checkout
80- cd master-checkout
81-
82- # Copy debian directory to our working wolfssl
83- echo " Copying debian directory from master..."
84- cp -r debian " $work_dir /wolfssl/"
72+ # Error out if the debian directory has any uncommitted changes since
73+ # we are going to clobber it.
74+ if [ -d " debian" ] && ! git diff --quiet debian; then
75+ echo " debian directory has uncommitted changes, please commit or stash them"
76+ exit 1
77+ fi
8578
86- # Go back to our working wolfssl directory
87- cd " $work_dir /wolfssl"
79+ # Checkout the debian directory from the main branch which has the updated packaging code
80+ if ! git checkout $main_branch -- debian; then
81+ echo " Failed to checkout debian directory from $main_branch "
82+ echo " Please ensure the $main_branch branch is being tracked and up-to-date"
83+ exit 1
84+ fi
8885
89- # Clean up temporary directory
90- rm -rf " $temp_master_dir "
86+ # Updated rules.in file should be present after checkout
87+ if [ ! -f " debian/rules.in" ]; then
88+ echo " debian/rules.in not found in $main_branch branch"
89+ echo " Try updating the $main_branch branch and try again"
90+ exit 1
91+ fi
9192
9293 # Patch configure.ac to add required substitutions for debian packaging
9394 echo " Patching configure.ac for debian packaging compatibility..."
0 commit comments