dcavalca / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone

Blame 0014-fsm-Call-new-rpmpluginsCallFsmFileInstall-in-rpmPack.patch

2f13d7
From ad46eb4132cbd2c4ee23686a1c52f2fc57afffc5 Mon Sep 17 00:00:00 2001
2f13d7
From: chantra <chantr4@gmail.com>
2f13d7
Date: Tue, 8 Feb 2022 17:06:55 -0800
2f13d7
Subject: [PATCH 14/30] [fsm] Call new `rpmpluginsCallFsmFileInstall` in
2f13d7
 `rpmPackageFilesInstall`
2f13d7
2f13d7
Call `rpmpluginsCallFsmFileInstall` for every files to be installed by
2f13d7
`rpmPackageFilesInstall`, this allows for plugin such as reflink to
2f13d7
write (reflink) a file and make sure the parent directories have already
2f13d7
been created.
2f13d7
If this was done in `rpmpluginsCallFsmFilePre`, the directories may be
2f13d7
missing, which makes file installation fail.
2f13d7
---
2f13d7
 lib/fsm.c | 29 +++++++++--------------------
2f13d7
 1 file changed, 9 insertions(+), 20 deletions(-)
2f13d7
2f13d7
diff --git a/lib/fsm.c b/lib/fsm.c
2f13d7
index feda3750c..711f553d3 100644
2f13d7
--- a/lib/fsm.c
2f13d7
+++ b/lib/fsm.c
2f13d7
@@ -53,7 +53,6 @@ struct filedata_s {
2f13d7
     int stage;
2f13d7
     int setmeta;
2f13d7
     int skip;
2f13d7
-    int plugin_contents;
2f13d7
     rpmFileAction action;
2f13d7
     const char *suffix;
2f13d7
     char *fpath;
2f13d7
@@ -921,23 +920,12 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
2f13d7
 	/* Remap file perms, owner, and group. */
2f13d7
 	rc = rpmfiStat(fi, 1, &fp->sb);
2f13d7
 
2f13d7
+	setFileState(fs, fx);
2f13d7
 	fsmDebug(fp->fpath, fp->action, &fp->sb);
2f13d7
 
2f13d7
 	/* Run fsm file pre hook for all plugins */
2f13d7
 	rc = rpmpluginsCallFsmFilePre(plugins, fi, fp->fpath,
2f13d7
 				      fp->sb.st_mode, fp->action);
2f13d7
-	fp->plugin_contents = 0;
2f13d7
-	switch (rc) {
2f13d7
-	case RPMRC_OK:
2f13d7
-	    setFileState(fs, fx);
2f13d7
-	    break;
2f13d7
-	case RPMRC_PLUGIN_CONTENTS:
2f13d7
-	    fp->plugin_contents = 1;
2f13d7
-	    // reduce reads on cpio to this value. Could be zero if
2f13d7
-	    // this is from a hard link.
2f13d7
-	    rc = RPMRC_OK;
2f13d7
-	    break;
2f13d7
-	}
2f13d7
 	fp->stage = FILE_PRE;
2f13d7
     }
2f13d7
     fi = rpmfiFree(fi);
2f13d7
@@ -992,14 +980,15 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
2f13d7
 	    if (fp->action == FA_TOUCH)
2f13d7
 		continue;
2f13d7
 
2f13d7
-            if (S_ISREG(fp->sb.st_mode)) {
2f13d7
+	    rpmRC plugin_rc = rpmpluginsCallFsmFileInstall(plugins, fi, fp->fpath, fp->sb.st_mode, fp->action);
2f13d7
+	    if(!(plugin_rc == RPMRC_PLUGIN_CONTENTS || plugin_rc == RPMRC_OK)){
2f13d7
+		rc = plugin_rc;
2f13d7
+	    } else if(plugin_rc == RPMRC_PLUGIN_CONTENTS){
2f13d7
+		rc = RPMRC_OK;
2f13d7
+	    } else if (S_ISREG(fp->sb.st_mode)) {
2f13d7
 		if (rc == RPMERR_ENOENT) {
2f13d7
-		    if(fp->plugin_contents) {
2f13d7
-			rc = RPMRC_OK;
2f13d7
-		    }else {
2f13d7
-			rc = fsmMkfile(fi, fp, files, psm, nodigest,
2f13d7
-			    &firstlink, &firstlinkfile);
2f13d7
-		    }
2f13d7
+		    rc = fsmMkfile(fi, fp, files, psm, nodigest,
2f13d7
+			&firstlink, &firstlinkfile);
2f13d7
 		}
2f13d7
             } else if (S_ISDIR(fp->sb.st_mode)) {
2f13d7
                 if (rc == RPMERR_ENOENT) {
2f13d7
-- 
2f13d7
2.35.1
2f13d7