Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Aug 2010 00:01:33 GMT
From:      Ivan Voras <ivoras@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 182448 for review
Message-ID:  <201008160001.o7G01XTN008811@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@182448?ac=10

Change 182448 by ivoras@ursaminor on 2010/08/16 00:01:00

	Avoid shuffling dependancies if already shuffled, add more optional
	verbose messages.

Affected files ...

.. //depot/projects/soc2010/pkg_patch/src/patch/Makefile#37 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/Notes.txt#7 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/applypatch.c#27 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/applypatch.h#27 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/hashjob.c#36 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/hashjob.h#36 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/main.c#38 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/mkpatch.c#35 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/mkpatch.h#35 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/mkpatchdir.c#20 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/mkpatchdir.h#19 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/pkg_patch.1#9 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/pkg_patch.h#35 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/support.c#34 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/updateweb.c#15 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/updateweb.h#15 edit

Differences ...

==== //depot/projects/soc2010/pkg_patch/src/patch/Makefile#37 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/Notes.txt#7 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/applypatch.c#27 (text+ko) ====

@@ -307,7 +307,7 @@
 	if (access(fpatch, R_OK) != 0)
 		err(1, "Access error reading file: %s", fpatch);
 	snprintf(dpatch, PATH_MAX, "%s/patch", my_tmp);
-	if (access(dpatch, R_OK) != 0)
+	if (access(dpatch, R_OK) == 0)
 		rm_rf(dpatch);
 	if (mkdir(dpatch, 0700) != 0)
 		err(1, "Cannot create directory: %s", dpatch);
@@ -346,6 +346,9 @@
 	 * Step 2 - read the existing (live system) package data and the new
 	 * package data.
 	 */
+	memset(&pkg_live, 0, sizeof(pkg_live));
+	memset(&pkg_new, 0, sizeof(pkg_new));
+	memset(&xpatch, 0, sizeof(xpatch));
 	if (read_package_by_name(pp.source, &pkg_live) != 0)
 		err(1, "Cannot read package information for %s", pp.source);
 	snprintf(tmp, PATH_MAX, "%s/%s", dpatch, CONTENTS_FNAME);
@@ -360,6 +363,9 @@
 		printf("Verifying live system and patch data consistency...\n");
 	/* Check that files to be added don't exist already. */
 	STAILQ_FOREACH(pl, &pp.pp_add, linkage) {
+		snprintf(tmp, PATH_MAX, "%s/%s", dpatch, pl->filename);
+		if (isdir(tmp))
+			continue;
 		if (pkg_to_live_filename(tmp, pl->filename, &pkg_new, "pp_add")
 		    != 0) {
 			err_count++;
@@ -435,6 +441,8 @@
 	
 	baton_twirl();
 	/* Step 4 - backup the existing package */
+	if (Verbose > 1)
+		printf("Backing up the old package to %s...\n", backup_pkg);
 	if (pkg_backup(pp.source, backup_pkg) != 0)
 		err(1, "Cannot backup package: %s", pp.source);
 	
@@ -443,6 +451,8 @@
 	 * existing files and patches, then verifying all of them match expected
 	 * checksum, then rename()-ing them to the expected files.
 	 */
+	if (Verbose > 1)
+		printf("Applying patches...\n");
 	snprintf(pext, sizeof(pext), ".p%u", getpid());
 	fpvect = calloc(pplist_count(&pp.pp_patch), sizeof(*fpvect));
 	n_patched_files = 0;
@@ -492,6 +502,8 @@
 		if (pclose(fpvect[i]) != 0)
 			err(1, "pclose() failed");
 	/* Verify patched files are correct */
+	if (Verbose > 1)
+		printf("Verifying patched files...\n");
 	STAILQ_FOREACH(pl, &pp.pp_patch, linkage) {
 		char live_md5[33], target_md5[33], newfile[PATH_MAX];
 		
@@ -534,6 +546,8 @@
 		baton_twirl();
 	}
 	/* All is well, we can rename() the new files to the live ones. */
+	if (Verbose > 1)
+		printf("Finishing...\n");
 	STAILQ_FOREACH(pl, &pp.pp_patch, linkage) {
 		char newfile[PATH_MAX], livefile[PATH_MAX];
 		

==== //depot/projects/soc2010/pkg_patch/src/patch/applypatch.h#27 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/hashjob.c#36 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/hashjob.h#36 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/main.c#38 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/mkpatch.c#35 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/mkpatch.h#35 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/mkpatchdir.c#20 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/mkpatchdir.h#19 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/pkg_patch.1#9 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/pkg_patch.h#35 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/support.c#34 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/updateweb.c#15 (text+ko) ====

@@ -45,6 +45,7 @@
 	Package *plist;
 	Boolean	match;
 	Boolean found_deps;
+	Boolean shuffled;
 	TAILQ_ENTRY(patchrec)	linkage;
 };
 
@@ -401,15 +402,18 @@
 					pl = pl->next;
 					continue;
 				}
-				/* Reshuffle the found (depended-on) package to
-				 * the front. */
 				assert(pr2 != NULL);
-				if (Verbose > 2)
-					printf("Shuffling %s to head of queue\n",
-					    pr2->target);
-				TAILQ_REMOVE(&pindex.prlist, pr2, linkage);
-				TAILQ_INSERT_HEAD(&pindex.prlist, pr2, linkage);
-				scount++;
+				if (!pr2->shuffled) {
+					if (Verbose > 2)
+						printf("Shuffling %s to head "
+						    "of queue\n", pr2->target);
+					TAILQ_REMOVE(&pindex.prlist, pr2,
+					    linkage);
+					TAILQ_INSERT_HEAD(&pindex.prlist, pr2,
+					    linkage);
+					pr2->shuffled = TRUE;
+					scount++;
+				}
 				pl = pl->next;
 			}
 		}

==== //depot/projects/soc2010/pkg_patch/src/patch/updateweb.h#15 (text+ko) ====




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008160001.o7G01XTN008811>