Ignore:
Timestamp:
02/17/17 20:36:51 (4 years ago)
Author:
ak19
Message:

Fix to commits 31421 and 31422. Adding Dr Bainbridge's new awk file script (with slight modification) now used by adjust-winmakefiles.bat in place of sed. To prevent race conditions when compiling up apache-httpd2 for GS2, tempfile.bat files should be numbered incrementally within each win32.mak in httpd-2.2.11, not incrementally between each win32.mak within httpd-2.2.11.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/packages/apache-httpd/adjust-winmak-files.bat

    r31422 r31425  
    33:: (Also http://trac.greenstone.org/browser/main/trunk/ant-tasks/src/org/greenstone/anttasks/RegexSearchReplace.java
    44:: http://trac.greenstone.org/browser/main/trunk/ant-tasks/src/org/greenstone/anttasks/InsertUniqueValue.java)
    5 :: This script performs 2 steps:
    6 :: replace all occurrences of "tempfile" in .mak files within httpd-2.2.11 with "tempfile$counter"
    7 :: replace all occurrences of "/MD" in .mak files within httpd-2.2.11 with "/MT"
     5:: This script makes use of mod_winmake_file.awk to perform the following 2 steps
     6:: to prevent race conditions to any win32.mak file trying to create/access the same tempfile.bat:
     7:: - in each .mak within httpd-2.2.11, make each line that refers to "tempfile.bat" refer to a unique tempfile.bat instead
     8:: - replace all occurrences of "/MD" in .mak files within httpd-2.2.11 with "/MT"
    89
    910:: http://www.theverge.com/2016/3/30/11331014/microsoft-windows-linux-ubuntu-bash
     
    3334:: http://stackoverflow.com/questions/2913231/how-do-i-increment-a-dos-variable-in-a-for-f-loop
    3435:: http://stackoverflow.com/questions/17605767/create-list-or-arrays-in-windows-batch
    35 set counter=0
     36rem set counter=0
    3637
    3738:: http://stackoverflow.com/questions/2951063/windows-bat-file-how-to-recursively-list-all-files-of-type-mp3
     
    4142
    4243call :rsr-files %httpdfolder% *.mak
    43 ::echo PATHS: %PATHS%
    44 ::echo NAMES: %NAMES%
    4544
    4645popd
     
    5150:: ************************ SUBROUTINES **********************************************
    5251
    53 :: append counter to tempfile.bat references in the current .mak file of loop
    54 :: And change any occurrence of /MD to /MT in each .mak file too
    55 :: Digit wildcard doesn't work for me in sed regex here, and although the any char wildcard
    56 :: works it may be too greedy. Fortunately, character classes for digits works.
     52:: A win mak file may make references to tempfile.bat in various lines of the makefile. The different
     53:: references could end up clashing with each other when they're generated on the file system by
     54:: that .mak file, leading to race conditions. To avoid this, within each win32.mak file, ensure
     55:: unique tempfile .bat files are generated:
     56:: For each win32.mak file, change each line of reference to tempfile.bat to a unique tempfile.bat
     57:: by renaming the references in that makefile line to tempfile<number>.bat. Note: change each
     58:: LINE to refer consistently to a unique tempfile .bat, don't make each reference in a line
     59:: refer to a different tempfile.bat.
     60:: Further, change any occurrence of /MD to /MT in each .mak file too.
    5761:: To check this script has worked, check httpd-2.2.11/modules/ssl/mod_ssl.mak to make sure
    5862:: occurrences of "tempfile.bat" have a number suffix before the extension and that there's
     
    6468    set NAMES=
    6569    for /r "%~1" %%P in ("%~2") do (
    66         rem set PATHS=!PATHS! "%%~fP"
    67         rem set NAMES=!NAMES! "%%~nP%%~xP"
    6870       
    69        
    70         set /a "counter +=1"
     71        rem set /a "counter +=1"
    7172        rem echo counter: !counter!
    7273       
    7374        set filename=%%~fP
     75        echo file: Modifying win32.mak file !filename! to refer to unique tempfile .bat files to avoid race conditions.
    7476       
    75         echo Writing tempfile!counter! into
    76         echo file: !filename!       
     77        rem echo Writing tempfile!counter! into
     78        rem echo file: !filename!       
    7779       
     80        rem copy "!filename!" "!filename!.tmp"     
     81        rem sed "s@tempfile[0-9]*\.bat@tempfile!counter!.bat@g" "!filename!.tmp" > "!filename!"
     82        rem del "!filename!.tmp"
     83       
     84        rem copy "!filename!" "!filename!.tmp"
     85        rem sed "s@/MD@/MT@g" "!filename!.tmp" > "!filename!"
     86        rem del "!filename!.tmp"
    7887       
     88        rem http://stackoverflow.com/questions/4462954/sed-increment-number
     89        rem https://www.gnu.org/software/gawk/manual/gawk.html see section An Example with Two Rules
    7990        copy "!filename!" "!filename!.tmp"
    80         sed "s@tempfile[0-9]*\.bat@tempfile!counter!.bat@g" "!filename!.tmp" > "!filename!"
    81         del "!filename!.tmp"
    82        
    83         copy "!filename!" "!filename!.tmp"
    84         sed "s@/MD@/MT@g" "!filename!.tmp" > "!filename!"
     91        awk -f mod_winmak_file.awk "!filename!.tmp" > "!filename!"
    8592        del "!filename!.tmp"
    8693       
Note: See TracChangeset for help on using the changeset viewer.