Browse Source

Fix parallel issue in 0install.sh script

 + Uses bash coproc and wait keywords
 + Fix issue pointed in e8c3ca5978f209ffc5127c19eb63ae1223f90b48, i.e. when the
 script exits, everything is now finished.
Leo 9 years ago
parent
commit
baae2c92c2
1 changed files with 6 additions and 3 deletions
  1. 6 3
      0install.sh

+ 6 - 3
0install.sh

@@ -36,17 +36,20 @@ mv $final_binary_name $build_log $name
 tree > $dbg_log
 tree > $dbg_log
 
 
 # Create archive, building the two in parallel, to speed up the process
 # Create archive, building the two in parallel, to speed up the process
-# WARNING the script may exit while the first compression didn't end.
 echo "========= Creating base archive ========="
 echo "========= Creating base archive ========="
 tar_name=${name}.tar
 tar_name=${name}.tar
 tar -cvaf ${tar_name} $name >> $dbg_log
 tar -cvaf ${tar_name} $name >> $dbg_log
 
 
 echo "========= Creating first archive ========="
 echo "========= Creating first archive ========="
-lzma -f -9 ${tar_name} >> $dbg_log &
+coproc lzma -f -9 ${tar_name} >> $dbg_log
 
 
 # Create stripped archive
 # Create stripped archive
 tar_name_stripped=${name}_stripped.tar
 tar_name_stripped=${name}_stripped.tar
 strip $final_binary_path
 strip $final_binary_path
 tar -cvaf ${tar_name_stripped} $name >> $dbg_log
 tar -cvaf ${tar_name_stripped} $name >> $dbg_log
 echo "========= Creating second (stripped) archive ========="
 echo "========= Creating second (stripped) archive ========="
-lzma -f -9 ${tar_name_stripped} >> $dbg_log
+coproc lzma -f -9 ${tar_name_stripped} >> $dbg_log
+
+# Wait for the detached compression process  to finish
+# (see lines starting with 'coproc')
+wait