[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 2ccd37bcadf4ab95a815b0952f933d3e73555366
Author: Guillem Jover 
Date:   Fri Sep 9 09:02:27 2011 +0200

build: Ship debian/dpkg.prerm in the dist tarball

Regression introduced in commit cf6b98d3738d1fe8b3119b71fd8321c12feb618c.

diff --git a/Makefile.am b/Makefile.am
index f1561ef..fe4c2b7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -47,6 +47,7 @@ EXTRA_DIST = \
debian/dpkg.postinst \
debian/dpkg.postrm \
debian/dpkg.preinst \
+   debian/dpkg.prerm \
debian/dpkg.logrotate \
debian/dpkg.links \
debian/dpkg.lintian-overrides \

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 972095bea5f6bcf3a14f3b3151ca3ca56eff6744
Author: Guillem Jover 
Date:   Fri Sep 9 06:24:19 2011 +0200

dpkg-buildflags(1): Escape minus sign

diff --git a/man/dpkg-buildflags.1 b/man/dpkg-buildflags.1
index cd33c77..305d608 100644
--- a/man/dpkg-buildflags.1
+++ b/man/dpkg-buildflags.1
@@ -1,4 +1,4 @@
-.TH dpkg\-buildflags 1 "2011-09-07" "Debian Project" "dpkg suite"
+.TH dpkg\-buildflags 1 "2011-09-09" "Debian Project" "dpkg suite"
 .SH NAME
 dpkg\-buildflags \- returns build flags to use during package build
 .
@@ -181,7 +181,7 @@ The special feature \fBall\fP can be used to enable or 
disable all
 hardening features at the same time. Thus disabling everything and
 enabling only "format" and "fortify" can be achieved with:
 .P
-  export DEB_BUILD_MAINT_OPTIONS="hardening=-all,+format,+fortify"
+  export DEB_BUILD_MAINT_OPTIONS="hardening=\-all,+format,+fortify"
 .
 .TP
 .B format

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 1e5cdccd104a1fe819b501ae0c3ff63170617f70
Author: Guillem Jover 
Date:   Fri Sep 9 05:55:37 2011 +0200

libdpkg: Do not generate the unused infodir in modstatdb_init()

diff --git a/lib/dpkg/dbmodify.c b/lib/dpkg/dbmodify.c
index f514ddc..91f3ec2 100644
--- a/lib/dpkg/dbmodify.c
+++ b/lib/dpkg/dbmodify.c
@@ -57,7 +57,6 @@ static int nextupdate;
 static char *updatesdir;
 static int updateslength;
 static char *updatefnbuf, *updatefnrest;
-static char *infodir;
 static struct varbuf uvb;
 
 static int ulist_select(const struct dirent *de) {
@@ -142,7 +141,6 @@ static const struct fni {
   {   AVAILFILE,  &availablefile  },
   {   UPDATESDIR, &updatesdir },
   {   UPDATESDIR IMPORTANTTMP,&importanttmpfile   },
-  {   INFODIR,&infodir},
   {   NULL, NULL  }
 };
 

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 0e63ea3ee1a247e581eef0fdee453d09f7a358f7
Author: Guillem Jover 
Date:   Wed Sep 7 06:20:43 2011 +0200

Do not include trailing slash for directory string literals

This makes it more natural to manage the directory names, and avoids
some doubled slashes.

diff --git a/lib/dpkg/dpkg.h b/lib/dpkg/dpkg.h
index 3bfbd7a..a242606 100644
--- a/lib/dpkg/dpkg.h
+++ b/lib/dpkg/dpkg.h
@@ -64,12 +64,12 @@ DPKG_BEGIN_DECLS
 #define DIVERSIONSFILE"diversions"
 #define STATOVERRIDEFILE  "statoverride"
 #define UPDATESDIR"updates/"
-#define INFODIR   "info/"
-#define TRIGGERSDIR   "triggers/"
+#define INFODIR   "info"
+#define TRIGGERSDIR   "triggers"
 #define TRIGGERSFILEFILE  "File"
 #define TRIGGERSDEFERREDFILE "Unincorp"
 #define TRIGGERSLOCKFILE  "Lock"
-#define CONTROLDIRTMP "tmp.ci/"
+#define CONTROLDIRTMP "tmp.ci"
 #define IMPORTANTTMP  "tmp.i"
 #define REASSEMBLETMP "reassemble" DEBEXT
 #define IMPORTANTMAXLEN10
diff --git a/lib/dpkg/trigdeferred.l b/lib/dpkg/trigdeferred.l
index 2fa8e2d..31e8e63 100644
--- a/lib/dpkg/trigdeferred.l
+++ b/lib/dpkg/trigdeferred.l
@@ -101,6 +101,7 @@ constructfn(struct varbuf *vb, const char *dir, const char 
*tail)
 {
varbuf_reset(vb);
varbuf_add_str(vb, dir);
+   varbuf_add_char(vb, '/');
varbuf_add_str(vb, tail);
varbuf_end_str(vb);
 }
diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index 324ba57..13280d2 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -253,6 +253,7 @@ trk_explicit_start(const char *trig)
 
varbuf_reset(&trk_explicit_fn);
varbuf_add_str(&trk_explicit_fn, triggersdir);
+   varbuf_add_char(&trk_explicit_fn, '/');
varbuf_add_str(&trk_explicit_fn, trig);
varbuf_end_str(&trk_explicit_fn);
 
diff --git a/src/filesdb.c b/src/filesdb.c
index efe860b..990a488 100644
--- a/src/filesdb.c
+++ b/src/filesdb.c
@@ -82,6 +82,7 @@ pkgadminfile(struct pkginfo *pkg, const char *filetype)
 
   varbuf_reset(&vb);
   varbuf_add_str(&vb, infodir);
+  varbuf_add_char(&vb, '/');
   varbuf_add_str(&vb, pkg->name);
   varbuf_add_char(&vb, '.');
   varbuf_add_str(&vb, filetype);
diff --git a/src/infodb.c b/src/infodb.c
index e02d78c..bd4f7b4 100644
--- a/src/infodb.c
+++ b/src/infodb.c
@@ -61,6 +61,7 @@ pkg_infodb_foreach(struct pkginfo *pkg, pkg_infodb_file_func 
*func)
size_t db_path_len;
 
varbuf_add_str(&db_path, pkgadmindir());
+   varbuf_add_char(&db_path, '/');
db_path_len = db_path.used;
varbuf_add_char(&db_path, '\0');
 
diff --git a/src/processarc.c b/src/processarc.c
index 250c38c..811b5f2 100644
--- a/src/processarc.c
+++ b/src/processarc.c
@@ -406,12 +406,10 @@ void process_archive(const char *filename) {
 strcpy(cidir,admindir);
 strcat(cidir, "/" CONTROLDIRTMP);
 
-cidirrest = cidir + strlen(cidir);
-
-assert(*cidir && cidirrest[-1] == '/');
-cidirrest[-1] = '\0';
 ensure_pathname_nonexisting(cidir);
-cidirrest[-1] = '/';
+
+strcat(cidir, "/");
+cidirrest = cidir + strlen(cidir);
   }
 
   push_cleanup(cu_cidir, ~0, NULL, 0, 2, (void *)cidir, (void *)cidirrest);

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 25f368cb9756f4fe238aff9f0f7ee3b15e2e86a4
Author: Guillem Jover 
Date:   Wed Sep 7 06:38:41 2011 +0200

dpkg: Refactor control directory creation on unpack

diff --git a/src/processarc.c b/src/processarc.c
index 811b5f2..09269b2 100644
--- a/src/processarc.c
+++ b/src/processarc.c
@@ -154,6 +154,45 @@ deb_verify(const char *filename)
   }
 }
 
