[PATCH] dpkg --hold package
I was missing hold/unhold action in dpkg command, so there is a patch with
this feature.
diff -Nru dpkg-1.10.8/main/archives.c dpkg-1.10.8.hold/main/archives.c
--- dpkg-1.10.8/main/archives.c 2002-08-24 21:22:33.000000000 +0200
+++ dpkg-1.10.8.hold/main/archives.c 2002-09-12 11:07:12.000000000 +0200
@@ -913,6 +913,8 @@
process_queue();
case act_unpack:
case act_avail:
+ case act_hold:
+ case act_unhold:
break;
default:
internerr("unknown action");
diff -Nru dpkg-1.10.8/main/hold.c dpkg-1.10.8.hold/main/hold.c
--- dpkg-1.10.8/main/hold.c 1970-01-01 01:00:00.000000000 +0100
+++ dpkg-1.10.8.hold/main/hold.c 2002-09-12 13:24:47.000000000 +0200
@@ -0,0 +1,131 @@
+/*
+ * dpkg - main program for package management
+ * hold.c - functionality for (un)holding packages
+ *
+ * Copyright (C) 1995 Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright (C) 2002 Piotr Roszatycki <dexter@debian.org>
+ *
+ * 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,
+ * 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 warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with dpkg; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <string.h>
+#include <assert.h>
+
+#include <config.h>
+#include <dpkg.h>
+#include <dpkg-db.h>
+#include <myopt.h>
+
+#include "filesdb.h"
+#include "main.h"
+
+void deferred_hold(struct pkginfo *pkg) {
+ struct varbuf raemsgs;
+ int rok;
+ struct dependency *dep;
+
+ debug(dbg_general,"deferred_hold package %s",pkg->name);
+
+ switch (cipaction->arg) {
+ case act_hold:
+ if (pkg->status == stat_notinstalled) {
+ fprintf(stderr,
+ _("dpkg - warning: ignoring request to hold %.250s which isn't installed.\n"),
+ pkg->name);
+ pkg->clientdata->istobe= itb_normal;
+ return;
+ } else if (pkg->status == stat_configfiles) {
+ fprintf(stderr,
+ _("dpkg - warning: ignoring request to hold %.250s, only the config\n"
+ " files of which are on the system.\n"),
+ pkg->name);
+ pkg->clientdata->istobe= itb_normal;
+ return;
+ } else if (pkg->want == want_hold) {
+ fprintf(stderr,
+ _("dpkg - warning: ignoring request to hold %.250s which is already held.\n"),
+ pkg->name);
+ pkg->clientdata->istobe= itb_normal;
+ return;
+ }
+ break;
+ case act_unhold:
+ if (pkg->status == stat_notinstalled) {
+ fprintf(stderr,
+ _("dpkg - warning: ignoring request to unhold %.250s which isn't installed.\n"),
+ pkg->name);
+ pkg->clientdata->istobe= itb_normal;
+ return;
+ } else if (pkg->status == stat_configfiles) {
+ fprintf(stderr,
+ _("dpkg - warning: ignoring request to unhold %.250s, only the config\n"
+ " files of which are on the system.\n"),
+ pkg->name);
+ pkg->clientdata->istobe= itb_normal;
+ return;
+ } else if (pkg->want != want_hold) {
+ fprintf(stderr,
+ _("dpkg - warning: ignoring request to unhold %.250s which is already unheld.\n"),
+ pkg->name);
+ pkg->clientdata->istobe= itb_normal;
+ return;
+ }
+ break;
+ default: internerr("unknown action for deferred_hold");
+ }
+ assert(pkg->installed.valid);
+
+ if (!f_noact) modstatdb_note(pkg);
+
+ ensure_allinstfiles_available();
+
+ if (f_noact) {
+ printf(_("Would hold or unhold %s ...\n"),pkg->name);
+ pkg->status= stat_notinstalled;
+ pkg->clientdata->istobe= itb_normal;
+ return;
+ }
+
+ oldconffsetflags(pkg->installed.conffiles);
+
+ switch (cipaction->arg) {
+ case act_hold:
+ printf(_("Holding %s ...\n"),pkg->name);
+ if (pkg->status == stat_halfconfigured || pkg->status == stat_installed) {
+ pkg->want= want_hold;
+ }
+ break;
+ case act_unhold:
+ printf(_("Unholding %s ...\n"),pkg->name);
+ if (pkg->status == stat_halfconfigured || pkg->status == stat_installed) {
+ pkg->want= want_install;
+ }
+ break;
+ default: internerr("unknown action for deferred_hold");
+ }
+
+}
+
diff -Nru dpkg-1.10.8/main/main.c dpkg-1.10.8.hold/main/main.c
--- dpkg-1.10.8/main/main.c 2002-09-01 06:47:05.000000000 +0200
+++ dpkg-1.10.8.hold/main/main.c 2002-09-12 11:06:09.000000000 +0200
@@ -62,6 +62,7 @@
dpkg -A|--record-avail <.deb file name> ... | -R|--recursive <dir> ...\n\
dpkg --configure <package name> ... | -a|--pending\n\
dpkg -r|--remove | -P|--purge <package name> ... | -a|--pending\n\
+ dpkg -H|--hold | -U|--unhold <package name> ...\n\
dpkg --get-selections [<pattern> ...] get list of selections to stdout\n\
dpkg --set-selections set package selections from stdin\n\
dpkg --update-avail <Packages-file> replace available packages info\n\
@@ -364,6 +365,8 @@
ACTION( "configure", 0, act_configure, packages ),
ACTION( "remove", 'r', act_remove, packages ),
ACTION( "purge", 'P', act_purge, packages ),
+ ACTION( "hold", 'H', act_hold, packages ),
+ ACTION( "unhold", 'U', act_unhold, packages ),
ACTIONBACKEND( "listfiles", 'L', DPKGQUERY),
ACTIONBACKEND( "status", 's', DPKGQUERY),
ACTION( "get-selections", 0, act_getselections, getselections ),
diff -Nru dpkg-1.10.8/main/main.h dpkg-1.10.8.hold/main/main.h
--- dpkg-1.10.8/main/main.h 2002-05-20 07:56:01.000000000 +0200
+++ dpkg-1.10.8.hold/main/main.h 2002-09-12 12:38:16.000000000 +0200
@@ -27,7 +27,8 @@
struct perpackagestate {
enum istobes {
- itb_normal, itb_remove, itb_installnew, itb_deconfigure, itb_preinstall
+ itb_normal, itb_remove, itb_installnew, itb_deconfigure, itb_preinstall,
+ itb_hold, itb_unhold
} istobe;
/* filelistvalid files meaning
@@ -55,7 +56,7 @@
act_printinstarch, act_compareversions, act_printavail, act_avclear,
act_forgetold, act_getselections, act_setselections, act_printgnuarch,
act_assertepoch, act_assertlongfilenames, act_assertmulticonrep,
- act_commandfd };
+ act_commandfd, act_hold, act_unhold };
enum conffopt {
cfof_prompt = 001,
@@ -148,6 +149,7 @@
void deferred_remove(struct pkginfo *pkg);
void deferred_configure(struct pkginfo *pkg);
+void deferred_hold(struct pkginfo *pkg);
extern int queuelen, sincenothing, dependtry;
diff -Nru dpkg-1.10.8/main/Makefile.in dpkg-1.10.8.hold/main/Makefile.in
--- dpkg-1.10.8/main/Makefile.in 2002-08-24 21:54:18.000000000 +0200
+++ dpkg-1.10.8.hold/main/Makefile.in 2002-09-12 12:38:27.000000000 +0200
@@ -8,7 +8,7 @@
SOURCES = main.c enquiry.c filesdb.c archives.c processarc.c \
cleanup.c select.c packages.c configure.c remove.c \
- help.c depcon.c errors.c update.c
+ help.c depcon.c errors.c update.c hold.c
MAN8PAGES = dpkg.8 dpkg-query.8
diff -Nru dpkg-1.10.8/main/packages.c dpkg-1.10.8.hold/main/packages.c
--- dpkg-1.10.8/main/packages.c 2002-05-06 18:18:15.000000000 +0200
+++ dpkg-1.10.8.hold/main/packages.c 2002-09-12 13:19:02.000000000 +0200
@@ -139,6 +139,8 @@
switch (cipaction->arg) {
case act_configure: case act_install: istobe= itb_installnew; break;
case act_remove: case act_purge: istobe= itb_remove; break;
+ case act_hold: istobe= itb_hold; break;
+ case act_unhold: istobe= itb_unhold; break;
default: internerr("unknown action for queue start");
}
for (rundown= queuehead; rundown; rundown= rundown->next) {
@@ -147,6 +149,7 @@
/* Remove it from the queue - this is a second copy ! */
switch (cipaction->arg) {
case act_configure: case act_remove: case act_purge:
+ case act_hold: case act_unhold:
printf(_("Package %s listed more than once, only processing once.\n"),
rundown->pkg->name);
break;
@@ -198,6 +201,9 @@
case act_remove: case act_purge:
deferred_remove(pkg);
break;
+ case act_hold: case act_unhold:
+ deferred_hold(pkg);
+ break;
default:
internerr("unknown action in queue");
}
Have a good fun.
--
Piotr Roszatycki, Netia Telekom S.A. .''`.
mailto:Piotr_Roszatycki@netia.net.pl : :' :
mailto:dexter@debian.org `. `'
`-
Reply to: