From 73c5a4691642f95d6f593b886d7d5dcf5ccd7466 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sat, 30 Apr 2005 17:58:05 +0000 Subject: [PATCH] 'noprocess' works now recursively with directories. --- apps/autodist/CHANGES | 5 + apps/autodist/TODO | 6 +- apps/autodist/autodist.in | 162 ++++++++++++++++++++------------ apps/autodist/doc/autodist.texi | 22 ++--- 4 files changed, 121 insertions(+), 74 deletions(-) diff --git a/apps/autodist/CHANGES b/apps/autodist/CHANGES index fcb3687..28e853b 100644 --- a/apps/autodist/CHANGES +++ b/apps/autodist/CHANGES @@ -1,3 +1,8 @@ +Sat Apr 30 17:49:05 EEST 2005 Pekka Riikonen + + * The 'noprocess' directive now works recursively with + directories. + Sat Apr 30 11:49:01 EEST 2005 Pekka Riikonen * Added better debug messages. diff --git a/apps/autodist/TODO b/apps/autodist/TODO index 26db6f2..106cb48 100644 --- a/apps/autodist/TODO +++ b/apps/autodist/TODO @@ -4,7 +4,5 @@ TODO In Autodist o Better 'license-header' implementation. o Perhaps ability to partially re-license the source tree. Now all files - will be processed if 'license-header' is used. - -o Better 'noprocess' so that it would work with directories recursively, - such as noprocess foo/bar, would not process anything under foo/bar. + will be processed if 'license-header' is used. Only way to control + this is to use 'noprocess' or specify different header in file. diff --git a/apps/autodist/autodist.in b/apps/autodist/autodist.in index f6af189..f40f70f 100755 --- a/apps/autodist/autodist.in +++ b/apps/autodist/autodist.in @@ -369,7 +369,7 @@ ad_make_configure_ac() rm -f configure.ac configure.ad.cfs - cfs=`find . -name configure\*\.ad` + cfs=`find . -type f -name configure\*\.ad` for i in $cfs do if test "x$i" = "x$1"; then @@ -468,7 +468,7 @@ ad_make_makefile_ams() ad_log "Following Makefile.ad files were processed into Makefile.am files:" ad_log "------------------------------------------------------------------" - files=`find . -name Makefile\.ad` + files=`find . -type f -name Makefile\.ad` for ff in $files do ad_log " $ff" @@ -518,7 +518,7 @@ ad_process_ads() ad_log "Following .ad files were processed:" ad_log "-----------------------------------" - files=`find . -name \*\.ad \! -name configure\*\.ad \! -name Makefile\.ad` + files=`find . -type f -name \*\.ad \! -name configure\*\.ad \! -name Makefile\.ad` for i in $files do fname=`echo $i | sed s/\.ad//` @@ -552,7 +552,7 @@ ad_process_ads() # source path. This, in effect, is a cp utility with ability to create # directories if they do not exist. # -# Arguments: ad_dist_includes +# Arguments: ad_dist_includes # ad_dist_includes() { @@ -560,9 +560,11 @@ ad_dist_includes() ad_debug "Starting running includes: $1 $2" - ad_log "" - ad_log "Following files and directories were included in distribution:" - ad_log "--------------------------------------------------------------" + if test x$3 = xtrue; then + ad_log "" + ad_log "Following files and directories were included in distribution:" + ad_log "--------------------------------------------------------------" + fi # By default do not expand pathnames set -f @@ -613,7 +615,9 @@ ad_dist_includes() fi fi - ad_log " $src into $am_distdir/$d" + if test x$3 = xtrue; then + ad_log " $src into $am_distdir/$d" + fi cp -p $src $am_distdir/$d || exit 1 elif test -d "$src"; then @@ -633,7 +637,9 @@ ad_dist_includes() mkdir -p $am_distdir/$d || exit 1 fi - ad_log " $src into $am_distdir/$d" + if test x$3 = xtrue; then + ad_log " $src into $am_distdir/$d" + fi cp -pR $src $am_distdir/$d || exit 1 else # Add to different location @@ -651,7 +657,9 @@ ad_dist_includes() mkdir -p $am_distdir/$d || exit 1 fi - ad_log " $src into $am_distdir/$dst" + if test x$3 = xtrue; then + ad_log " $src into $am_distdir/$dst" + fi cp -pR $src $am_distdir/$dst || exit 1 fi @@ -710,7 +718,10 @@ ad_dist_includes() src= dst= done - ad_log "" + + if test x$3 = xtrue; then + ad_log "" + fi set +f @@ -727,23 +738,33 @@ ad_dist_includes() # # The path may be file, directory or regular expression. # -# Arguments: ad_dist_includes +# Arguments: ad_dist_includes # ad_dist_excludes() { ad_debug "Starting running excludes: $1" - ad_log "" - ad_log "Following files and directories were excluded from distribution:" - ad_log "----------------------------------------------------------------" + if test x$2 = xtrue; then + ad_log "" + ad_log "Following files and directories were excluded from distribution:" + ad_log "----------------------------------------------------------------" + fi + cur=`pwd` + cd $am_distdir || exit 1 for i in $1 do ad_debug "Excluding $i" - ad_log " $1" - rm -rf $am_distdir/$i + if test x$2 = xtrue; then + ad_log " $1" + fi + rm -rf $i done - ad_log "" + cd $cur || exit 1 + + if test x$2 = xtrue; then + ad_log "" + fi ad_debug "Ending running excludes: $1" } @@ -762,7 +783,7 @@ ad_process_tree() ad_debug "Starting processing non-source files: $1" # Take files, except source and .ad files. - files=`find $am_distdir \! -name \*\.ad \( \ + files=`find $am_distdir -type f \! -name \*\.ad \( \ \! -name \*\.[cC] -a \ \! -name \*\.[cC][cCpP] -a \ \! -name \*\.[cC][xX][xX] -a \ @@ -781,11 +802,6 @@ ad_process_tree() \! -name \*\.hh\.in \)` files=`echo $files | sed 's/$am_distdir//'` - # Take away noprocess list - if test -f autodist.noprocess; then - files=`echo $files" " | sh autodist.noprocess` || exit 1 - fi - for ff in $files do ad_process_file $ff $ff.tmp true @@ -815,7 +831,7 @@ ad_process_source_tree() # We take only C/C++ files since they use the C compiler friendly # version of distdefs. Other files are not assumed to use them. - files=`find $am_distdir \! -name \*\.ad \( \ + files=`find $am_distdir -type f \! -name \*\.ad \( \ -name \*\.[cC] -o \ -name \*\.[cC][cCpP] -o \ -name \*\.[cC][xX][xX] -o \ @@ -833,11 +849,6 @@ ad_process_source_tree() -name \*\.[hH]\.in -o \ -name \*\.hh\.in \)` - # Take away noprocess list - if test -f autodist.noprocess; then - files=`echo $files" " | sh autodist.noprocess` || exit 1 - fi - for ff in $files do ad_process_source_file $ff $ff.tmp true @@ -876,7 +887,7 @@ ad_makedist_makesane() configh=`grep "^CONFIG_HEADER" Makefile | cut -d= -f2 | sed 's/^[ ]*//'` touch $am_distdir/$configh.in 1>/dev/null 2>/dev/null - files=`find $am_distdir -name Makefile\.in` + files=`find $am_distdir -type f -name Makefile\.in` for i in $files do touch $i @@ -928,6 +939,7 @@ ad_makedist() ad_parse_distribution $distribution false ad_log " Distribution: $distribution $dist_version" ad_log " Destination directory: $am_distdir" + ad_log "" ad_process_distdefs if test x$opt_no_dist = xtrue; then @@ -950,10 +962,10 @@ ad_makedist() ad_run_dist_hooks "$pre_p_dist_hooks" # Run excludes - ad_dist_excludes "$excludes" + ad_dist_excludes "$excludes" true # Run includes - ad_dist_includes "$includes" + ad_dist_includes "$includes" false true # Include specific license file if specified if test "$license" != ""; then @@ -961,11 +973,12 @@ ad_makedist() ad_log "License file in distribution:" ad_log "-----------------------------" ad_log " $license into $am_distdir/COPYING" + ad_log "" cp -p $license $am_distdir/COPYING || exit 1 fi - # Process noprocesses - ad_process_noprocess + # Process noprocesses, first pass + ad_process_noprocess true ad_log "" ad_log "Following files were not re-licensed:" @@ -979,6 +992,11 @@ ad_makedist() ad_debug "Process distribution tree" ad_process_tree $am_distdir + ad_log "" + + # Process noprocesses, second pass + ad_process_noprocess false + # Run post-process_dist-hooks ad_run_dist_hooks "$post_p_dist_hooks" @@ -1015,7 +1033,6 @@ ad_makedist() # Cleanup rm -rf $am_distdir - rm -f autodist.noprocess ad_log "Distribution created successfully." @@ -1351,39 +1368,67 @@ ad_process_license_header() # # Process specified noprocesses. This is called during makedist. +# The noprocess first copies the noprocess files and dirs into a temp +# directory, and then removes them from the distdir. This way they are +# not processed by Autodist. After processing they are returned to their +# correct locations from the temp dir. Dirty, yeah, but the way we do +# this until better one comes along. +# +# Arguments: ad_process_noprocess # -# Arguments: ad_process_noprocess +# If is true this excludes and if false this includes. # ad_process_noprocess() { - local np=false - local n="sed " - ad_debug "Starting running noprocesses" - ad_log "" - ad_log "Autodist did not process the following files:" - ad_log "---------------------------------------------" + set -f cur=`pwd` - cd $am_distdir || exit 1 - for i in $noprocess - do - ad_log " $i" - - # Escape - ie=`echo $i | sed 's/\\//\\\\\//g'` || exit 1 - n="$n -e 's/$am_distdir\\/$ie //'" - np=true - done - cd $cur || exit 1 + if test x$1 = xtrue; then + ad_log "" + ad_log "Autodist did not process the following files and directories:" + ad_log "-------------------------------------------------------------" + + f="$cur/autodist__noprocess" + rm -rf $f + mkdir -p $f || exit 1 + + # First, include them to new location with correct directory structure. + old_am_distdir="$am_distdir" + cd $am_distdir || exit 1 + am_distdir="$f" + nops=" $noprocess" + nops=`echo $nops | sed -e 's/ / : /g' -e 's/^/ : /'` || exit 1 + ad_dist_includes "$nops" false false + am_distdir="$old_am_distdir" + + # Then, remove from distdir (they are in temp dir now) + for i in $noprocess + do + ad_log " $i" + rm -rf $i + done + cd $cur || exit 1 - rm -f autodist.noprocess - if test x$np = xtrue; then - echo $n > autodist.noprocess || exit 1 + ad_log "" + else + # Copy from the temp dir back to distdir + cd autodist__noprocess || exit 1 + old_am_distdir="$am_distdir" + am_distdir="$cur/$old_am_distdir" + nops=" $noprocess" + nops=`echo $nops | sed -e 's/ / : /g' -e 's/^/ : /'` || exit 1 + + ad_dist_includes "$nops" false false + + am_distdir="$old_am_distdir" + cd $cur || exit 1 + rm -rf autodist__noprocess fi - ad_log "" + + set +f ad_debug "Ending running noprocesses" } @@ -1801,6 +1846,7 @@ if test $# != 0; then fi ad_parse_distribution $distribution false ad_log " Distribution: $distribution $dist_version" +ad_log "" ad_process_distdefs if test $# != 0; then diff --git a/apps/autodist/doc/autodist.texi b/apps/autodist/doc/autodist.texi index 93f01be..e7542e3 100644 --- a/apps/autodist/doc/autodist.texi +++ b/apps/autodist/doc/autodist.texi @@ -789,24 +789,22 @@ This will exclude the file 'README' and anything that match 'doc/client*'. @section Directive: noprocess [...] -The 'noprocess' directive can be used to tell Autodist specificly not to -process a file. The Autodist will not process the file during -preparation or during distribution packaging. This directive is optional. -One or more file can be specified in the 'noprocess' directive. Zero or -more 'noprocess' directives can be used in distribution. The -can be a single file or a regular expression that will match several files. -Note that, in current Autodist version 'noprocess' cannot be used to -specify directories. +The 'noprocess' directive can be used to tell Autodist specificly not to +process files or directories. The Autodist will not process the files +during preparation or during distribution packaging. This directive is +optional. One or more files can be specified in the 'noprocess' +directive. Zero or more 'noprocess' directives can be used in +distribution. The can be a single file, a single directory or +a regular expression that will match several files and/or directories. Example: @example noprocess autodist.texi -noprocess apps/foo/* +noprocess apps/foo/ @end example -Autodist will not process 'autodist.texi' file, and any file that match -'apps/foo/*'. Note that, any subdirectory under 'apps/foo/' will not -match, and will be processed. +Autodist will not process 'autodist.texi' file, and any files and +directories under 'apps/foo/'. Also note that, 'noprocess' directive cannot be used to disallow processing of any file with '.ad' suffix. -- 2.24.0