+static char *
+get_control_dir(char *cidir)
+{
+  if (f_noact) {
+char *tmpdir;
+
+tmpdir = mkdtemp(path_make_temp_template("dpkg"));
+if (tmpdir == NULL)
+  ohshite(_("unable to create temporary directory"));
+
+cidir = m_realloc(cidir, strlen(tmpdir) + MAXCONTROLFILENAME + 10);
+
+strcpy(cidir, tmpdir);
+
+free(tmpdir);
+  } else {
+const char *admindir;
+
+admindir = dpkg_db_get_dir();
+
+/* The admindir length is always constant on a dpkg execution run. */
+if (cidir == NULL)
+  cidir = m_malloc(strlen(admindir) + sizeof(CONTROLDIRTMP) +
+   MAXCONTROLFILENAME + 10);
+
+/* We want it to be on the same filesystem so that we can
+ * use rename(2) to install the postinst &c. */
+strcpy(cidir, admindir);
+strcat(cidir, "/" CONTROLDIRTMP);
+
+/* Make sure the control information directory is empty. */
+ensure_pathname_nonexisting(cidir);
+  }
+
+  strcat(cidir, "/");
+
+  return cidir;
+}
+
 #define MAXCONFLICTORS 20
 
 static struct pkginfo *conflictor[MAXCONFLICTORS];
@@ -381,38 +420,11 @@ void process_archive(const char *filename) {
   if (!f_nodebsig)
 deb_verify(filename);
 
-  if (f_noact) {
-char *tmpdir;
-
-tmpdir = mkdtemp(path_make_temp_template("dpkg"));
-if (!tmpdir)
-  ohshite(_("unable to create temporary directory"));
-
-cidir = m_realloc(cidir, strlen(tmpdir) + MAXCONTROLFILENAME + 10);
-strcpy(cidir, tmpdir);
-strcat(cidir,"/");
-
-cidirrest = cidir + strlen(cidir);
-
-free(tmpdir);
-  } else {
-const char *admindir = dpkg_db_get_dir();
-
-/* We want it to be on the same filesystem so that we can
- * use rename(2) to install the postinst &c. */
-if (!cidir)
-  cidir = m_malloc(strlen(admindir) + sizeof(CONTROLDIRTMP) +
-   MAXCONTROLFILENAME + 10);
-strcpy(cidir,admindir);
-strcat(cidir, "/" CONTROLDIRTMP);
-
-ensure_pathname_nonexisting(cidir);
-
-strcat(cidir, "/");
-cidirrest = cidir + strlen(cidir);
-  }
-
+  /* Get the control information directory. */
+  cidir = get_control_dir(cidir);
+  cidirrest = cidir + strlen(cidir);
   push_cleanup(cu_cidir, ~0, NULL, 0, 2, (void *)cidir, (void *)cidirrest);
+
   pid = subproc_fork();
   if (pid == 0) {
 cidirrest[-1] = '\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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit af4a5dd8bb2e88c0d97646b697f60f9e9d265fdf
Author: Guillem Jover 
Date:   Mon Sep 5 16:08:51 2011 +0200

libdpkg: Move trigger note support to a new trignote module

This detangles the trigger note support from triglib and avoids code
using parsedb() to end up pulling the triglib and dbmodify modules.
This reduces the dpkg-deb binary size.

diff --git a/debian/changelog b/debian/changelog
index f7afd68..bf1648b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -213,6 +213,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
 Closes: #639997
   * Reduce dpkg-trigger binary size by refactoring libdpkg modules so that
 it does not end up pulling triglib.
+  * Reduce dpkg-deb binary size by refectoring libdpkg modules so that it
+does not end up pulling triglib.
 
   [ Updated dpkg translations ]
   * German (Sven Joachim). Closes: #620312
diff --git a/lib/dpkg/Makefile.am b/lib/dpkg/Makefile.am
index bfd02c1..98d084d 100644
--- a/lib/dpkg/Makefile.am
+++ b/lib/dpkg/Makefile.am
@@ -63,6 +63,7 @@ libdpkg_a_SOURCES = \
tarfn.c \
test.h \
trigname.c \
+   trignote.c \
triglib.c \
trigdeferred.l \
utils.c \
diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index dffc708..324ba57 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -34,7 +34,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -100,73 +99,6 @@ trig_record_activation(struct pkginfo *pend, struct pkginfo 
*aw, const char *tri
}
 }
 
-/*
- * Note: This is also called from fields.c where *pend is a temporary!
- *
- * trig is not copied!
- */
-bool
-trig_note_pend_core(struct pkginfo *pend, const char *trig)
-{
-   struct trigpend *tp;
-
-   for (tp = pend->trigpend_head; tp; tp = tp->next)
-   if (!strcmp(tp->name, trig))
-   return false;
-
-   tp = nfmalloc(sizeof(*tp));
-   tp->name = trig;
-   tp->next = pend->trigpend_head;
-   pend->trigpend_head = tp;
-
-   return true;
-}
-
-/*
- * trig is not copied!
- *
- * @retval true  For done.
- * @retval false For already noted.
- */
-bool
-trig_note_pend(struct pkginfo *pend, const char *trig)
-{
-   if (!trig_note_pend_core(pend, trig))
-   return false;
-
-   pend->status = pend->trigaw.head ? stat_triggersawaited :
-  stat_triggerspending;
-
-   return true;
-}
-
-/*
- * Note: This is called also from fields.c where *aw is a temporary
- * but pend is from pkg_db_find()!
- *
- * @retval true  For done.
- * @retval false For already noted.
- */
-bool
-trig_note_aw(struct pkginfo *pend, struct pkginfo *aw)
-{
-   struct trigaw *ta;
-
-   /* We search through aw's list because that's probably shorter. */
-   for (ta = aw->trigaw.head; ta; ta = ta->sameaw.next)
-   if (ta->pend == pend)
-   return false;
-
-   ta = nfmalloc(sizeof(*ta));
-   ta->aw = aw;
-   ta->pend = pend;
-   ta->samepend_next = pend->othertrigaw_head;
-   pend->othertrigaw_head = ta;
-   LIST_LINK_TAIL_PART(aw->trigaw, ta, sameaw.);
-
-   return true;
-}
-
 void
 trig_clear_awaiters(struct pkginfo *notpend)
 {
@@ -190,37 +122,6 @@ trig_clear_awaiters(struct pkginfo *notpend)
}
 }
 
-static struct pkg_list *trig_awaited_pend_head;
-
-void
-trig_awaited_pend_enqueue(struct pkginfo *pend)
-{
-   struct pkg_list *tp;
-
-   for (tp = trig_awaited_pend_head; tp; tp = tp->next)
-   if (tp->pkg == pend)
-   return;
-
-   pkg_list_prepend(&trig_awaited_pend_head, pend);
-}
-
-void
-trig_awaited_pend_foreach(trig_awaited_pend_foreach_func *func)
-{
-   struct pkg_list *tp;
-
-   for (tp = trig_awaited_pend_head; tp; tp = tp->next)
-   if (!tp->pkg->trigpend_head)
-   func(tp->pkg);
-}
-
-void
-trig_awaited_pend_free(void)
-{
-   pkg_list_free(trig_awaited_pend_head);
-   trig_awaited_pend_head = NULL;
-}
-
 /*
  * Fix up packages in state triggers-awaited w/o the corresponding package
  * with pending triggers. This can happen when dpkg was interrupted
diff --git a/lib/dpkg/trignote.c b/lib/dpkg/trignote.c
new file mode 100644
index 000..2681eb6
--- /dev/null
+++ b/lib/dpkg/trignote.c
@@ -0,0 +1,128 @@
+/*
+ * libdpkg - Debian packaging suite library routines
+ * trignote.c - trigger note handling
+ *
+ * Copyright © 2007 Canonical Ltd
+ * Written by Ian Jackson 
+ * Copyright © 2008-2011 Guillem Jover 
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warr

[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit a4298e6ff245505a5a963a08fe2d40ecad9c595e
Author: Guillem Jover 
Date:   Tue Sep 6 05:59:13 2011 +0200

libdpkg: Refactor trig_awaited_pend_head processing into new functions

This will allow accessing trig_awaited_pend_head from a different
module, w/o needing to pull in triglib.

diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index 121fb90..dffc708 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -4,6 +4,7 @@
  *
  * Copyright © 2007 Canonical Ltd
  * Written by Ian Jackson 
+ * Copyright © 2008-2011 Guillem Jover 
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -203,6 +204,23 @@ trig_awaited_pend_enqueue(struct pkginfo *pend)
pkg_list_prepend(&trig_awaited_pend_head, pend);
 }
 
+void
+trig_awaited_pend_foreach(trig_awaited_pend_foreach_func *func)
+{
+   struct pkg_list *tp;
+
+   for (tp = trig_awaited_pend_head; tp; tp = tp->next)
+   if (!tp->pkg->trigpend_head)
+   func(tp->pkg);
+}
+
+void
+trig_awaited_pend_free(void)
+{
+   pkg_list_free(trig_awaited_pend_head);
+   trig_awaited_pend_head = NULL;
+}
+
 /*
  * Fix up packages in state triggers-awaited w/o the corresponding package
  * with pending triggers. This can happen when dpkg was interrupted
@@ -215,17 +233,11 @@ trig_awaited_pend_enqueue(struct pkginfo *pend)
 void
 trig_fixup_awaiters(enum modstatdb_rw cstatus)
 {
-   struct pkg_list *tp;
-
if (cstatus < msdbrw_write)
return;
 
-   for (tp = trig_awaited_pend_head; tp; tp = tp->next)
-   if (!tp->pkg->trigpend_head)
-   trig_clear_awaiters(tp->pkg);
-
-   pkg_list_free(trig_awaited_pend_head);
-   trig_awaited_pend_head = NULL;
+   trig_awaited_pend_foreach(trig_clear_awaiters);
+   trig_awaited_pend_free();
 }
 
 /*-- Generalized handling of trigger kinds. --*/
diff --git a/lib/dpkg/triglib.h b/lib/dpkg/triglib.h
index 96e52b5..b870953 100644
--- a/lib/dpkg/triglib.h
+++ b/lib/dpkg/triglib.h
@@ -83,7 +83,12 @@ bool trig_note_pend(struct pkginfo *pend, const char *trig 
/*not copied!*/);
 bool trig_note_aw(struct pkginfo *pend, struct pkginfo *aw);
 void trig_clear_awaiters(struct pkginfo *notpend);
 
+typedef void trig_awaited_pend_foreach_func(struct pkginfo *pkg);
+
 void trig_awaited_pend_enqueue(struct pkginfo *pend);
+void trig_awaited_pend_foreach(trig_awaited_pend_foreach_func *func);
+void trig_awaited_pend_free(void);
+
 void trig_fixup_awaiters(enum modstatdb_rw cstatus);
 
 void trig_file_interests_ensure(void);

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 2e9a20901a16a1b3f2b392ad14c321712073b3f1
Author: Guillem Jover 
Date:   Mon Sep 5 16:03:21 2011 +0200

libdpkg: Move trig_name_is_illegal to a new trigname module

This detangles the function from the triglib module, avoiding
dpkg-trigger to pull it, and reducing its size.

diff --git a/debian/changelog b/debian/changelog
index 2d96535..f7afd68 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -211,6 +211,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
 Closes: #639997
   * Do not warn on strange timestamps when unpacking with dpkg-deb.
 Closes: #639997
+  * Reduce dpkg-trigger binary size by refactoring libdpkg modules so that
+it does not end up pulling triglib.
 
   [ Updated dpkg translations ]
   * German (Sven Joachim). Closes: #620312
diff --git a/lib/dpkg/Makefile.am b/lib/dpkg/Makefile.am
index 7950835..bfd02c1 100644
--- a/lib/dpkg/Makefile.am
+++ b/lib/dpkg/Makefile.am
@@ -62,6 +62,7 @@ libdpkg_a_SOURCES = \
subproc.c \
tarfn.c \
test.h \
+   trigname.c \
triglib.c \
trigdeferred.l \
utils.c \
diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index 65efcb6..83bcbf0 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -39,22 +39,6 @@
 #include 
 #include 
 
-const char *
-trig_name_is_illegal(const char *p)
-{
-   int c;
-
-   if (!*p)
-   return _("empty trigger names are not permitted");
-
-   while ((c = *p++)) {
-   if (c <= ' ' || c >= 0177)
-   return _("trigger name contains invalid character");
-   }
-
-   return NULL;
-}
-
 /*== Recording triggers. ==*/
 
 static char *triggersdir, *triggersfilefile, *triggersnewfilefile;
