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

Bug#628189: lintian: check for icons with a different size to the name of the directory they are in



tags 628189 patch
thanks

I've extended the icon-size-and-directory-name-mismatch tag to cover
all icons directories and added a new tag raster-image-in-scalable-directory.
See the attached patches.

I've checked some packages with these changes. Quite a few of them ship
icons whose size almost almost matches the directory name.
For example 16x14 instead of 16x16, 34x34 instead of 32x32 and 18x18
instead of 16x16.
We might want to relax the check to tolerate those since the difference is
probably not visible.

>      * scalable images (svg/svgz) in /usr/share/icons/*/<size>/*
>        directories

I think svg icons in <size> directories are valid since you might have multiple
svg images created for low/high resolutions.

Felix

>From a8c5a32d940f10ee81e3e8111d951b37d52ba139 Mon Sep 17 00:00:00 2001
From: Felix Geyer <debfx-pkg@fobos.de>
Date: Mon, 16 Apr 2012 18:24:30 +0200
Subject: [PATCH 1/2] c/files: Extend icon-size-and-directory-name-mismatch
 check

Extend icon-size-and-directory-name-mismatch to cover all icons directories.

Useful directories include:
/usr/share/icons
/usr/share/kde4/apps/amarok/icons
---
 checks/files                                |   16 ++++++++--------
 t/tests/files-general/debian/debian/install |    1 +
 t/tests/files-general/tags                  |    1 +
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/checks/files b/checks/files
index 27a4105..d5fdb8e 100644
--- a/checks/files
+++ b/checks/files
@@ -603,14 +603,6 @@ foreach my $file (@{$info->sorted_index}) {
             tag 'desktop-file-in-wrong-dir', $file;
         }
 
-        # ---------------- png files under /usr/share/apps/*/icons/*
-        elsif ($file =~ m,^usr/share/apps/[^/]+/icons/[^/]+/(\d+x\d+)/.*\.png$,) {
-            my ($dsize, $fsize) = ($1);
-            $info->file_info->{$file} =~ m/,\s*(\d+)\s*x\s*(\d+)\s*,/;
-            $fsize = $1.'x'.$2;
-            tag 'icon-size-and-directory-name-mismatch', $file, $fsize
-                unless ($dsize eq $fsize);
-        }
         # ---------------- non-games-specific data in games subdirectory
         elsif ($file =~ m,^usr/share/games/(?:applications|mime|icons|pixmaps)/,
                and $index_info->{type} !~ m/^d/) {
@@ -927,6 +919,14 @@ foreach my $file (@{$info->sorted_index}) {
         tag 'python-module-in-wrong-location', @correction if (@correction);
     }
 
+    if ($file =~ m,/icons/[^/]+/(\d+x\d+)/.*\.png$,) {
+        my ($dsize, $fsize) = ($1);
+        $info->file_info->{$file} =~ m/,\s*(\d+)\s*x\s*(\d+)\s*,/;
+        $fsize = $1.'x'.$2;
+        tag 'icon-size-and-directory-name-mismatch', $file, $fsize
+            unless ($dsize eq $fsize);
+    }
+
     # ---------------- plain files
     if ($index_info->{type} =~ m/^[-h]/) {
         # ---------------- backup files and autosave files
diff --git a/t/tests/files-general/debian/debian/install b/t/tests/files-general/debian/debian/install
index 98c7ba8..74606e9 100644
--- a/t/tests/files-general/debian/debian/install
+++ b/t/tests/files-general/debian/debian/install
@@ -1,4 +1,5 @@
 lintian-16x16.png usr/share/apps/lintian/icons/hicolor/22x22
+lintian-16x16.png usr/share/icons/hicolor/22x22/apps
 lintian-22x22.png usr/share/apps/lintian/icons/hicolor/22x22
 lintian-16x16.png usr/share/doc/lintian/
 lintian-22x22.png usr/share/games/icons/hicolor/22x22
diff --git a/t/tests/files-general/tags b/t/tests/files-general/tags
index d2d029c..b22e693 100644
--- a/t/tests/files-general/tags
+++ b/t/tests/files-general/tags
@@ -19,5 +19,6 @@ W: files-general: executable-not-elf-or-script usr/share/man/man5/foo.5.gz
 W: files-general: file-in-unusual-dir new-top-level-dir/file-in-new-top-level-dir
 W: files-general: file-name-ends-in-whitespace usr/share/foo/ws 
 W: files-general: icon-size-and-directory-name-mismatch usr/share/apps/lintian/icons/hicolor/22x22/lintian-16x16.png 16x16
+W: files-general: icon-size-and-directory-name-mismatch usr/share/icons/hicolor/22x22/apps/lintian-16x16.png 16x16
 W: files-general: obsolete-comments-style-in-php-ini etc/php5/conf.d/php-foo.ini
 W: files-general: windows-devel-file-in-package usr/lib/foo/foo.vcproj
-- 
1.7.9.5

>From 55765ea21ce9709d58181fe867cda24d35de3425 Mon Sep 17 00:00:00 2001
From: Felix Geyer <debfx-pkg@fobos.de>
Date: Mon, 16 Apr 2012 18:39:37 +0200
Subject: [PATCH 2/2] c/files: Add raster-image-in-scalable-directory tag

---
 checks/files                                |    4 ++++
 checks/files.desc                           |    6 ++++++
 t/tests/files-general/debian/debian/install |    1 +
 t/tests/files-general/desc                  |    1 +
 t/tests/files-general/tags                  |    1 +
 5 files changed, 13 insertions(+)

diff --git a/checks/files b/checks/files
index d5fdb8e..bd6db66 100644
--- a/checks/files
+++ b/checks/files
@@ -927,6 +927,10 @@ foreach my $file (@{$info->sorted_index}) {
             unless ($dsize eq $fsize);
     }
 
+    if ($file =~ m,/icons/[^/]+/scalable/.*\.(?:png|xpm)$,) {
+        tag 'raster-image-in-scalable-directory', $file;
+    }
+
     # ---------------- plain files
     if ($index_info->{type} =~ m/^[-h]/) {
         # ---------------- backup files and autosave files
diff --git a/checks/files.desc b/checks/files.desc
index cb62a01..c58e798 100644
--- a/checks/files.desc
+++ b/checks/files.desc
@@ -984,6 +984,12 @@ Info: The icon has a size that differs from the size specified by the name
  of the directory under which it was installed.  The icon was probably
  mistakenly installed into the wrong directory.
 
+Tag: raster-image-in-scalable-directory
+Severity: normal
+Certainty: certain
+Info: The given raster image was installed into a "scalable" icon directory.
+ Only vector graphics (e.g. SVG) should be installed into those directories.
+
 Tag: gz-file-not-gzip
 Severity: normal
 Certainty: possible
diff --git a/t/tests/files-general/debian/debian/install b/t/tests/files-general/debian/debian/install
index 74606e9..4ce9d68 100644
--- a/t/tests/files-general/debian/debian/install
+++ b/t/tests/files-general/debian/debian/install
@@ -3,6 +3,7 @@ lintian-16x16.png usr/share/icons/hicolor/22x22/apps
 lintian-22x22.png usr/share/apps/lintian/icons/hicolor/22x22
 lintian-16x16.png usr/share/doc/lintian/
 lintian-22x22.png usr/share/games/icons/hicolor/22x22
+lintian-16x16.png usr/share/icons/hicolor/scalable/apps
 --lzma etc/modprobe.d
 lintian.conf etc/modprobe.d
 dir usr/share/info
diff --git a/t/tests/files-general/desc b/t/tests/files-general/desc
index 91d109e..aabf83a 100644
--- a/t/tests/files-general/desc
+++ b/t/tests/files-general/desc
@@ -22,6 +22,7 @@ Test-For:
  package-contains-mime-cache-file
  package-contains-mimeinfo.cache-file
  package-modifies-ld.so-search-path
+ raster-image-in-scalable-directory
  star-file
  stray-directory-in-manpage-directory
  windows-devel-file-in-package
diff --git a/t/tests/files-general/tags b/t/tests/files-general/tags
index b22e693..329a24c 100644
--- a/t/tests/files-general/tags
+++ b/t/tests/files-general/tags
@@ -21,4 +21,5 @@ W: files-general: file-name-ends-in-whitespace usr/share/foo/ws
 W: files-general: icon-size-and-directory-name-mismatch usr/share/apps/lintian/icons/hicolor/22x22/lintian-16x16.png 16x16
 W: files-general: icon-size-and-directory-name-mismatch usr/share/icons/hicolor/22x22/apps/lintian-16x16.png 16x16
 W: files-general: obsolete-comments-style-in-php-ini etc/php5/conf.d/php-foo.ini
+W: files-general: raster-image-in-scalable-directory usr/share/icons/hicolor/scalable/apps/lintian-16x16.png
 W: files-general: windows-devel-file-in-package usr/lib/foo/foo.vcproj
-- 
1.7.9.5


Reply to: