r120 - in trunk/debian: . patches

rousseau at alioth.debian.org rousseau at alioth.debian.org
Sun Aug 12 16:25:51 UTC 2007


Author: rousseau
Date: 2007-08-12 16:25:51 +0000 (Sun, 12 Aug 2007)
New Revision: 120

Added:
   trunk/debian/patches/18_bins-memory-leak.dpatch
   trunk/debian/patches/19_bins-insert-directory.dpatch
   trunk/debian/patches/20_bins-syscall.dpatch
Modified:
   trunk/debian/changelog
   trunk/debian/patches/00list
Log:
debian/patches/{18_bins-memory-leak,19_bins-insert-directory,
20_bins-syscall}.dpatch: Closes: #395098 "Bins is very slow, eats memory
and makes unnecessary system calls"


Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2007-07-04 20:45:37 UTC (rev 119)
+++ trunk/debian/changelog	2007-08-12 16:25:51 UTC (rev 120)
@@ -1,3 +1,11 @@
+bins (1.1.29-9) unstable; urgency=low
+
+  * debian/patches/{18_bins-memory-leak,19_bins-insert-directory,
+    20_bins-syscall}.dpatch: Closes: #395098 "Bins is very slow, eats memory
+    and makes unnecessary system calls"
+
+ -- Ludovic Rousseau <rousseau at debian.org>  Sun, 12 Aug 2007 18:23:53 +0200
+
 bins (1.1.29-8) unstable; urgency=low
 
   * debian/patches/17_bins.dpatch: use localtime instead of gmtime

Modified: trunk/debian/patches/00list
===================================================================
--- trunk/debian/patches/00list	2007-07-04 20:45:37 UTC (rev 119)
+++ trunk/debian/patches/00list	2007-08-12 16:25:51 UTC (rev 120)
@@ -12,3 +12,6 @@
 15_example_css
 16_examples_html
 17_bins
+18_bins-memory-leak
+19_bins-insert-directory
+20_bins-syscall

