teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

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

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