diff --git a/lib/dpkg/test/t-macros.c b/lib/dpkg/trigname.c
similarity index 63%
copy from lib/dpkg/test/t-macros.c
copy to lib/dpkg/trigname.c
index 2b19775..7fd88cf 100644
--- a/lib/dpkg/test/t-macros.c
+++ b/lib/dpkg/trigname.c
@@ -1,8 +1,9 @@
 /*
  * libdpkg - Debian packaging suite library routines
- * t-macros.c - test C support macros
+ * trigname.c - trigger name handling
  *
- * Copyright © 2009 Guillem Jover 
+ * Copyright © 2007 Canonical Ltd
+ * Written by Ian Jackson 
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,19 +22,21 @@
 #include 
 #include 
 
-#include 
-#include 
+#include 
+#include 
 
-static void
-test(void)
+const char *
+trig_name_is_illegal(const char *p)
 {
-   test_pass(min(10, 30) == 10);
-   test_pass(min(30, 10) == 10);
-   test_pass(min(0, 10) == 0);
-   test_pass(min(-10, 0) == -10);
+   int c;
 
-   test_pass(max(10, 30) == 30);
-   test_pass(max(30, 10) == 30);
-   test_pass(max(0, 10) == 10);
-   test_pass(max(-10, 0) == 0);
+   if (!*p)
+   return _("empty trigger names are not permitted");
+
+   while ((c = *p++)) {
+   if (c <= ' ' || c >= 0177)
+   return _("trigger name contains invalid character");
+   }
+
+   return NULL;
 }
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f8e4f9b..c7dd704 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -33,6 +33,7 @@ lib/dpkg/subproc.c
 lib/dpkg/tarfn.c
 lib/dpkg/trigdeferred.l
 lib/dpkg/triglib.c
+lib/dpkg/trigname.c
 lib/dpkg/utils.c
 lib/dpkg/varbuf.c
 lib/dpkg/vercmp.c

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit f3dcf914203a42c9080f128d7e8263e8a0fb7ffa
Author: Guillem Jover 
Date:   Tue Sep 6 05:54:36 2011 +0200

libdpkg: Rename trig_enqueue_awaited_pend to trig_awaited_pend_enqueue

diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index 124d2d4..cc844f1 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -573,6 +573,6 @@ f_trigaw(struct pkginfo *aw, struct pkgbin *pifp,
   parse_error(ps,
   _("duplicate awaited trigger package `%.255s'"), word);
 
-trig_enqueue_awaited_pend(pend);
+trig_awaited_pend_enqueue(pend);
   }
 }
diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index 83bcbf0..121fb90 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -192,7 +192,7 @@ trig_clear_awaiters(struct pkginfo *notpend)
 static struct pkg_list *trig_awaited_pend_head;
 
 void
-trig_enqueue_awaited_pend(struct pkginfo *pend)
+trig_awaited_pend_enqueue(struct pkginfo *pend)
 {
struct pkg_list *tp;
 
diff --git a/lib/dpkg/triglib.h b/lib/dpkg/triglib.h
index 250c241..96e52b5 100644
--- a/lib/dpkg/triglib.h
+++ b/lib/dpkg/triglib.h
@@ -83,7 +83,7 @@ bool trig_note_pend(struct pkginfo *pend, const char *trig 
/*not copied!*/);
 bool trig_note_aw(struct pkginfo *pend, struct pkginfo *aw);
 void trig_clear_awaiters(struct pkginfo *notpend);
 
-void trig_enqueue_awaited_pend(struct pkginfo *pend);
+void trig_awaited_pend_enqueue(struct pkginfo *pend);
 void trig_fixup_awaiters(enum modstatdb_rw cstatus);
 
 void trig_file_interests_ensure(void);

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 8ed2e04c2b1bfa247e34da01c0e84612ce7dc84b
Author: Guillem Jover 
Date:   Sun Sep 4 16:07:29 2011 +0200

dpkg-deb: Do not warn on strange timestamps

The external extractor is only used on dpkg-deb -x (and friends), which
is only used by dpkg when extracting the control member. The internal
dpkg tar extractor never warns on timestamps, and there's no point for
dpkg to induce those warnings on the control extraction either.

Closes: #640298

diff --git a/debian/changelog b/debian/changelog
index f50c38c..2d96535 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -209,6 +209,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
 Based on a patch by Salvatore Bonaccorso .
   * Fix double “error:” string in dpkg missing PATH error output.
 Closes: #639997
+  * Do not warn on strange timestamps when unpacking with dpkg-deb.
+Closes: #639997
 
   [ Updated dpkg translations ]
   * German (Sven Joachim). Closes: #620312
diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index 737dab7..99362db 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -313,7 +313,7 @@ extracthalf(const char *debar, const char *dir, const char 
*taroption,
 }
   }
 
-  execlp(TAR, "tar", buffer, "-", NULL);
+  execlp(TAR, "tar", buffer, "-", "--warning=no-timestamp", NULL);
   ohshite(_("unable to execute %s (%s)"), "tar", TAR);
 }
 close(p2[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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 920596da263ed1342668a9fe5b59f8bbb52445dd
Author: Guillem Jover 
Date:   Thu Sep 1 15:17:35 2011 +0200

dpkg: Fix double “error:” string in missing PATH error output

Closes: #639997

diff --git a/debian/changelog b/debian/changelog
index 468f3ac..f50c38c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -207,6 +207,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
   * Update alternative links only if they change. This allows for a
 read-only file system and a writable database. Closes: #636700
 Based on a patch by Salvatore Bonaccorso .
+  * Fix double “error:” string in dpkg missing PATH error output.
+Closes: #639997
 
   [ Updated dpkg translations ]
   * German (Sven Joachim). Closes: #620312
diff --git a/src/help.c b/src/help.c
index fa33b1a..e9ffd2e 100644
--- a/src/help.c
+++ b/src/help.c
@@ -104,7 +104,7 @@ void checkpath(void) {
 
   path_list = getenv("PATH");
   if (!path_list)
-ohshit(_("error: PATH is not set."));
+ohshit(_("PATH is not set."));
 
   for (prog = prog_list; *prog; prog++) {
 struct stat stab;

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 05ce02f897fbe2a455cacb064fd5bc5a6bf182d9
Author: Guillem Jover 
Date:   Fri Aug 19 18:07:13 2011 +0200

u-a: Update alternative links only if they change

There's no point in changing the links to the same target. This also
helps when systems might have a read-only file system mounted, but a
writable database.

Closes: #636700

Based-on-patch-by: Salvatore Bonaccorso 
Signed-off-by: Guillem Jover 

diff --git a/debian/changelog b/debian/changelog
index 4967e00..468f3ac 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -204,6 +204,9 @@ dpkg (1.16.1) UNRELEASED; urgency=low
 Prompted by Timo Juhani Lindfors .
   * Print an actual error or warning message instead of assert()ing on
 readlink()/stat() size discrepancies. Closes: #639229
+  * Update alternative links only if they change. This allows for a
+read-only file system and a writable database. Closes: #636700
+Based on a patch by Salvatore Bonaccorso .
 
   [ Updated dpkg translations ]
   * German (Sven Joachim). Closes: #620312
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index e7516aa..feef7ed 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1681,6 +1681,34 @@ alternative_can_replace_path(const char *linkname)
return true;
 }
 
+static bool
+alternative_path_needs_update(const char *linkname, const char *filename)
+{
+   char *linktarget;
+   bool update;
+
+   if (opt_force)
+   return true;
+
+   switch (alternative_path_classify(linkname)) {
+   case ALT_PATH_SYMLINK:
+   linktarget = xreadlink(linkname);
+   if (strcmp(linktarget, filename) == 0)
+   update = false;
+   else
+   update = true;
+   free(linktarget);
+
+   return update;
+   case ALT_PATH_OTHER:
+   warning(_("not replacing %s with a link."), linkname);
+   return false;
+   case ALT_PATH_MISSING:
+   default:
+   return true;
+   }
+}
+
 static void
 alternative_prepare_install_single(struct alternative *a, const char *name,
   const char *linkname, const char *file)
@@ -1695,15 +1723,13 @@ alternative_prepare_install_single(struct alternative 
*a, const char *name,
alternative_add_commit_op(a, opcode_mv, fntmp, fn);
free(fntmp);
 
-   if (alternative_can_replace_path(linkname)) {
+   if (alternative_path_needs_update(linkname, fn)) {
/* Create alternative link. */
xasprintf(&fntmp, "%s" DPKG_TMP_EXT, linkname);
checked_rm(fntmp);
checked_symlink(fn, fntmp);
alternative_add_commit_op(a, opcode_mv, fntmp, linkname);
free(fntmp);
-   } else {
-   warning(_("not replacing %s with a link."), linkname);
}
free(fn);
 }

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 3518e4d159412c31c2de413b7bc358870b6c5c02
Author: Guillem Jover 
Date:   Thu Sep 8 10:19:28 2011 +0200

u-a: Refactor alternative_path_classify from alternative_can_replace_path

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 03ceb6d..e7516aa 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1646,25 +1646,39 @@ alternative_commit(struct alternative *a)
alternative_commit_operations_free(a);
 }
 
-static bool
-alternative_can_replace_path(const char *linkname)
+enum alternative_path_status {
+   ALT_PATH_SYMLINK,
+   ALT_PATH_MISSING,
+   ALT_PATH_OTHER,
+};
+
+static enum alternative_path_status
+alternative_path_classify(const char *linkname)
 {
struct stat st;
-   bool replace_link;
-
-   if (opt_force)
-   return true;
 
errno = 0;
if (lstat(linkname, &st) == -1) {
if (errno != ENOENT)
syserr(_("cannot stat file '%s'"), linkname);
-   replace_link = true;
+   return ALT_PATH_MISSING;
+   } else if (S_ISLNK(st.st_mode)) {
+   return ALT_PATH_SYMLINK;
} else {
-   replace_link = S_ISLNK(st.st_mode);
+   return ALT_PATH_OTHER;
}
+}
 
-   return replace_link;
+static bool
+alternative_can_replace_path(const char *linkname)
+{
+   if (opt_force)
+   return true;
+
+   if (alternative_path_classify(linkname) == ALT_PATH_OTHER)
+   return false;
+   else
+   return true;
 }
 
 static void

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit c922a8f681dc27135947ebdaff68fc3158614807
Author: Guillem Jover 
Date:   Thu Sep 8 19:12:20 2011 +0200

u-a: Do not try to readlink() a non-symlink

Return early in case the path is not a symlink, there's no point in
calling readlink() if we know it's going to fail.

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index b8654fa..03ceb6d 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -289,6 +289,12 @@ areadlink(const char *linkname)
/* Allocate required memory to store the value of the symlink */
if (lstat(linkname, &st))
return NULL;
+
+   if (!S_ISLNK(st.st_mode)) {
+   errno = EINVAL;
+   return NULL;
+   }
+
buf = xmalloc(st.st_size + 1);
 
/* Read it and terminate the string properly */

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 6c481e19a532080643e3cf5c76760df8009ea2c7
Author: Guillem Jover 
Date:   Thu Sep 8 10:10:06 2011 +0200

u-a: Use xreadlink() instead of areadlink() in alternative_evolve()

The function does not expect the readlink call to fail.

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 44a3114..b8654fa 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -2075,7 +2075,7 @@ alternative_evolve(struct alternative *a, struct 
alternative *b,
char *lnk;
 
xasprintf(&lnk, "%s/%s", altdir, sl->name);
-   new_file = areadlink(lnk);
+   new_file = xreadlink(lnk);
free(lnk);
}
if (strcmp(old, new) != 0 && lstat(old, &st) == 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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit c7c7522dd3e29af582eddda7b10b521337a7b21c
Author: Guillem Jover 
Date:   Tue Sep 6 04:19:03 2011 +0200

u-a: Split xreadlink() allocation code into areadlink()

Using a bool as an argument for a function already taking several
arguments is almost never a good interface, it's not clear from
the call sites what it refers to and as such prone to confusion.

Split the main xreadlink() code into a function that allocates but
can return NULL, and make xreadlink() use the common semantics of
never failing.

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 8e82bb6..44a3114 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -280,34 +280,44 @@ xstrdup(const char *str)
 }
 
 static char *
-xreadlink(const char *linkname, bool error_out)
+areadlink(const char *linkname)
 {
struct stat st;
char *buf;
ssize_t size;
 
/* Allocate required memory to store the value of the symlink */
-   if (lstat(linkname, &st)) {
-   if (!error_out)
-   return NULL;
-   syserr(_("cannot stat file '%s'"), linkname);
-   }
+   if (lstat(linkname, &st))
+   return NULL;
buf = xmalloc(st.st_size + 1);
 
/* Read it and terminate the string properly */
size = readlink(linkname, buf, st.st_size);
if (size == -1) {
-   if (!error_out) {
-   free(buf);
-   return NULL;
-   }
-   syserr(_("unable to read link `%.255s'"), linkname);
+   int saved_errno = errno;
+
+   free(buf);
+   errno = saved_errno;
+
+   return NULL;
}
buf[size] = '\0';
 
return buf;
 }
 
+static char *
+xreadlink(const char *linkname)
+{
+   char *buf;
+
+   buf = areadlink(linkname);
+   if (buf == NULL)
+   syserr(_("unable to read link `%.255s'"), linkname);
+
+   return buf;
+}
+
 static int DPKG_ATTR_VPRINTF(2)
 xvasprintf(char **strp, const char *fmt, va_list args)
 {
@@ -1421,7 +1431,7 @@ alternative_get_current(struct alternative *a)
return NULL;
 
xasprintf(&curlink, "%s/%s", altdir, a->master_name);
-   file = xreadlink(curlink, true);
+   file = xreadlink(curlink);
free(curlink);
 
return file;
@@ -1757,7 +1767,7 @@ alternative_is_broken(struct alternative *a)
return true;
 
/* Check master link */
-   altlnk = xreadlink(a->master_link, false);
+   altlnk = areadlink(a->master_link);
if (!altlnk)
return true;
xasprintf(&wanted, "%s/%s", altdir, a->master_name);
@@ -1784,7 +1794,7 @@ alternative_is_broken(struct alternative *a)
char *sl_altlnk, *sl_current;
 
/* Verify link -> /etc/alternatives/foo */
-   sl_altlnk = xreadlink(sl->link, false);
+   sl_altlnk = areadlink(sl->link);
if (!sl_altlnk)
return true;
xasprintf(&wanted, "%s/%s", altdir, sl->name);
@@ -1795,7 +1805,7 @@ alternative_is_broken(struct alternative *a)
}
free(sl_altlnk);
/* Verify /etc/alternatives/foo -> file */
-   sl_current = xreadlink(wanted, false);
+   sl_current = areadlink(wanted);
free(wanted);
if (!sl_current)
return true;
@@ -2065,7 +2075,7 @@ alternative_evolve(struct alternative *a, struct 
alternative *b,
char *lnk;
 
xasprintf(&lnk, "%s/%s", altdir, sl->name);
-   new_file = xreadlink(lnk, false);
+   new_file = areadlink(lnk);
free(lnk);
}
if (strcmp(old, new) != 0 && lstat(old, &st) == 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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 2b824afa6bb06b7cb757423b248f6907e9919e86
Author: Guillem Jover 
Date:   Mon May 2 21:51:47 2011 +0200

libdpkg: Detangle buffer filter logic from write logic

diff --git a/lib/dpkg/buffer.c b/lib/dpkg/buffer.c
index 99015d2..f0cf91f 100644
--- a/lib/dpkg/buffer.c
+++ b/lib/dpkg/buffer.c
@@ -66,6 +66,26 @@ buffer_filter_init(struct buffer_data *data)
return 0;
 }
 
+static off_t
+buffer_filter_update(struct buffer_data *filter, const void *buf, off_t length)
+{
+   off_t ret = length;
+
+   switch (filter->type) {
+   case BUFFER_FILTER_NULL:
+   break;
+   case BUFFER_FILTER_MD5:
+   MD5Update(&(((struct buffer_md5_ctx *)filter->arg.ptr)->ctx),
+ buf, length);
+   break;
+   default:
+   internerr("unknown data type '%i' in buffer_filter_update",
+ filter->type);
+   }
+
+   return ret;
+}
+
 static void
 buffer_md5_done(struct buffer_data *data)
 {
@@ -111,10 +131,6 @@ buffer_write(struct buffer_data *data, const void *buf, 
off_t length)
ret = fd_write(data->arg.i, buf, length);
break;
case BUFFER_WRITE_NULL:
-   case BUFFER_FILTER_NULL:
-   break;
-   case BUFFER_FILTER_MD5:
-   MD5Update(&(((struct buffer_md5_ctx *)data->arg.ptr)->ctx), 
buf, length);
break;
default:
internerr("unknown data type '%i' in buffer_write",
@@ -142,20 +158,22 @@ buffer_read(struct buffer_data *data, void *buf, off_t 
length)
 }
 
 off_t
-buffer_hash(const void *input, void *output, int type, off_t limit)
+buffer_filter(const void *input, void *output, int type, off_t limit)
 {
struct buffer_data data = { .arg.ptr = output, .type = type };
off_t ret;
 
buffer_filter_init(&data);
-   ret = buffer_write(&data, input, limit);
+   ret = buffer_filter_update(&data, input, limit);
buffer_filter_done(&data);
 
return ret;
 }
 
 static off_t
-buffer_copy(struct buffer_data *read_data, struct buffer_data *write_data,
+buffer_copy(struct buffer_data *read_data,
+struct buffer_data *filter,
+struct buffer_data *write_data,
 off_t limit, const char *desc)
 {
char *buf;
@@ -170,7 +188,7 @@ buffer_copy(struct buffer_data *read_data, struct 
buffer_data *write_data,
 
buf = m_malloc(bufsize);
 
-   buffer_filter_init(write_data);
+   buffer_filter_init(filter);
 
while (bufsize > 0) {
bytesread = buffer_read(read_data, buf, bufsize);
@@ -187,6 +205,8 @@ buffer_copy(struct buffer_data *read_data, struct 
buffer_data *write_data,
bufsize = limit;
}
 
+   buffer_filter_update(filter, buf, bytesread);
+
byteswritten = buffer_write(write_data, buf, bytesread);
if (byteswritten < 0)
break;
@@ -203,7 +223,7 @@ buffer_copy(struct buffer_data *read_data, struct 
buffer_data *write_data,
if (limit > 0)
ohshit(_("short read on buffer copy for %s"), desc);
 
-   buffer_filter_done(write_data);
+   buffer_filter_done(filter);
 
free(buf);
 
@@ -212,11 +232,13 @@ buffer_copy(struct buffer_data *read_data, struct 
buffer_data *write_data,
 
 off_t
 buffer_copy_IntInt(int Iin, int Tin,
+   void *Pfilter, int Tfilter,
int Iout, int Tout,
off_t limit, const char *desc, ...)
 {
va_list args;
struct buffer_data read_data = { .type = Tin, .arg.i = Iin };
+   struct buffer_data filter = { .type = Tfilter, .arg.ptr = Pfilter };
struct buffer_data write_data = { .type = Tout, .arg.i = Iout };
struct varbuf v = VARBUF_INIT;
off_t ret;
@@ -225,7 +247,7 @@ buffer_copy_IntInt(int Iin, int Tin,
varbuf_vprintf(&v, desc, args);
va_end(args);
 
-   ret = buffer_copy(&read_data, &write_data, limit, v.buf);
+   ret = buffer_copy(&read_data, &filter, &write_data, limit, v.buf);
 
varbuf_destroy(&v);
 
@@ -234,11 +256,13 @@ buffer_copy_IntInt(int Iin, int Tin,
 
 off_t
 buffer_copy_IntPtr(int Iin, int Tin,
+   void *Pfilter, int Tfilter,
void *Pout, int Tout,
off_t limit, const char *desc, ...)
 {
va_list args;
struct buffer_data read_data = { .type = Tin, .arg.i = Iin };
+   struct buffer_data filter = { .type = Tfilter, .arg.ptr = Pfilter };
struct buffer_data write_data = { .type = Tout, .arg.ptr = Pout };
struct varbuf v = VARBUF_INIT;
off_t ret;
@@ -247,7 +271,7 @@ buffer_copy_IntPtr(int Iin, int Tin,
varbuf_vprintf(&v, desc, args);
va_end(args);
 
-   ret = buffer_copy(&read_data, &write_data, limit, v.buf);
+   ret = buffer_cop

[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit a23c74e708972c7e566ea8255728184393963825
Author: Guillem Jover 
Date:   Thu Aug 25 20:40:02 2011 +0200

dpkg: Change type of variable r from int to ssize_t in conffderef()

diff --git a/src/configure.c b/src/configure.c
index 97689c1..4a38db0 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -375,7 +375,7 @@ conffderef(struct pkginfo *pkg, struct varbuf *result, 
const char *in)
 {
static struct varbuf target = VARBUF_INIT;
struct stat stab;
-   int r;
+   ssize_t r;
int loopprotect;
 
varbuf_reset(result);
@@ -424,7 +424,7 @@ conffderef(struct pkginfo *pkg, struct varbuf *result, 
const char *in)
varbuf_end_str(&target);
 
debug(dbg_conffdetail,
- "conffderef readlink gave %d, '%s'",
+ "conffderef readlink gave %zd, '%s'",
  r, target.buf);
 
if (target.buf[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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 5f40ae0644cf266f533d63cdc8643164f4d6b3c3
Author: Guillem Jover 
Date:   Thu Aug 25 20:40:42 2011 +0200

dpkg: Print a message instead of asserting on readlink/stat size discrepancy

This will help the user diagnose which file was affected and in
correcting the situation, which in most cases is due to file system
breakage, or non POSIX compliance.

Closes: #639229

diff --git a/debian/changelog b/debian/changelog
index 977d27d..4967e00 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -202,6 +202,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
   * Change Dpkg::Compression default values depending on the compressor
 used, and as such dpkg-source inherits this functionality.
 Prompted by Timo Juhani Lindfors .
+  * Print an actual error or warning message instead of assert()ing on
+readlink()/stat() size discrepancies. Closes: #639229
 
   [ Updated dpkg translations ]
   * German (Sven Joachim). Closes: #620312
diff --git a/src/archives.c b/src/archives.c
index 6e36409..a275b55 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -830,7 +830,9 @@ tarobject(void *ctx, struct tar_entry *ti)
   r = readlink(fnamevb.buf, symlinkfn.buf, symlinkfn.size);
   if (r < 0)
 ohshite(_("unable to read link `%.255s'"), ti->name);
-  assert(r == stab.st_size);
+  else if (r != stab.st_size)
+ohshit(_("symbolic link '%.250s' size has changed from %jd to %zd"),
+   fnamevb.buf, stab.st_size, r);
   varbuf_trunc(&symlinkfn, r);
   varbuf_end_str(&symlinkfn);
   if (symlink(symlinkfn.buf,fnametmpvb.buf))
diff --git a/src/configure.c b/src/configure.c
index 4a38db0..c75e8c3 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -418,8 +418,12 @@ conffderef(struct pkginfo *pkg, struct varbuf *result, 
const char *in)
  " (= '%s'): %s"),
pkg->name, in, result->buf, 
strerror(errno));
return -1;
+   } else if (r != stab.st_size) {
+   warning(_("symbolic link '%.250s' size has "
+ "changed from %jd to %zd"),
+   result->buf, stab.st_size, r);
+   return -1;
}
-   assert(r == stab.st_size); /* XXX: debug */
varbuf_trunc(&target, r);
varbuf_end_str(&target);
 

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 2cd316401fa2451e266562cf689bdfc7b4c501e8
Author: Guillem Jover 
Date:   Mon May 2 21:51:47 2011 +0200

libdpkg: Add new BUFFER_FILTER_NULL filter action

diff --git a/lib/dpkg/buffer.c b/lib/dpkg/buffer.c
index ce620dc..99015d2 100644
--- a/lib/dpkg/buffer.c
+++ b/lib/dpkg/buffer.c
@@ -57,6 +57,8 @@ static off_t
 buffer_filter_init(struct buffer_data *data)
 {
switch (data->type) {
+   case BUFFER_FILTER_NULL:
+   break;
case BUFFER_FILTER_MD5:
buffer_md5_init(data);
break;
@@ -87,6 +89,8 @@ static off_t
 buffer_filter_done(struct buffer_data *data)
 {
switch (data->type) {
+   case BUFFER_FILTER_NULL:
+   break;
case BUFFER_FILTER_MD5:
buffer_md5_done(data);
break;
@@ -107,6 +111,7 @@ buffer_write(struct buffer_data *data, const void *buf, 
off_t length)
ret = fd_write(data->arg.i, buf, length);
break;
case BUFFER_WRITE_NULL:
+   case BUFFER_FILTER_NULL:
break;
case BUFFER_FILTER_MD5:
MD5Update(&(((struct buffer_md5_ctx *)data->arg.ptr)->ctx), 
buf, length);
diff --git a/lib/dpkg/buffer.h b/lib/dpkg/buffer.h
index ce89470..3677d76 100644
--- a/lib/dpkg/buffer.h
+++ b/lib/dpkg/buffer.h
@@ -35,6 +35,8 @@ DPKG_BEGIN_DECLS
 #define BUFFER_WRITE_VBUF  1
 #define BUFFER_WRITE_FD2
 #define BUFFER_WRITE_NULL  3
+
+#define BUFFER_FILTER_NULL 4
 #define BUFFER_FILTER_MD5  5
 
 #define BUFFER_READ_FD 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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 3c83f54bfe1f7d17c878c0897f9762ea8adc64dc
Author: Guillem Jover 
Date:   Fri Jun 17 14:11:43 2011 +0200

libdpkg: Rename BUFFER_WRITE_MD5 to BUFFER_FILTER_MD5

diff --git a/lib/dpkg/buffer.c b/lib/dpkg/buffer.c
index 03cbf86..ce620dc 100644
--- a/lib/dpkg/buffer.c
+++ b/lib/dpkg/buffer.c
@@ -57,7 +57,7 @@ static off_t
 buffer_filter_init(struct buffer_data *data)
 {
switch (data->type) {
-   case BUFFER_WRITE_MD5:
+   case BUFFER_FILTER_MD5:
buffer_md5_init(data);
break;
}
@@ -87,7 +87,7 @@ static off_t
 buffer_filter_done(struct buffer_data *data)
 {
switch (data->type) {
-   case BUFFER_WRITE_MD5:
+   case BUFFER_FILTER_MD5:
buffer_md5_done(data);
break;
}
@@ -108,7 +108,7 @@ buffer_write(struct buffer_data *data, const void *buf, 
off_t length)
break;
case BUFFER_WRITE_NULL:
break;
-   case BUFFER_WRITE_MD5:
+   case BUFFER_FILTER_MD5:
MD5Update(&(((struct buffer_md5_ctx *)data->arg.ptr)->ctx), 
buf, length);
break;
default:
diff --git a/lib/dpkg/buffer.h b/lib/dpkg/buffer.h
index 4ee158c..ce89470 100644
--- a/lib/dpkg/buffer.h
+++ b/lib/dpkg/buffer.h
@@ -35,7 +35,7 @@ DPKG_BEGIN_DECLS
 #define BUFFER_WRITE_VBUF  1
 #define BUFFER_WRITE_FD2
 #define BUFFER_WRITE_NULL  3
-#define BUFFER_WRITE_MD5   5
+#define BUFFER_FILTER_MD5  5
 
 #define BUFFER_READ_FD 0
 
@@ -48,10 +48,10 @@ struct buffer_data {
 };
 
 # define buffer_md5(buf, hash, limit) \
-   buffer_hash(buf, hash, BUFFER_WRITE_MD5, limit)
+   buffer_hash(buf, hash, BUFFER_FILTER_MD5, limit)
 
 # define fd_md5(fd, hash, limit, ...) \
-   buffer_copy_IntPtr(fd, BUFFER_READ_FD, hash, BUFFER_WRITE_MD5, \
+   buffer_copy_IntPtr(fd, BUFFER_READ_FD, hash, BUFFER_FILTER_MD5, \
   limit, __VA_ARGS__)
 # define fd_fd_copy(fd1, fd2, limit, ...) \
buffer_copy_IntInt(fd1, BUFFER_READ_FD, fd2, BUFFER_WRITE_FD, \

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 7585faa92009f15b06e346cddaa5e4ce92df7079
Author: Guillem Jover 
Date:   Mon May 2 10:25:38 2011 +0200

libdpkg: Namespace buffer init and done functions with buffer_filter_

This makes it clear these functions are not to initialize normal
buffer operations, but just for when a filter is in place.

diff --git a/lib/dpkg/buffer.c b/lib/dpkg/buffer.c
index c99af0f..03cbf86 100644
--- a/lib/dpkg/buffer.c
+++ b/lib/dpkg/buffer.c
@@ -54,7 +54,7 @@ buffer_md5_init(struct buffer_data *data)
 }
 
 static off_t
-buffer_init(struct buffer_data *data)
+buffer_filter_init(struct buffer_data *data)
 {
switch (data->type) {
case BUFFER_WRITE_MD5:
@@ -84,7 +84,7 @@ buffer_md5_done(struct buffer_data *data)
 }
 
 static off_t
-buffer_done(struct buffer_data *data)
+buffer_filter_done(struct buffer_data *data)
 {
switch (data->type) {
case BUFFER_WRITE_MD5:
@@ -142,9 +142,9 @@ buffer_hash(const void *input, void *output, int type, 
off_t limit)
struct buffer_data data = { .arg.ptr = output, .type = type };
off_t ret;
 
-   buffer_init(&data);
+   buffer_filter_init(&data);
ret = buffer_write(&data, input, limit);
-   buffer_done(&data);
+   buffer_filter_done(&data);
 
return ret;
 }
@@ -165,7 +165,7 @@ buffer_copy(struct buffer_data *read_data, struct 
buffer_data *write_data,
 
buf = m_malloc(bufsize);
 
-   buffer_init(write_data);
+   buffer_filter_init(write_data);
 
while (bufsize > 0) {
bytesread = buffer_read(read_data, buf, bufsize);
@@ -198,7 +198,7 @@ buffer_copy(struct buffer_data *read_data, struct 
buffer_data *write_data,
if (limit > 0)
ohshit(_("short read on buffer copy for %s"), desc);
 
-   buffer_done(write_data);
+   buffer_filter_done(write_data);
 
free(buf);
 

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 3650a669fb01737444656916a6a7a09e82800679
Author: Guillem Jover 
Date:   Tue May 3 10:55:45 2011 +0200

libdpkg: Rename fd_null_copy() to fd_skip()

diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index f80955e..737dab7 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -175,8 +175,8 @@ extracthalf(const char *debar, const char *dir, const char 
*taroption,
   } else if (arh.ar_name[0] == '_') {
 /* Members with ‘_’ are noncritical, and if we don't understand
  * them we skip them. */
-fd_null_copy(arfd, memberlen + (memberlen & 1),
- _("skipped archive member data from %s"), debar);
+fd_skip(arfd, memberlen + (memberlen & 1),
+_("skipped archive member data from %s"), debar);
   } else {
if (strncmp(arh.ar_name, ADMINMEMBER, sizeof(arh.ar_name)) == 0)
  adminmember = 1;
@@ -201,8 +201,8 @@ extracthalf(const char *debar, const char *dir, const char 
*taroption,
   ctrllennum= memberlen;
 }
 if (!adminmember != !admininfo) {
-  fd_null_copy(arfd, memberlen + (memberlen & 1),
-   _("skipped archive member data from %s"), debar);
+  fd_skip(arfd, memberlen + (memberlen & 1),
+  _("skipped archive member data from %s"), debar);
 } else {
   /* Yes! - found it. */
   break;
@@ -238,8 +238,8 @@ extracthalf(const char *debar, const char *dir, const char 
*taroption,
   memberlen = ctrllennum;
 } else {
   memberlen = stab.st_size - ctrllennum - strlen(ctrllenbuf) - l;
-  fd_null_copy(arfd, ctrllennum,
-   _("skipped archive control member data from %s"), debar);
+  fd_skip(arfd, ctrllennum,
+  _("skipped archive control member data from %s"), debar);
 }
 
 if (admininfo >= 2) {
diff --git a/dpkg-split/join.c b/dpkg-split/join.c
index 95ed64a..1dd124e 100644
--- a/dpkg-split/join.c
+++ b/dpkg-split/join.c
@@ -55,7 +55,7 @@ void reassemble(struct partinfo **partlist, const char 
*outputfile) {
 fd_in = open(pi->filename, O_RDONLY);
 if (fd_in < 0)
   ohshite(_("unable to (re)open input part file `%.250s'"), pi->filename);
-fd_null_copy(fd_in, pi->headerlen, _("skipping split package header"));
+fd_skip(fd_in, pi->headerlen, _("skipping split package header"));
 fd_fd_copy(fd_in, fd_out, pi->thispartlen, _("split package part"));
 close(fd_in);
 
diff --git a/lib/dpkg/buffer.h b/lib/dpkg/buffer.h
index 436a22e..4ee158c 100644
--- a/lib/dpkg/buffer.h
+++ b/lib/dpkg/buffer.h
@@ -59,7 +59,7 @@ struct buffer_data {
 # define fd_vbuf_copy(fd, buf, limit, ...) \
buffer_copy_IntPtr(fd, BUFFER_READ_FD, buf, BUFFER_WRITE_VBUF, \
   limit, __VA_ARGS__)
-# define fd_null_copy(fd, limit, ...) \
+# define fd_skip(fd, limit, ...) \
buffer_skip_Int(fd, BUFFER_READ_FD, limit, __VA_ARGS__)
 
 off_t buffer_copy_IntPtr(int i, int typeIn, void *p, int typeOut,
diff --git a/src/archives.c b/src/archives.c
index f03bd5d..6e36409 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -191,9 +191,9 @@ tarfile_skip_one_forward(struct tarcontext *tc, struct 
tar_entry *ti)
   if (ti->type == tar_filetype_file) {
 char fnamebuf[256];
 
-fd_null_copy(tc->backendpipe, ti->size,
- _("skipped unpacking file '%.255s' (replaced or excluded?)"),
- path_quote_filename(fnamebuf, ti->name, 256));
+fd_skip(tc->backendpipe, ti->size,
+_("skipped unpacking file '%.255s' (replaced or excluded?)"),
+path_quote_filename(fnamebuf, ti->name, 256));
 r = ti->size % TARBLKSZ;
 if (r > 0)
   if (fd_read(tc->backendpipe, databuf, TARBLKSZ - r) < 0)
diff --git a/src/processarc.c b/src/processarc.c
index fa41833..250c38c 100644
--- a/src/processarc.c
+++ b/src/processarc.c
@@ -846,7 +846,7 @@ void process_archive(const char *filename) {
   ohshit(_("corrupted filesystem tarfile - corrupted package archive"));
 }
   }
-  fd_null_copy(p1[0], -1, _("dpkg-deb: zap possible trailing zeros"));
+  fd_skip(p1[0], -1, _("dpkg-deb: zap possible trailing zeros"));
   close(p1[0]);
   p1[0] = -1;
   subproc_wait_check(pid, BACKEND " --fsys-tarfile", PROCPIPE);

-- 
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-309-g2ccd37b

2011-09-09 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 3416f1d5c7a78e49a52f079b1e2a8576025650cb
Author: Guillem Jover 
Date:   Fri Sep 9 07:19:27 2011 +0200

libdpkg: Add a test case for fd_md5()

diff --git a/lib/dpkg/test/t-buffer.c b/lib/dpkg/test/t-buffer.c
index f90167d..a34c182 100644
--- a/lib/dpkg/test/t-buffer.c
+++ b/lib/dpkg/test/t-buffer.c
@@ -2,7 +2,7 @@
  * libdpkg - Debian packaging suite library routines
  * t-buffer.c - test buffer handling
  *
- * Copyright © 2009-2010 Guillem Jover 
+ * Copyright © 2009-2011 Guillem Jover 
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,24 +25,56 @@
 #include 
 #include 
 
+#include 
+
+#include 
+#include 
 #include 
 
+static const char str_empty[] = "";
+static const char ref_hash_empty[] = "d41d8cd98f00b204e9800998ecf8427e";
+static const char str_test[] = "this is a test string\n";
+static const char ref_hash_test[] = "475aae3b885d70a9130eec23ab33f2b9";
+
 static void
 test_buffer_hash(void)
 {
-   const char str_test[] = "this is a test string\n";
-   const char str_empty[] = "";
char hash[MD5HASHLEN + 1];
 
buffer_md5(str_empty, hash, strlen(str_empty));
-   test_str(hash, ==, "d41d8cd98f00b204e9800998ecf8427e");
+   test_str(hash, ==, ref_hash_empty);
 
buffer_md5(str_test, hash, strlen(str_test));
-   test_str(hash, ==, "475aae3b885d70a9130eec23ab33f2b9");
+   test_str(hash, ==, ref_hash_test);
+}
+
+static void
+test_fdio_hash(void)
+{
+   char hash[MD5HASHLEN + 1];
+   char *test_file;
+   int fd;
+
+   test_file = strdup("test.XX");
+   test_pass(test_file != NULL);
+   fd = mkstemp(test_file);
+   test_pass(fd >= 0);
+
+   fd_md5(fd, hash, -1, "test empty file");
+   test_str(hash, ==, ref_hash_empty);
+
+   test_pass(write(fd, str_test, strlen(str_test)) == strlen(str_test));
+   test_pass(lseek(fd, 0, SEEK_SET) == 0);
+
+   fd_md5(fd, hash, -1, "test filled file");
+   test_str(hash, ==, ref_hash_test);
+
+   test_pass(unlink(test_file) == 0);
 }
 
 static void
 test(void)
 {
test_buffer_hash();
+   test_fdio_hash();
 }

-- 
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