Added: trunk/debian/patches/18_bins-memory-leak.dpatch
===================================================================
--- trunk/debian/patches/18_bins-memory-leak.dpatch	                        (rev 0)
+++ trunk/debian/patches/18_bins-memory-leak.dpatch	2007-08-12 16:25:51 UTC (rev 120)
@@ -0,0 +1,215 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 18_bins-1.1.29-memory-leak.dpatch by  <rousseau at localhost.localdomain>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+ at DPATCH@
+diff -urNad bins-1.1.29~/bins bins-1.1.29/bins
+--- bins-1.1.29~/bins	2005-08-25 00:07:06.000000000 +0200
++++ bins-1.1.29/bins	2007-08-12 17:55:56.000000000 +0200
+@@ -449,13 +449,13 @@
+ $defaultConfig{fileActiveSizeNames} = \@fileActiveSizeNames;
+ 
+ # Fields to display (in the list order) under the picture. These
+-# fields are defined in the getFields function below.
++# fields are defined in the %fields hash below.
+ my @mainFields = ("description", "people", "location", "date",
+                                   "event", "comment");
+ 
+ 
+ # Fields to display (in the list order) in the details page. These
+-# fields are in the getFields function below.
++# fields are in the %fields hash below.
+ my @secondaryFields = (
+                        # DigiCam
+                        _("BINS-SECTION DigiCam Info"),
+@@ -519,7 +519,6 @@
+                        "BINS-SECTION end", # close the last section
+                        );
+ 
+-sub getFields {
+     # The key is the string used as the name in the picture
+     #   description file.
+     # Name corresponds to the string displayed under the picture.
+@@ -527,9 +526,8 @@
+     #   found in some JPEG images.
+     # The value of the EXIF structure is only used if no value
+     #   is present in the picture description file.
+-    # Transform is a Perl operator used to convert an exif value
+-    #   to the desired format to display.  It is evaluated as
+-    #   normal Perl code and the result has to be in $_.
++    # Note: See also postProcessHashArrays() for dateString related
++    # items
+     my %fields =
+           (
+          "title" =>
+@@ -547,12 +545,6 @@
+          "date" =>
+          { Name => _("Date"),
+            EXIF => "DateTimeOriginal",
+-           Transform => '$_ = local2html(strftime $configHash->{dateString}, localtime str2time "$_") if str2time "$_"',
+-           # Alternatively, you could use regex substitution:
+-           # English version is yyyy:mm:dd hh:mm:ss to yyyy/mm/dd hh:mm:ss :
+-           # Transform => 's%^(\\d+):(\\d+):(\\d+) (.*)$%\$1/\$2/\$3 \$4%',
+-           # French version is yyyy:mm:dd hh:mm:ss to dd/mm/yyyy hh:mm:ss :
+-           # Transform => 's%^(\d+):(\d+):(\d+) (.*)$%$3/$2/$1 $4%',
+                  },
+ 
+              "event" =>
+@@ -822,8 +814,6 @@
+            Tip => _("Indicates the image sensor type on the camera or input device."),
+        },
+          );
+-    return \%fields;
+-}
+ 
+ my @priorityExifTags = ();  # the field in this list are taken from
+ # the desc file, even if they are present
+@@ -847,10 +837,10 @@
+                 });
+ $defaultConfig{colorsSubs} = \%colorsSubs;
+ 
+-sub getIntlSubs{
+-    my $configHash = shift;
+-    # Strings to translate in the HTML template pages (if I18N is used)
+-    my %intlSubs = (  STRING_THUMBNAILS   => _("thumbnails"),
++# Strings to translate in the HTML template pages (if I18N is used)
++# Note: See also postProcessHashArrays() for dateString related
++# items
++my %intlSubs = (  STRING_THUMBNAILS   => _("thumbnails"),
+                       STRING_IMAGELIST    => _("Image List"),
+                       STRING_HOME => _("Home"),
+                       STRING_ALBUM => _("Album"),
+@@ -882,13 +872,11 @@
+                       BINS_VERSION             => "1.1.29",
+                       ENCODING                 => $defaultConfig{htmlEncoding},
+                       GENERATED_DATE       => _("on ").
+-                      local2html(strftime($configHash->{dateString},
++                      local2html(strftime($defaultConfig{dateString},
+                                           localtime)),
+                       BINS_ID =>
+                       '<!--$Id: bins,v 1.182 2005/08/22 23:52:33 jerome Exp $-->',
+                       );
+-    return \%intlSubs;
+-}
+ 
+ # @knownImageExtentions defines file extensions that BINS can handle as
+ # input image. BINS _should_ handle all input format of ImageMagick
+@@ -925,6 +913,7 @@
+ sub beVerboseN;
+ sub min;
+ sub readConfigFile;
++sub postProcessHashArrays;
+ sub fileSize;
+ sub generateAlbumPages;
+ sub filenameToPreviewName;
+@@ -942,8 +931,6 @@
+ sub trimWhiteSpace;
+ sub stringToBool;
+ sub ignoreSet;
+-sub getFields;
+-sub getIntlSubs;
+ 
+ sub generateThumbnailPages;
+ sub generateThumbEntry;
+@@ -1005,6 +992,27 @@
+     return \%option;
+ }
+ 
++# process hash arrays after reading config file
++# a non-default value of dateString might have been read from the
++# configuration file, so the proper values must be inserted into the
++# %fields and %intlSubs hash arrays
++sub postProcessHashArrays {
++    my $configHash = shift;
++
++    # Transform is a Perl operator used to convert an exif value
++    #   to the desired format to display.  It is evaluated as
++    #   normal Perl code and the result has to be in $_.
++    $fields{date}{Transform} =
++        '$_ = local2html(strftime $configHash->{dateString}, localtime str2time "$_")';
++           # Alternatively, you could use regex substitution:
++           # English version is yyyy:mm:dd hh:mm:ss to yyyy/mm/dd hh:mm:ss :
++           # Transform => 's%^(\\d+):(\\d+):(\\d+) (.*)$%\$1/\$2/\$3 \$4%',
++           # French version is yyyy:mm:dd hh:mm:ss to dd/mm/yyyy hh:mm:ss :
++           # Transform => 's%^(\d+):(\d+):(\d+) (.*)$%$3/$2/$1 $4%',
++    $intlSubs{GENERATED_DATE} = _("on ").
++            local2html(strftime($configHash->{dateString}, localtime)),
++}
++
+ # process command line arguments after reading config file
+ sub postProcessArgs {
+     my $option = shift;
+@@ -1257,6 +1265,9 @@
+     # read configurations files
+     my $defaultConfig = readConfigFile(\%defaultConfig);
+ 
++    # post process %fields and %intlSubs hash arrays
++    postProcessHashArrays($defaultConfig);
++
+     # post process command line args after reading config files
+     postProcessArgs($options, $defaultConfig);
+ 
+@@ -2934,7 +2945,7 @@
+             $sectionTitle = $tagName;
+             $sectionTitle =~ s/^BINS-SECTION //;
+         }else{
+-            $tagValue = getFields($configHash)->{$tagName};
++            $tagValue = $fields{$tagName};
+             if ($imageInfo->{$tagName}) {
+                 my %row = (FIELD_NAME => $tagValue->{'Name'},
+                            FIELD_VALUE => local2html($imageInfo->{$tagName})
+@@ -2989,7 +3000,7 @@
+     $subs_hash{CUSTOM_CSS} = $configHash->{customStyleSheet};
+ 
+     my @array;
+-    push @array, {NAV_NAME => getIntlSubs($configHash)->{STRING_BACKTOTHEIMAGE},
++    push @array, {NAV_NAME => $intlSubs{STRING_BACKTOTHEIMAGE},
+                   NAV_LINK => "javascript:history.back();",
+                   NAV_ICON => "back.png",
+                   NAV_ID => "back"};
+@@ -3646,7 +3657,7 @@
+         if (${%$hashref}{$tagName}) {
+             my $value=${%$hashref}{$tagName};
+             $value =~ s/'/&#39;/g  ; # in case it's used in javascript code
+-            push @descTable, {DESC_FIELD_NAME => getFields($configHash)->{$tagName}->{'Name'},
++            push @descTable, {DESC_FIELD_NAME => $fields{$tagName}->{'Name'},
+                               DESC_FIELD_VALUE => $value,
+                           };
+         }
+@@ -3791,7 +3802,7 @@
+     %{$templateParameters} =
+         (%{$templateParameters},
+          %{$configHash->{colorsSubs}{$configHash->{colorStyle}}},
+-         %{getIntlSubs($configHash)},
++         %intlSubs,
+          );
+ 
+     # open the html template
+@@ -3919,7 +3930,7 @@
+                 && $element->{Name} eq "field") {
+                 $fieldName = $element->{Attributes}{'name'};
+                 $fieldValue = "";
+-                if (grep (/^$fieldName$/, keys(%{getFields($configHash)}))) {
++                if (grep (/^$fieldName$/, keys(%fields))) {
+                     beVerbose("    Reading field '$fieldName':", 3);
+                     foreach my $characters (@{$element->{Contents}}) {
+                         #if (UNIVERSAL::isa($characters, 'XML::Grove::Characters')) {
+@@ -4345,13 +4356,13 @@
+     }
+ 
+     # add value to desc Hash if field is void
+-    foreach my $field (keys(%{getFields($configHash)})) {
+-        my $fieldExif = getFields($configHash)->{$field}->{'EXIF'};
++    foreach my $field (keys(%fields)) {
++        my $fieldExif = $fields{$field}->{'EXIF'};
+         if ((! $descHash->{$field}) && $fieldExif && $exifHash->{$fieldExif}) {
+             beVerboseN("  Using '$field' from EXIF data: ".
+                        $exifHash->{$fieldExif}, 3);
+ 
+-            my $func = getFields($configHash)->{$field}->{'Transform'};
++            my $func = $fields{$field}->{'Transform'};
+             if ($func) {
+                 $_ = $exifHash->{$fieldExif};
+                 beVerbose("  Evaluating '$func' from '$_'", 4);


Property changes on: trunk/debian/patches/18_bins-memory-leak.dpatch
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/debian/patches/19_bins-insert-directory.dpatch
===================================================================
--- trunk/debian/patches/19_bins-insert-directory.dpatch	                        (rev 0)
+++ trunk/debian/patches/19_bins-insert-directory.dpatch	2007-08-12 16:25:51 UTC (rev 120)
@@ -0,0 +1,148 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 19_bins-1.1.29-insert-directory.dpatch by  <rousseau at localhost.localdomain>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+ at DPATCH@
+diff -urNad bins-1.1.29~/bins bins-1.1.29/bins
+--- bins-1.1.29~/bins	2005-08-25 00:07:06.000000000 +0200
++++ bins-1.1.29/bins	2007-08-12 17:56:20.000000000 +0200
+@@ -399,6 +399,10 @@
+                                            # strings on console and to
+                                            # convert strings from .po
+                                            # files.
++
++     injectDir      => '',                  # directory to be injected
++                                            # without rebuilding complete
++                                            # album
+      );
+ 
+ my $codeset;
+@@ -988,7 +992,7 @@
+     Getopt::Long::Configure("bundling");
+     die "Invalid options\n"
+         if (!GetOptions(\%option, "h", "p", "r:s", "e", "o:s", "t=s", "d=s", "s=s",
+-                        "c=s", "v:i", "i=s", "n=s", "f=s"));
++                        "c=s", "v:i", "i=s", "n=s", "f=s", "j=s"));
+ 
+     if (defined($option{v})) {
+         $verbose = $option{v};
+@@ -1123,6 +1127,25 @@
+ 
+         die "albumdir_dir ($albumdir) can't be a subdirectory of picdir_dir ($picdir)"
+             if ($albumdir2 =~ m/^$picdir2\//);
++
++        if( defined $option{j} ) {
++            my $injectDir = $option{j};
++            my $injectExists = 1;
++
++            chdir $injectDir or warn "Can't chdir $injectDir: $!" and $injectExists = 0;
++
++            if( $injectExists ) {
++                $injectDir = File::Spec->rel2abs(".") unless -l $option{j};
++                chdir $pwd;
++            }
++
++            die "inject_dir (specified via -j parameter) $option{j} must be a subdirectory of pic_dir ($picdir)"
++                unless $injectDir =~ m#^$picdir2/.*#;
++
++            $configHash->{injectDir}
++                = File::Spec->rel2abs(File::Spec->canonpath($injectDir));
++            $configHash->{injectDir} .= '/';        # add trailing slash
++        }
+     }
+ 
+     $picdir = File::Spec->rel2abs(File::Spec->canonpath($picdir));
+@@ -2151,6 +2174,16 @@
+ 
+ sub generateImageListPage{
+     my ($album, $albumHashRef, $imageDataRef, $xlinksRef, $configHash) = @_;
++    if( $configHash->{injectDir} ne '' ) {
++        my $injectDir = $configHash->{injectDir};
++        my $oneDirUp;
++        # drop the last subdirectory
++        ( $oneDirUp = $configHash->{injectDir} ) =~ s#(.*/).*?/$#$1#o;
++        my $dir = $picdir . $album;
++        # Only generate imagelist page during injection
++        # for 1-level-up or injected album itself
++        return unless $dir =~ m#($oneDirUp|$injectDir)$#;
++    }
+     my %albumHash = %{$albumHashRef};
+     my @imageData = @{$imageDataRef};
+     my $pwd;
+@@ -2361,6 +2394,18 @@
+ 
+ sub generateLongSubAlbumPage{
+     my ($album, $albumHashRef, $configHash) = @_;
++    if( $configHash->{injectDir} ne '' ) {
++        my $injectDir = $configHash->{injectDir};
++        my( $oneDirUp, $twoDirUp );
++        # drop the last subdirectory
++        ( $oneDirUp = $configHash->{injectDir} ) =~ s#(.*/).*?/$#$1#o;
++        # drop the last subdirectory
++        ( $twoDirUp = $oneDirUp ) =~ s#(.*/).*?/$#$1#o;
++        my $dir = $picdir . $album;
++        # Only generate subalbum page during injection for
++        # 1-level-up or 2-level-up or injected album itself
++        return unless $dir =~ m#($oneDirUp|$twoDirUp|$injectDir)$#;
++    }
+     my %albumHash = %{$albumHashRef};
+ 
+     # hash for final subsitutions
+@@ -2641,6 +2686,18 @@
+     my ($album, $albumHashRef, $firstIsIndex, $configHash,
+         $xlinkListRef,
+         @imageData) = @_;
++
++    if( $configHash->{injectDir} ne '' ) {
++        my $injectDir = $configHash->{injectDir};
++        my $oneDirUp;
++        # drop the last subdirectory
++        ( $oneDirUp = $configHash->{injectDir} ) =~ s#(.*/).*?/$#$1#o;
++        my $dir = $picdir . $album;
++        # Only generate thumbnail page during injection for
++        # 1-level-up or injected album itself
++        return unless $dir =~ m#($oneDirUp|$injectDir)$#;
++    }
++
+     my @xlinkList=@$xlinkListRef;
+     my %albumHash = %{$albumHashRef};
+     my $numImages = scalar(@imageData); #element count
+@@ -3056,6 +3113,13 @@
+     my ($album, $albumHashRef, $firstIsIndex,
+         $configHash, @imagesToDisplay) = @_;
+ 
++    my $skipDueToInjection = 0;
++
++    if( $configHash->{injectDir} ne '' ) {
++        # skip processing of images unless processing injected directory
++        $skipDueToInjection = 1 unless $picdir . $album eq $configHash->{injectDir};
++    }
++
+     # an array of references to hashes storing information about each image
+     my @imageData;
+ 
+@@ -3311,10 +3375,12 @@
+         $imageData[$i]{'detailsLink'} =
+             generateSecondaryFieldsPage($imageData[$i], $album, $albumHashRef,
+                                         $crntImageBase.$crntImageType,
+-                                        $configHash);
++                                        $configHash)
++                unless $skipDueToInjection;
+         if ( $configHash->{searchEngine}) {
+             writeSearchString($imageData[$i], $configHash, $albumHashRef,
+-                              $album);
++                              $album)
++                unless $skipDueToInjection;
+         }
+     }
+ 
+@@ -3322,6 +3388,7 @@
+ 
+     # now generate html
+     for ($i=0; $i<$numImages; $i++) {
++        last if $skipDueToInjection;
+         for (my $j=0; $j <= $imageData[$i]->{maxSize}; $j++) {
+             my $lastImageURL = getHTMLImagePageLink($imageData[$numImages-1],
+                                                     $j, $numImages-1);


Property changes on: trunk/debian/patches/19_bins-insert-directory.dpatch
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/debian/patches/20_bins-syscall.dpatch
===================================================================
--- trunk/debian/patches/20_bins-syscall.dpatch	                        (rev 0)
+++ trunk/debian/patches/20_bins-syscall.dpatch	2007-08-12 16:25:51 UTC (rev 120)
@@ -0,0 +1,36 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 20_bins-1.1.29-syscall.dpatch by  <rousseau at localhost.localdomain>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+ at DPATCH@
+diff -urNad bins-1.1.29~/bins bins-1.1.29/bins
+--- bins-1.1.29~/bins	2005-08-25 00:07:06.000000000 +0200
++++ bins-1.1.29/bins	2007-08-12 17:56:39.000000000 +0200
+@@ -3440,13 +3440,14 @@
+                     $newpath = "$picdir$origName";
+                 }
+                 beVerboseN("Linking from $albumdir$newName to $newpath... ", 2);
+-                system("ln", "-sf", $newpath, "$albumdir$newName") == 0
++                unlink("$albumdir$newName");
++                symlink($newpath, "$albumdir$newName") == 1
+                     or die("\nCannot link $albumdir$newName to $newpath: $?");
+                 # the original file may be r/o but we don't have to modify it
+                 # but it must be readable by the http deamon
+                 if ($configHash->{updateOriginalPerms})
+                 {
+-                    system("chmod", "a+r", "$picdir$origName") == 0
++                    chmod(0644, "$picdir$origName") == 1
+                         or die("\nCannot set read permission on $albumdir$newName: $?");
+                 }
+                 beVerboseN("done.", 2);
+@@ -3457,7 +3458,7 @@
+                 system("cp", "-p", "$picdir$origName", "$albumdir$newName") == 0
+                     or die("\nCannot copy $picdir$origName to $albumdir$newName: $?");
+                 # make it writable in case $origName was r/o
+-                system("chmod", "u+w,a+r", "$albumdir$newName") == 0
++                chmod(0644, "$albumdir$newName") == 1
+                     or die("\nCannot set write permission on $albumdir$newName: $?");
+                 beVerboseN("done.", 2);
+                 return 1;


Property changes on: trunk/debian/patches/20_bins-syscall.dpatch
___________________________________________________________________
Name: svn:executable
   + *




More information about the pkg-bins-commits mailing list