Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-projects commit in portage-utils: qmerge.c
Date: Tue, 30 Apr 2013 01:50:29
Message-Id: 20130430015020.EDC272171D@flycatcher.gentoo.org
1 vapier 13/04/30 01:50:20
2
3 Modified: qmerge.c
4 Log:
5 qmerge: add support for FEATURES=config-protect-if-modified when unmerging
6
7 Revision Changes Path
8 1.128 portage-utils/qmerge.c
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.128&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?rev=1.128&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qmerge.c?r1=1.127&r2=1.128
13
14 Index: qmerge.c
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v
17 retrieving revision 1.127
18 retrieving revision 1.128
19 diff -u -r1.127 -r1.128
20 --- qmerge.c 29 Apr 2013 23:03:31 -0000 1.127
21 +++ qmerge.c 30 Apr 2013 01:50:20 -0000 1.128
22 @@ -1,7 +1,7 @@
23 /*
24 * Copyright 2005-2010 Gentoo Foundation
25 * Distributed under the terms of the GNU General Public License v2
26 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.127 2013/04/29 23:03:31 vapier Exp $
27 + * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.128 2013/04/30 01:50:20 vapier Exp $
28 *
29 * Copyright 2005-2010 Ned Ludd - <solar@g.o>
30 * Copyright 2005-2010 Mike Frysinger - <vapier@g.o>
31 @@ -65,7 +65,7 @@
32 COMMON_OPTS_HELP
33 };
34
35 -static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.127 2013/04/29 23:03:31 vapier Exp $";
36 +static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.128 2013/04/30 01:50:20 vapier Exp $";
37 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
38
39 char search_pkgs = 0;
40 @@ -1078,6 +1078,8 @@
41 makeargv(config_protect, &cp_argc, &cp_argv);
42 makeargv(config_protect_mask, &cpm_argc, &cpm_argv);
43
44 + bool unmerge_config_protected = !!strstr(features, "config-protect-if-modified");
45 +
46 while (getline(&buf, &buflen, fp) != -1) {
47 queue *q;
48 contents_entry *e;
49 @@ -1097,17 +1099,21 @@
50
51 /* Should we remove in order symlinks,objects,dirs ? */
52 switch (e->type) {
53 - case CONTENTS_DIR:
54 - if (!protected) {
55 - /* since the dir contains files, we remove it later */
56 - llist_char *list = xmalloc(sizeof(llist_char));
57 - list->data = xstrdup(e->name);
58 - list->next = dirs;
59 - dirs = list;
60 - }
61 + case CONTENTS_DIR: {
62 + /* since the dir contains files, we remove it later */
63 + llist_char *list = xmalloc(sizeof(llist_char));
64 + list->data = xstrdup(e->name);
65 + list->next = dirs;
66 + dirs = list;
67 continue;
68 + }
69
70 case CONTENTS_OBJ:
71 + if (protected && unmerge_config_protected) {
72 + /* If the file wasn't modified, unmerge it */
73 + unsigned char *hash = hash_file_at(portroot_fd, e->name + 1, HASH_MD5);
74 + protected = strcmp(e->digest, (const char *)hash);
75 + }
76 break;
77
78 case CONTENTS_SYM: