gimp-help-2 r2796 - in trunk: . tools



Author: ulfehlert
Date: Thu Mar 26 13:05:44 2009
New Revision: 2796
URL: http://svn.gnome.org/viewvc/gimp-help-2?rev=2796&view=rev

Log:
2009-03-26  Ulf-D. Ehlert  <ulfehlert svn gnome org>

	* tools/make_image_links.pl
	* tools/README
	* Makefile.GNU
	* Makefile.am: make relative symlinks in xml/*/images
	rather than absolute symlinks

	* tools/check_keywords_property.pl: removed


Added:
   trunk/tools/make_image_links.pl   (contents, props changed)
Removed:
   trunk/tools/check_keywords_property.pl
Modified:
   trunk/ChangeLog
   trunk/Makefile.GNU
   trunk/Makefile.am
   trunk/tools/README

Modified: trunk/Makefile.GNU
==============================================================================
--- trunk/Makefile.GNU	(original)
+++ trunk/Makefile.GNU	Thu Mar 26 13:05:44 2009
@@ -439,22 +439,10 @@
 	$(cmd) if test -L xml/$*; then rm -v xml/$*; fi
 	$(cmd) if test -d $@; then rm -rf $@/*; fi
 	$(cmd) test -d $@ || $(mkdir_p) $@
-	$(msg) "*** Copying images ($*) ..."
-	$(cmd) (cd images && $(find_l) common C $(dir_predicates)) | \
-	while read dir; do \
-		dest=$${dir#*/}; \
-		test "$${dir}" != "$${dest}" || continue; \
-		test -d $@/$${dest} || $(mkdir_p) $@/$${dest}; \
-	done
-	$(cmd) (cd images && $(find_l) common C $(file_predicates)) | \
-	while read image; do \
-		if [ "$*" != "en" ]; then \
-			localized=$*/$${image#C/}; \
-			test -e images/$${localized} && image=$${localized}; \
-		fi; \
-		dest=$${image#*/}; \
-		$(call copy,images/$${image},$@/$${dest}); \
-	done
+	$(cmd) $(echo_n) "*** Copying images ($*) ..."
+	$(cmd) perl tools/make_image_links.pl -v \
+	           images/common images/C \
+		   xml/$*
 
 # Special case: en
 

Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am	(original)
+++ trunk/Makefile.am	Thu Mar 26 13:05:44 2009
@@ -445,22 +445,10 @@
 	$(cmd) if test -L xml/$*; then rm -v xml/$*; fi
 	$(cmd) if test -d $@; then rm -rf $@/*; fi
 	$(cmd) test -d $@ || $(MKDIR_P) $@
-	$(msg) "*** Copying images ($*) ..."
-	$(cmd) (cd images && find common C $(dir_predicates)) | \
-	while read dir; do \
-		dest=$${dir#*/}; \
-		test "$${dir}" != "$${dest}" || continue; \
-		test -d $@/$${dest} || $(MKDIR_P) $@/$${dest}; \
-	done
-	$(cmd) (cd images && find common C $(file_predicates)) | \
-	while read image; do \
-		if [ "$*" != "en" ]; then \
-			localized=$*/$${image#C/}; \
-			test -e images/$${localized} && image=$${localized}; \
-		fi; \
-		dest=$${image#*/}; \
-		$(call copy,images/$${image},$@/$${dest}); \
-	done
+	$(cmd) $(echo_n) "*** Copying images ($*) ..."
+	$(cmd) perl tools/make_image_links.pl -v \
+	           images/common images/C \
+		   xml/$*
 
 # Special case: en
 

Modified: trunk/tools/README
==============================================================================
--- trunk/tools/README	(original)
+++ trunk/tools/README	Thu Mar 26 13:05:44 2009
@@ -226,33 +226,12 @@
 check_keywords_property.pl
 ==========================
 
-This script searches for XML source files without 'svn:keywords'
-property set to "Author Date Id Revision". It will print a list of
-these files to stdout and a few informative lines to stderr if
-called with option '-v' or '--verbose'.
+Removed, we do not need "svn:keywords" any more
+(and "git" won't support them).
 
-If the 'svn:keywords' property is set, Subversion will replace e.g.
-"$Revision$" with "$Revision: <revision of last change> $".
 
-Example output (verbose):
-
-    Searching for files with missing/wrong properties...
-    Found 1 of 593 files:
-    src/dialogs/foo-bar.xml
-
-Requirements:
-    - Perl
-
-Usage:
-    Call the script from the gimp-help-2 root:
-
-        tools/check_keywords_property.pl [-v | --verbose]
-                                or
-        perl tools/check_keywords_property.pl [-v | --verbose]
-
-    If you want to set the svn:keywords property:
-
-        tools/check_keywords_property.pl | \
-        xargs --no-run-if-empty svn propset svn:keywords "Author Date Id Revision"
+make_image_links.pl
+===================
 
+Do not use this script directly, it's meant to be run by 'make'.
 

Added: trunk/tools/make_image_links.pl
==============================================================================
--- (empty file)
+++ trunk/tools/make_image_links.pl	Thu Mar 26 13:05:44 2009
@@ -0,0 +1,96 @@
+#!/usr/bin/env perl
+#
+# make_image_links.pl
+#
+# This script creates relative symlinks in xml/LANG to images files
+# in images/C and images/common.
+#
+# Do not use this script directly, it's meant to be run by 'make'.
+#
+# Usage:
+#     cd <top_srcdir>  # where src/ and tools/ are
+#     tools/make_image_links.pl [-v] images/C images/common xml/LANG
+#
+
+use warnings;
+use strict;
+use File::Find;
+use File::Path qw/mkpath/;
+use File::Spec::Functions qw/abs2rel splitpath catfile/;
+
+
+# Error message for command-line (usage) error:
+my $Usage = "Usage: $0 [-v] srcdir [...] destdir";
+# If "-v" option is specified, the number of links will be displayed.
+my $Verbose = 0;
+if (@ARGV && $ARGV[0] =~ /-v|--verbose/) {
+    $Verbose = 1;
+    shift;
+}
+# Required args: one or more source directories,
+#                one destination directory.
+die "$Usage\n" if scalar @ARGV < 2;
+my $Destdir = pop;
+$Destdir =~ s|(/images)?/?$||;
+my @Srcdirs = @ARGV;
+
+# Check for existance of directories:
+foreach (@Srcdirs, $Destdir) {
+    die "No such directory: $_\n" unless -d
+}
+
+# XXX: assuming destination = xml/LANG[/images]
+(my $Language = $Destdir) =~ s|.*/([^/]+)/?$|$1|;
+my $Translatable = (($Language =~ /^[a-z]{2}(_[A-Z]{2})?$/) &&
+                    ($Language ne "en"));
+
+# Create list of source directories:
+my @Image_dirs;
+find( sub { /^\.svn/ and ($File::Find::prune = 1)
+                             or
+            -d and push(@Image_dirs, $File::Find::name) 
+      },
+      @Srcdirs );
+die "Oops! Bug in search routine!\n" unless @Image_dirs;
+
+# See "perldoc -f symlink"
+my $Symlink_exists = eval { symlink("",""); 1 };
+# If verbose mode, the number of links will be displayed:
+my ($Count_all, $Count_i18n) = (0, 0);
+
+# Main routine:
+foreach my $srcdir (sort @Image_dirs) {
+    # Construct corresponding destination directory:
+    # XXX: assuming source = images/{C,common}
+    #      and destination = xml/LANG
+    (my $dstdir = $srcdir) =~ s|images/[^/]+|$Destdir/images|o;
+    mkpath $dstdir unless -d $dstdir;
+    # Get relative symlink pointing to image source directory
+    my $save_path = my $dst_to_src_path = abs2rel($srcdir, $dstdir);
+    foreach my $imgfile (glob "$srcdir/*.*") {
+        next unless -f $imgfile;
+        # Check for existance of localized image:
+        if ($Translatable) {
+            $dst_to_src_path = $save_path;
+            (my $localized_imgfile = $imgfile) =~ s|/C/|/$Language/|o;
+            $dst_to_src_path =~ s|/C/|/$Language/|o if -e $localized_imgfile;
+            ++$Count_i18n if $Verbose && -e _;
+        }
+        my $basename = (splitpath($imgfile))[2];  # (vol, dir, file)
+        # Create relative symlink to image file:
+        symlink(catfile($dst_to_src_path, $basename),
+                catfile($dstdir, $basename));
+        # XXX: this can be expanded to (an optimized version of)
+        #      "try hardlink, then symlink, then copy":
+        #          link(source, destination)
+        #                      or
+        #          $Symlink_exists and symlink(source, destination)
+        #                      or
+        #          copy(source, destination);
+        ++$Count_all if $Verbose;
+    }
+}
+
+# print number or created symlinks:
+print " ", $Count_all, ($Translatable ? " ($Language: $Count_i18n)" : ""), "\n"
+    if $Verbose;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]