[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-270-g89973c5

2011-08-20 Thread Guillem Jover
The following commit has been merged in the master branch:
commit ffc6888c5721e5e4451d8135827936fca761b157
Author: Guillem Jover guil...@debian.org
Date:   Sun Aug 14 22:45:20 2011 +0200

deb-src-control(5): Use linux-any in example control stanza

Instead of using the negated list of not supported architectures, just
use the positive form, which should be considered current best practice.

diff --git a/man/deb-src-control.5 b/man/deb-src-control.5
index 6fc32f9..76e2f9e 100644
--- a/man/deb-src-control.5
+++ b/man/deb-src-control.5
@@ -300,7 +300,7 @@ Vcs\-Browser: http://git.debian.org/?p=dpkg/dpkg.git
 Vcs\-Git: git://git.debian.org/git/dpkg/dpkg.git
 Standards\-Version: 3.7.3
 Build\-Depends: pkg\-config, debhelper (= 4.1.81),
- libselinux1\-dev (= 1.28\-4) [!hurd\-i386 !kfreebsd\-i386 !kfreebsd\-amd64]
+ libselinux1\-dev (= 1.28\-4) [!linux\-any]
 
 Package: dpkg\-dev
 Section: utils

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-270-g89973c5

2011-08-20 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 5c6be96b1c88c40d002a25295891ec81d8764f90
Author: Guillem Jover guil...@debian.org
Date:   Sun Aug 14 23:28:07 2011 +0200

dpkg-deb(1): Clarify the default compression-levels

diff --git a/debian/changelog b/debian/changelog
index 7259c77..24d45c2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -191,6 +191,7 @@ dpkg (1.16.1) UNRELEASED; urgency=low
 been fsync()ed and cannot be executed causing ETXTBSY when trying
 to open the to be installed paths for writing.
 Thanks to Jonathan Nieder jrnie...@gmail.com. Closes: #635683
+  * Clarify the default dpkg-deb compression-levels on the man page.
 
   [ Updated dpkg translations ]
   * German (Sven Joachim). Closes: #620312
diff --git a/man/dpkg-deb.1 b/man/dpkg-deb.1
index 4bf7ad6..26b684c 100644
--- a/man/dpkg-deb.1
+++ b/man/dpkg-deb.1
@@ -195,8 +195,8 @@ explanation of the \fB\-\-showformat\fP option in
 The default for this field is ${Package}\\t${Version}\\n.
 .TP
 .BI \-z compress-level
-Specify which compression level to pass to the compressor backend program,
-when building a package.
+Specify which compression level to use on the compressor backend, when
+building a package (default is 9 for gzip and bzip2, 6 for xz and lzma).
 .TP
 .BI \-Z compress-type
 Specify which compression type to use when building a package. Allowed

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-270-g89973c5

2011-08-20 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 62449a0a27ab1231ed81267f7ee5421b9f7fcb0c
Author: Guillem Jover guil...@debian.org
Date:   Sun Aug 14 23:45:36 2011 +0200

Expand numeric literals and word abbreviation in usage error output

This avoids unneeded abbreviations, uses correct english, and should
help translators.

diff --git a/scripts/dpkg-scanpackages.pl b/scripts/dpkg-scanpackages.pl
index df900a0..35c2d86 100755
--- a/scripts/dpkg-scanpackages.pl
+++ b/scripts/dpkg-scanpackages.pl
@@ -155,7 +155,7 @@ sub load_override_extra
 usage() and exit 1 if not $result;
 
 if (not @ARGV = 1  @ARGV = 3) {
-usageerr(_g(1 to 3 args expected));
+usageerr(_g(one to three arguments expected));
 }
 
 my $type = defined($options{type}) ? $options{type} : 'deb';
diff --git a/scripts/dpkg-scansources.pl b/scripts/dpkg-scansources.pl
index 8c4e46d..777fec3 100755
--- a/scripts/dpkg-scansources.pl
+++ b/scripts/dpkg-scansources.pl
@@ -299,7 +299,7 @@ sub main {
 my (@out);
 
 GetOptions(@Option_spec) or usage;
-@ARGV = 1  @ARGV = 3 or usageerr(_g(1 to 3 args expected\n));
+@ARGV = 1  @ARGV = 3 or usageerr(_g(one to three arguments 
expected));
 
 push @ARGV, undef  if @ARGV  2;
 push @ARGV, '' if @ARGV  3;

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-270-g89973c5

2011-08-20 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 4fdbd69d7b8ca2fff39798a6e6fc5fa3e229c66b
Author: Guillem Jover guil...@debian.org
Date:   Mon Aug 15 00:01:53 2011 +0200

dpkg-parsechangelog: Remove duplicate program name from usage error output

diff --git a/scripts/dpkg-parsechangelog.pl b/scripts/dpkg-parsechangelog.pl
index 34bf3fb..2ab7608 100755
--- a/scripts/dpkg-parsechangelog.pl
+++ b/scripts/dpkg-parsechangelog.pl
@@ -114,7 +114,7 @@ while (@ARGV) {
 }
 }
 
-@ARGV  usageerr(_g(%s takes no non-option arguments), $progname);
+@ARGV  usageerr(_g(takes no non-option arguments));
 
 my $count = 0;
 my @fields = changelog_parse(%options);

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-270-g89973c5

2011-08-20 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 36954c36abe3ce8e42b3c231579ef9e497f0da6d
Author: Guillem Jover guil...@debian.org
Date:   Fri Aug 19 12:59:35 2011 +0200

Dpkg::Compression: Change default values depending on the compressor used

This makes dpkg-source use more appropriate default compression values
depending on the compressor used.

Prompted-by: Timo Juhani Lindfors timo.lindf...@iki.fi

diff --git a/debian/changelog b/debian/changelog
index 9f29809..ec2e9ae 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -193,6 +193,9 @@ dpkg (1.16.1) UNRELEASED; urgency=low
 Thanks to Jonathan Nieder jrnie...@gmail.com. Closes: #635683
   * Clarify the default dpkg-deb compression-levels on the man page.
   * Clarify dpkg --update-avail usage error message. Closes: #628055
+  * Change Dpkg::Compression default values depending on the compressor
+used, and as such dpkg-source inherits this functionality.
+Prompted by Timo Juhani Lindfors timo.lindf...@iki.fi.
 
   [ Updated dpkg translations ]
   * German (Sven Joachim). Closes: #620312
diff --git a/man/dpkg-source.1 b/man/dpkg-source.1
index d339303..e124fe6 100644
--- a/man/dpkg-source.1
+++ b/man/dpkg-source.1
@@ -153,7 +153,7 @@ dpkg\-dev 1.15.5.
 Compression level to use. As with \fB\-Z\fP it only affects newly created
 files. Supported values are:
 .IR 1  to  9 ,  best , and  fast .
-\fI9\fP is the default.
+The default is \fI9\fP for gzip and bzip2, \fI6\fP for xz and lzma.
 .TP
 .BR \-i [\fIregexp\fP],  \-\-diff\-ignore [=\fIregexp\fP]
 You may specify a perl regular expression to match files you want
diff --git a/scripts/Dpkg/Compression.pm b/scripts/Dpkg/Compression.pm
index 0a5ed94..c83fb4e 100644
--- a/scripts/Dpkg/Compression.pm
+++ b/scripts/Dpkg/Compression.pm
@@ -18,7 +18,7 @@ package Dpkg::Compression;
 use strict;
 use warnings;
 
-our $VERSION = 1.00;
+our $VERSION = 1.01;
 
 use Dpkg::ErrorHandling;
 use Dpkg::Gettext;
@@ -54,26 +54,30 @@ my $COMP = {
file_ext = gz,
comp_prog = [ gzip, --no-name, --rsyncable ],
decomp_prog = [ gunzip ],
+   default_level = 9,
 },
 bzip2 = {
file_ext = bz2,
comp_prog = [ bzip2 ],
decomp_prog = [ bunzip2 ],
+   default_level = 9,
 },
 lzma = {
file_ext = lzma,
comp_prog = [ 'xz', '--format=lzma' ],
decomp_prog = [ 'unxz', '--format=lzma' ],
+   default_level = 6,
 },
 xz = {
file_ext = xz,
comp_prog = [ xz ],
decomp_prog = [ unxz ],
+   default_level = 6,
 },
 };
 
 our $default_compression = gzip;
-our $default_compression_level = 9;
+our $default_compression_level = undef;
 
 =item $compression_re_file_ext
 
@@ -117,6 +121,7 @@ sub compression_is_supported {
 Returns the requested property of the compression method. Returns undef if
 either the property or the compression method doesn't exist. Valid
 properties currently include file_ext for the file extension,
+default_level for the default compression level,
 comp_prog for the name of the compression program and decomp_prog for
 the name of the decompression program.
 
@@ -173,25 +178,29 @@ sub compression_set_default {
 =item my $level = compression_get_default_level()
 
 Return the default compression level used when compressing data. It's 9
-unless Ccompression_set_default_level has been used to change it.
+for gzip and bzip2, 6 for xz and lzma, unless
+Ccompression_set_default_level has been used to change it.
 
 =item compression_set_default_level($level)
 
-Change the default compression level. Errors out if the
+Change the default compression level. Passing undef as the level will
+reset it to the compressor specific default, otherwise errors out if the
 level is not valid (see Ccompression_is_valid_level).
-either a number between 1 and 9 or fast
-or best.
 
 =cut
 
 sub compression_get_default_level {
-return $default_compression_level;
+if (defined $default_compression_level) {
+return $default_compression_level;
+} else {
+return compression_get_property($default_compression, default_level);
+}
 }
 
 sub compression_set_default_level {
 my ($level) = @_;
 error(_g(%s is not a compression level), $level)
-unless compression_is_valid_level($level);
+unless !defined($level) or compression_is_valid_level($level);
 $default_compression_level = $level;
 }
 
diff --git a/scripts/t/850_Dpkg_Compression.t b/scripts/t/850_Dpkg_Compression.t
index b792905..a8054f6 100644
--- a/scripts/t/850_Dpkg_Compression.t
+++ b/scripts/t/850_Dpkg_Compression.t
@@ -13,11 +13,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see http://www.gnu.org/licenses/.
 
-use Test::More tests = 9;
+use Test::More tests = 13;
 
 use strict;
 use warnings;
 
+use_ok('Dpkg::Compression');
 use_ok('Dpkg::Compression::FileHandle');
 
 my $tmpdir = 

[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-270-g89973c5

2011-08-20 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 31242e1aaabe7750b2b68ee96306e2cbdfd767bb
Author: Guillem Jover guil...@debian.org
Date:   Sat Aug 20 12:30:35 2011 +0200

u-a: Rename get_all_alternatives() to altdb_get_namelist()

This makes it clear we are referring to the filenames in the database
directory.

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 9b0548a..0bea4b5 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -399,7 +399,7 @@ filter_altdir(const struct dirent *entry)
 }
 
 static int
-get_all_alternatives(struct dirent ***table)
+altdb_get_namelist(struct dirent ***table)
 {
int count;
 
@@ -480,7 +480,7 @@ config_all(void)
struct dirent **table;
int i, count;
 
-   count = get_all_alternatives(table);
+   count = altdb_get_namelist(table);
for (i = 0; i  count; i++) {
subcall(prog_path, --config, table[i]-d_name, NULL);
printf(\n);
@@ -2204,7 +2204,7 @@ main(int argc, char **argv)
alt_map_obj = alternative_map_new(NULL, NULL);
alt_map_links = alternative_map_new(NULL, NULL);
alt_map_parent = alternative_map_new(NULL, NULL);
-   count = get_all_alternatives(table);
+   count = altdb_get_namelist(table);
for (i = 0; i  count; i++) {
struct slave_link *sl;
struct alternative *a_new = alternative_new(table[i]-d_name);

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-270-g89973c5

2011-08-20 Thread Guillem Jover
The following commit has been merged in the master branch:
commit a27a8e1989b0937e9eee18c2153524c755aba058
Author: Guillem Jover guil...@debian.org
Date:   Sat Aug 20 09:51:13 2011 +0200

Do not use possessive «'s» after ‘s’ or ‘x’

diff --git a/debian/changelog b/debian/changelog
index 9aed1a7..9f29809 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1906,7 +1906,7 @@ dpkg (1.15.0) experimental; urgency=low
 - Cleanup and split of header files.
 
   [ Raphaël Hertzog ]
-  * Enhance dpkg-shlibdeps's error message when a library can't be found to
+  * Enhance dpkg-shlibdeps' error message when a library can't be found to
 include the ELF format of the desired library. Closes: #474671
   * dpkg-gensymbols now refuses empty values for the the -v -P and -e
 parameters.
@@ -2717,7 +2717,7 @@ dpkg (1.14.16) unstable; urgency=low
 is used. That way we're consistent with the definition of that variable
 in deb-substvars(5). Closes: #433477
   * Add support of Dm-Upload-Allowed field. Closes: #453400
-  * Fix dpkg-shlibdeps's filtering of duplicated dependencies in fields of
+  * Fix dpkg-shlibdeps' filtering of duplicated dependencies in fields of
 lesser priority (when -d is used).
   * Fix behaviour of dpkg-shlibdeps when the same binary was passed multiple
 times for use in different dependency fields (-d option).
diff --git a/man/dpkg-shlibdeps.1 b/man/dpkg-shlibdeps.1
index 96906e6..9bbc8eb 100644
--- a/man/dpkg-shlibdeps.1
+++ b/man/dpkg-shlibdeps.1
@@ -277,8 +277,8 @@ the RPATH of the binary, directories listed in 
/etc/ld.so.conf,
 directories listed in the LD_LIBRARY_PATH environment variable, and
 standard public directories (/lib, /usr/lib, /lib32, /usr/lib32, /lib64,
 /usr/lib64). Then it checks those directories in the package's build tree
-of the binary being analyzed, in the packages's build trees indicated with
-the \-S command-line option, in other packages's build trees that contains
+of the binary being analyzed, in the packages' build trees indicated with
+the \-S command-line option, in other packages' build trees that contains
 a DEBIAN/shlibs or DEBIAN/symbols file and finally in the root directory.
 If the library is not found in any of those directories, then you get this
 error.
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index 46295c0..6503ce5 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -116,7 +116,7 @@
 #endif
 
 #if defined(OSLinux)
-/* This comes from TASK_COMM_LEN defined in Linux's include/linux/sched.h. */
+/* This comes from TASK_COMM_LEN defined in Linux' include/linux/sched.h. */
 #define PROCESS_NAME_SIZE 15
 #elif defined(OSsunos)
 #define PROCESS_NAME_SIZE 15
@@ -416,7 +416,7 @@ usage(void)
   -a|--startas pathname   program to start (default is executable)\n
   -r|--chroot directory   chroot to directory before starting\n
   -d|--chdir directorychange to directory (default is /)\n
-  -N|--nicelevel incr add incr to the process's nice level\n
+  -N|--nicelevel incr add incr to the process' nice level\n
   -P|--procsched policy[:prio]\n
 use policy with prio for the kernel\n
   process scheduler (default prio is 0)\n

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-270-g89973c5

2011-08-20 Thread Guillem Jover
The following commit has been merged in the master branch:
commit ca9a2b79f85a8ed72308b5a2877ca8cfbda0b243
Author: Guillem Jover guil...@debian.org
Date:   Sat Aug 20 12:21:22 2011 +0200

u-a: Refactor scandir() namelist free into new altdb_free_namelist()

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 0bea4b5..863c03c 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -410,6 +410,14 @@ altdb_get_namelist(struct dirent ***table)
return count;
 }
 
+static void
+altdb_free_namelist(struct dirent **table, int n)
+{
+   while (n--)
+   free(table[n]);
+   free(table);
+}
+
 static int
 spawn(const char *prog, const char *args[])
 {
@@ -484,9 +492,8 @@ config_all(void)
for (i = 0; i  count; i++) {
subcall(prog_path, --config, table[i]-d_name, NULL);
printf(\n);
-   free(table[i]);
}
-   free(table);
+   altdb_free_namelist(table, count);
 }
 
 static bool
@@ -2211,7 +2218,6 @@ main(int argc, char **argv)
 
if (!alternative_load(a_new, true)) {
alternative_free(a_new);
-   free(table[i]);
continue;
}
alternative_map_add(alt_map_obj, a_new-master_name, a_new);
@@ -2221,10 +2227,8 @@ main(int argc, char **argv)
alternative_map_add(alt_map_links, sl-link, a_new);
alternative_map_add(alt_map_parent, sl-name, a_new);
}
-
-   free(table[i]);
}
-   free(table);
+   altdb_free_namelist(table, count);
 
/* Check that caller don't mix links between alternatives and don't mix
 * alternatives between slave/master, and that the various parameters

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-270-g89973c5

2011-08-20 Thread Guillem Jover
The following commit has been merged in the master branch:
commit abda47fbe81e53da7d0a46237895bd225373d022
Author: Guillem Jover guil...@debian.org
Date:   Fri Aug 19 22:32:19 2011 +0200

u-a: Move alternative map loading to the actions that make use of them

This will reduce start up time, by not doing unneeded operations.

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 2d3ed75..2dd16f3 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -2100,8 +2100,6 @@ main(int argc, char **argv)
struct fileset *fileset = NULL;
/* Path of alternative we are offering. */
char *path = NULL, *current_choice = NULL;
-   /* Alternatives maps for checks */
-   struct alternative_map *alt_map_obj, *alt_map_links, *alt_map_parent;
const char *new_choice = NULL;
int i = 0;
 
@@ -2251,22 +2249,21 @@ main(int argc, char **argv)
   --config, --set, --set-selections, --install, 
   --remove, --all, --remove-all or --auto));
 
-   /* Load infos about all alternatives to be able to check for mistakes. 
*/
-   alt_map_obj = alternative_map_new(NULL, NULL);
-   alternative_map_load_names(alt_map_obj);
-
-   alt_map_links = alternative_map_new(NULL, NULL);
-   alt_map_parent = alternative_map_new(NULL, NULL);
-   alternative_map_load_tree(alt_map_links, alt_map_parent);
-
/* Check that caller don't mix links between alternatives and don't mix
 * alternatives between slave/master, and that the various parameters
 * are fine. */
if (strcmp(action, install) == 0) {
+   struct alternative_map *alt_map_links, *alt_map_parent;
struct alternative *found;
struct stat st;
struct slave_link *sl;
 
+   /* Load information about all alternatives to be able to
+* check for mistakes. */
+   alt_map_links = alternative_map_new(NULL, NULL);
+   alt_map_parent = alternative_map_new(NULL, NULL);
+   alternative_map_load_tree(alt_map_links, alt_map_parent);
+
found = alternative_map_find(alt_map_parent,
 inst_alt-master_name);
if (found  strcmp(found-master_name,
@@ -2358,8 +2355,12 @@ main(int argc, char **argv)
config_all();
exit(0);
} else if (strcmp(action, get-selections) == 0) {
+   struct alternative_map *alt_map_obj;
struct alternative_map *am;
 
+   alt_map_obj = alternative_map_new(NULL, NULL);
+   alternative_map_load_names(alt_map_obj);
+
for (am = alt_map_obj; am  am-item; am = am-next) {
char *current;
 
@@ -2372,7 +2373,11 @@ main(int argc, char **argv)
 
exit(0);
} else if (strcmp(action, set-selections) == 0) {
+   struct alternative_map *alt_map_obj;
+
log_msg(run with %s, get_argv_string(argc, argv));
+   alt_map_obj = alternative_map_new(NULL, NULL);
+   alternative_map_load_names(alt_map_obj);
alternative_set_selections(alt_map_obj, stdin, _(standard 
input));
exit(0);
}

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-270-g89973c5

2011-08-20 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 774e918754bc7d801e802ea6ccbd9b5673799d8c
Author: Guillem Jover guil...@debian.org
Date:   Fri Aug 19 18:38:10 2011 +0200

u-a: Split alternative map loading into two functions

This will allow only loading them when needed, instead of doing it
for any action.

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 863c03c..2d3ed75 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1867,6 +1867,51 @@ alternative_map_add(struct alternative_map *am, const 
char *key, struct alternat
}
 }
 
+static void
+alternative_map_load_names(struct alternative_map *alt_map_obj)
+{
+   struct dirent **table;
+   int i, count;
+
+   count = altdb_get_namelist(table);
+   for (i = 0; i  count; i++) {
+   struct alternative *a_new = alternative_new(table[i]-d_name);
+
+   if (!alternative_load(a_new, true)) {
+   alternative_free(a_new);
+   continue;
+   }
+   alternative_map_add(alt_map_obj, a_new-master_name, a_new);
+   }
+   altdb_free_namelist(table, count);
+}
+
+static void
+alternative_map_load_tree(struct alternative_map *alt_map_links,
+  struct alternative_map *alt_map_parent)
+{
+   struct dirent **table;
+   int i, count;
+
+   count = altdb_get_namelist(table);
+   for (i = 0; i  count; i++) {
+   struct slave_link *sl;
+   struct alternative *a_new = alternative_new(table[i]-d_name);
+
+   if (!alternative_load(a_new, true)) {
+   alternative_free(a_new);
+   continue;
+   }
+   alternative_map_add(alt_map_links, a_new-master_link, a_new);
+   alternative_map_add(alt_map_parent, a_new-master_name, a_new);
+   for (sl = a_new-slaves; sl; sl = sl-next) {
+   alternative_map_add(alt_map_links, sl-link, a_new);
+   alternative_map_add(alt_map_parent, sl-name, a_new);
+   }
+   }
+   altdb_free_namelist(table, count);
+}
+
 static const char *
 get_argv_string(int argc, char **argv)
 {
@@ -2057,9 +2102,8 @@ main(int argc, char **argv)
char *path = NULL, *current_choice = NULL;
/* Alternatives maps for checks */
struct alternative_map *alt_map_obj, *alt_map_links, *alt_map_parent;
-   struct dirent **table;
const char *new_choice = NULL;
-   int i = 0, count;
+   int i = 0;
 
setlocale(LC_ALL, );
bindtextdomain(dpkg, LOCALEDIR);
@@ -2209,26 +2253,11 @@ main(int argc, char **argv)
 
/* Load infos about all alternatives to be able to check for mistakes. 
*/
alt_map_obj = alternative_map_new(NULL, NULL);
+   alternative_map_load_names(alt_map_obj);
+
alt_map_links = alternative_map_new(NULL, NULL);
alt_map_parent = alternative_map_new(NULL, NULL);
-   count = altdb_get_namelist(table);
-   for (i = 0; i  count; i++) {
-   struct slave_link *sl;
-   struct alternative *a_new = alternative_new(table[i]-d_name);
-
-   if (!alternative_load(a_new, true)) {
-   alternative_free(a_new);
-   continue;
-   }
-   alternative_map_add(alt_map_obj, a_new-master_name, a_new);
-   alternative_map_add(alt_map_links, a_new-master_link, a_new);
-   alternative_map_add(alt_map_parent, a_new-master_name, a_new);
-   for (sl = a_new-slaves; sl; sl = sl-next) {
-   alternative_map_add(alt_map_links, sl-link, a_new);
-   alternative_map_add(alt_map_parent, sl-name, a_new);
-   }
-   }
-   altdb_free_namelist(table, count);
+   alternative_map_load_tree(alt_map_links, alt_map_parent);
 
/* Check that caller don't mix links between alternatives and don't mix
 * alternatives between slave/master, and that the various parameters

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-270-g89973c5

2011-08-20 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 46aadad359a9e4204cfe707f47e3cfceef47e709
Author: Guillem Jover guil...@debian.org
Date:   Fri Aug 19 22:59:53 2011 +0200

u-a: Refactor --install argument checking into a new function

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 2dd16f3..73ac954 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -2083,6 +2083,108 @@ alternative_evolve(struct alternative *a, struct 
alternative *b,
}
 }
 
+/**
+ * Check the alternative installation arguments.
+ *
+ * That the caller doesn't mix links between alternatives, doesn't mix
+ * alternatives between slave/master, and that the various parameters
+ * are fine.
+ */
+static void
+alternative_check_install_args(struct alternative *inst_alt,
+   struct fileset *fileset)
+{
+   struct alternative_map *alt_map_links, *alt_map_parent;
+   struct alternative *found;
+   struct slave_link *sl;
+   struct stat st;
+
+   /* Load information about all alternatives to check for mistakes. */
+   alt_map_links = alternative_map_new(NULL, NULL);
+   alt_map_parent = alternative_map_new(NULL, NULL);
+   alternative_map_load_tree(alt_map_links, alt_map_parent);
+
+   found = alternative_map_find(alt_map_parent, inst_alt-master_name);
+   if (found  strcmp(found-master_name, inst_alt-master_name) != 0) {
+   error(_(alternative %s can't be master: it is a slave of %s),
+ inst_alt-master_name, found-master_name);
+   }
+
+   found = alternative_map_find(alt_map_links, inst_alt-master_link);
+   if (found  strcmp(found-master_name, inst_alt-master_name) != 0) {
+   found = alternative_map_find(alt_map_parent,
+found-master_name);
+   error(_(alternative link %s is already managed by %s.),
+ inst_alt-master_link, found-master_name);
+   }
+
+   if (inst_alt-master_link[0] != '/')
+   error(_(alternative link is not absolute as it should be: %s),
+ inst_alt-master_link);
+
+   if (fileset-master_file[0] != '/')
+   error(_(alternative path is not absolute as it should be: %s),
+ fileset-master_file);
+
+   if (stat(fileset-master_file, st) == -1  errno == ENOENT)
+   error(_(alternative path %s doesn't exist.),
+ fileset-master_file);
+
+   if (strpbrk(inst_alt-master_name, / \t))
+   error(_(alternative name (%s) must not contain '/' 
+   and spaces.), inst_alt-master_name);
+
+   for (sl = inst_alt-slaves; sl; sl = sl-next) {
+   const char *file = fileset_get_slave(fileset, sl-name);
+
+   found = alternative_map_find(alt_map_parent, sl-name);
+   if (found 
+   strcmp(found-master_name, inst_alt-master_name) != 0) {
+   char *msg;
+
+   if (strcmp(found-master_name, sl-name) == 0)
+   msg = _(it is a master alternative.);
+   else
+   xasprintf(msg, _(it is a slave of %s),
+ found-master_name);
+   error(_(alternative %s can't be slave of %s: %s),
+ sl-name, inst_alt-master_name, msg);
+   }
+
+   found = alternative_map_find(alt_map_links, sl-link);
+   if (found 
+   strcmp(found-master_name, inst_alt-master_name) != 0) {
+   error(_(alternative link %s is already 
+   managed by %s.), sl-link,
+ found-master_name);
+   }
+   if (found) {
+   struct slave_link *sl2;
+
+   for (sl2 = found-slaves; sl2; sl2 = sl2-next)
+   if (strcmp(sl2-link, sl-link) == 0)
+   break;
+   if (sl2  strcmp(sl2-name, sl-name) != 0)
+   error(_(alternative link %s is already 
+   managed by %s (slave of %s).),
+ sl-link, sl2-name,
+ found-master_name);
+   }
+
+   if (sl-link[0] != '/')
+   error(_(alternative link is not absolute as 
+   it should be: %s), sl-link);
+
+   if (!file || file[0] != '/')
+   error(_(alternative path is not absolute as 
+   it should be: %s), file);
+
+   if (strpbrk(sl-name, / \t))
+   error(_(alternative name (%s) must not contain '/' 
+   and 

[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-270-g89973c5

2011-08-20 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 52507504e69d6621262de82096987fdfb821bf8d
Author: Guillem Jover guil...@debian.org
Date:   Sat Aug 20 12:55:33 2011 +0200

u-a: Refactor alternative argument checks into new function

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 73ac954..20c2545 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -2083,6 +2083,22 @@ alternative_evolve(struct alternative *a, struct 
alternative *b,
}
 }
 
+static void
+alternative_check_args(const char *name, const char *linkname, const char 
*file)
+{
+   if (strpbrk(name, / \t))
+   error(_(alternative name (%s) must not contain '/' 
+   and spaces.), name);
+
+   if (linkname[0] != '/')
+   error(_(alternative link is not absolute as it should be: %s),
+ linkname);
+
+   if (!file || file[0] != '/')
+   error(_(alternative path is not absolute as it should be: %s),
+ file);
+}
+
 /**
  * Check the alternative installation arguments.
  *
@@ -2118,22 +2134,13 @@ alternative_check_install_args(struct alternative 
*inst_alt,
  inst_alt-master_link, found-master_name);
}
 
-   if (inst_alt-master_link[0] != '/')
-   error(_(alternative link is not absolute as it should be: %s),
- inst_alt-master_link);
-
-   if (fileset-master_file[0] != '/')
-   error(_(alternative path is not absolute as it should be: %s),
- fileset-master_file);
+   alternative_check_args(inst_alt-master_name, inst_alt-master_link,
+  fileset-master_file);
 
if (stat(fileset-master_file, st) == -1  errno == ENOENT)
error(_(alternative path %s doesn't exist.),
  fileset-master_file);
 
-   if (strpbrk(inst_alt-master_name, / \t))
-   error(_(alternative name (%s) must not contain '/' 
-   and spaces.), inst_alt-master_name);
-
for (sl = inst_alt-slaves; sl; sl = sl-next) {
const char *file = fileset_get_slave(fileset, sl-name);
 
@@ -2171,17 +2178,7 @@ alternative_check_install_args(struct alternative 
*inst_alt,
  found-master_name);
}
 
-   if (sl-link[0] != '/')
-   error(_(alternative link is not absolute as 
-   it should be: %s), sl-link);
-
-   if (!file || file[0] != '/')
-   error(_(alternative path is not absolute as 
-   it should be: %s), file);
-
-   if (strpbrk(sl-name, / \t))
-   error(_(alternative name (%s) must not contain '/' 
-   and spaces.), sl-name);
+   alternative_check_args(sl-name, sl-link, file);
}
 }
 

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-270-g89973c5

2011-08-20 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 89973c5bb9eed790242a7d1d35564fd954edf554
Author: Guillem Jover guil...@debian.org
Date:   Sat Aug 20 15:36:00 2011 +0200

u-a: Do not build strings from parts in alternative_check_install_args

This makes the work of translators harder.

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 20c2545..8e82bb6 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -2147,15 +2147,15 @@ alternative_check_install_args(struct alternative 
*inst_alt,
found = alternative_map_find(alt_map_parent, sl-name);
if (found 
strcmp(found-master_name, inst_alt-master_name) != 0) {
-   char *msg;
-
if (strcmp(found-master_name, sl-name) == 0)
-   msg = _(it is a master alternative.);
+   error(_(alternative %s can't be slave of %s: 
+   it is a master alternative.),
+ sl-name, inst_alt-master_name);
else
-   xasprintf(msg, _(it is a slave of %s),
- found-master_name);
-   error(_(alternative %s can't be slave of %s: %s),
- sl-name, inst_alt-master_name, msg);
+   error(_(alternative %s can't be slave of %s: 
+   it is a slave of %s),
+ sl-name, inst_alt-master_name,
+ found-master_name);
}
 
found = alternative_map_find(alt_map_links, sl-link);

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org