teknoraver / rpms / rpm

Forked from rpms/rpm 2 months 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
---
bd9c00
 lib/fsm.c | 37 ++++++++++---------------------------
bd9c00
 1 file changed, 10 insertions(+), 27 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
bd9c00
@@ -55,7 +55,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;
bd9c00
@@ -918,20 +917,7 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
bd9c00
 	fp->setmeta = (fp->skip == 0) &&
bd9c00
 		      (fp->sb.st_nlink == 1 || fp->action == FA_TOUCH);
2f13d7
 
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;
bd9c00
-	default:
bd9c00
-	    fp->action = FA_SKIP;
bd9c00
-	    fp->skip = XFA_SKIPPING(fp->action);
2f13d7
-	}
bd9c00
+	setFileState(fs, fx);
bd9c00
 	fsmDebug(rpmfiDN(fi), fp->fpath, fp->action, &fp->sb);
bd9c00
 
2f13d7
 	fp->stage = FILE_PRE;
bd9c00
@@ -984,10 +970,6 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
bd9c00
 	    if (!rc) {
bd9c00
 		rc = rpmpluginsCallFsmFilePre(plugins, fi, fp->fpath,
bd9c00
 					      fp->sb.st_mode, fp->action);
bd9c00
-		if (rc == RPMRC_PLUGIN_CONTENTS) {
bd9c00
-		    fp->plugin_contents = 1;
bd9c00
-		    rc = RPMRC_OK;
bd9c00
-		}
bd9c00
 	    }
bd9c00
 	    if (rc)
bd9c00
 		goto setmeta; /* for error notification */
bd9c00
@@ -1016,15 +998,16 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
2f13d7
 	    if (fp->action == FA_TOUCH)
bd9c00
 		goto setmeta;
2f13d7
 
2f13d7
-            if (S_ISREG(fp->sb.st_mode)) {
2f13d7
+	    rpmRC plugin_rc = rpmpluginsCallFsmFileInstall(plugins, fi, fp->fpath, fp->sb.st_mode, fp->action);
bd9c00
+	    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) {
bd9c00
-		    if (fp->plugin_contents) {
2f13d7
-			rc = RPMRC_OK;
bd9c00
-		    } else {
bd9c00
-			rc = fsmMkfile(di.dirfd, fi, fp, files, psm, nodigest,
bd9c00
-				       &firstlink, &firstlinkfile,
bd9c00
-				       &di.firstdir, &fd;;
2f13d7
-		    }
bd9c00
+		    rc = fsmMkfile(di.dirfd, fi, fp, files, psm, nodigest,
bd9c00
+				   &firstlink, &firstlinkfile,
bd9c00
+				   &di.firstdir, &fd;;
2f13d7
 		}
2f13d7
             } else if (S_ISDIR(fp->sb.st_mode)) {
2f13d7
                 if (rc == RPMERR_ENOENT) {
2f13d7
-- 
2f13d7
2.35.1
2f13d7