summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2001-02-27 22:08:53 +0000
committerjbj <devnull@localhost>2001-02-27 22:08:53 +0000
commit56bea19bfc794370c8b18de5becfdfefd560e98b (patch)
tree64aecc45e39212c9ece475327c63aa9c69bf3dbc /lib
parent74f16c53a389ed68ee93d6eccc31e0f9236ef8c4 (diff)
downloadrpm-56bea19bfc794370c8b18de5becfdfefd560e98b.tar.gz
rpm-56bea19bfc794370c8b18de5becfdfefd560e98b.tar.bz2
rpm-56bea19bfc794370c8b18de5becfdfefd560e98b.zip
Sketch out PSM_t for package state machine.
CVS patchset: 4584 CVS date: 2001/02/27 22:08:53
Diffstat (limited to 'lib')
-rw-r--r--lib/psm.c101
-rw-r--r--lib/psm.h32
-rw-r--r--lib/rpmlib.h5
-rw-r--r--lib/transaction.c15
4 files changed, 138 insertions, 15 deletions
diff --git a/lib/psm.c b/lib/psm.c
index 005ef02a0..fb70dbd2d 100644
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -911,12 +911,103 @@ static int psmChroot(rpmTransactionSet ts, TFI_t fi, int enter)
return rc;
}
+int psmStage(PSM_t psm, fileStage stage)
+{
+ const char * const cur = fileStageString(stage);
+ int rc = psm->rc;
+ int i;
+
+ switch (stage) {
+ case FSM_UNKNOWN:
+ break;
+ case FSM_PKGINSTALL:
+ break;
+ case FSM_PKGERASE:
+ break;
+ case FSM_PKGCOMMIT:
+ break;
+ case FSM_PKGBUILD:
+ break;
+ case FSM_CREATE:
+ break;
+ case FSM_INIT:
+ break;
+ case FSM_PRE:
+ break;
+ case FSM_MAP:
+ break;
+ case FSM_MKDIRS:
+ break;
+ case FSM_RMDIRS:
+ break;
+ case FSM_PROCESS:
+ break;
+ case FSM_POST:
+ break;
+ case FSM_MKLINKS:
+ break;
+ case FSM_NOTIFY:
+ break;
+ case FSM_UNDO:
+ break;
+ case FSM_FINI:
+ break;
+ case FSM_COMMIT:
+ break;
+ case FSM_DESTROY:
+ break;
+ case FSM_VERIFY:
+ break;
+
+ case FSM_UNLINK:
+ case FSM_RENAME:
+ case FSM_MKDIR:
+ case FSM_RMDIR:
+ case FSM_CHOWN:
+ case FSM_LCHOWN:
+ case FSM_CHMOD:
+ case FSM_UTIME:
+ case FSM_SYMLINK:
+ case FSM_LINK:
+ case FSM_MKFIFO:
+ case FSM_MKNOD:
+ case FSM_LSTAT:
+ case FSM_STAT:
+ case FSM_READLINK:
+ break;
+ case FSM_CHROOT:
+ break;
+
+ case FSM_NEXT:
+ case FSM_EAT:
+ case FSM_POS:
+ case FSM_PAD:
+ case FSM_TRAILER:
+ case FSM_HREAD:
+ case FSM_HWRITE:
+ case FSM_DREAD:
+ case FSM_DWRITE:
+ case FSM_ROPEN:
+ case FSM_READ:
+ case FSM_RCLOSE:
+ case FSM_WOPEN:
+ case FSM_WRITE:
+ case FSM_WCLOSE:
+ default:
+ break;
+ }
+
+ return rc;
+}
+
/**
* @todo Packages w/o files never get a callback, hence don't get displayed
* on install with -v.
*/
-int installBinaryPackage(const rpmTransactionSet ts, TFI_t fi)
+int installBinaryPackage(PSM_t psm)
{
+ const rpmTransactionSet ts = psm->ts;
+ TFI_t fi = psm->fi;
HGE_t hge = (HGE_t)fi->hge;
/*@observer@*/ static char * stepName = " install";
Header oldH = NULL;
@@ -1090,8 +1181,10 @@ exit:
return ec;
}
-int removeBinaryPackage(const rpmTransactionSet ts, TFI_t fi)
+int removeBinaryPackage(PSM_t psm)
{
+ const rpmTransactionSet ts = psm->ts;
+ TFI_t fi = psm->fi;
/*@observer@*/ static char * stepName = " erase";
Header h;
const char * failedFile = NULL;
@@ -1200,8 +1293,10 @@ exit:
return rc;
}
-int repackage(const rpmTransactionSet ts, TFI_t fi)
+int repackage(PSM_t psm)
{
+ const rpmTransactionSet ts = psm->ts;
+ TFI_t fi = psm->fi;
HGE_t hge = fi->hge;
HFD_t hfd = fi->hfd;
FD_t fd = NULL;
diff --git a/lib/psm.h b/lib/psm.h
index a8c763cdd..0a27b05b5 100644
--- a/lib/psm.h
+++ b/lib/psm.h
@@ -96,6 +96,15 @@ struct transactionFileInfo_s {
unsigned int record;
};
+/**
+ */
+struct psm_s {
+ const rpmTransactionSet ts;
+ TFI_t fi;
+ int rc; /*!< External file stage return code. */
+ fileStage stage; /*!< External package stage. */
+};
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -131,26 +140,31 @@ void freeFi(TFI_t fi)
/**
* Install binary package (from transaction set).
- * @param ts transaction set
- * @param fi transaction element file info
+ * @param psm package state machine data
* @return 0 on success, 1 on bad magic, 2 on error
*/
-int installBinaryPackage(const rpmTransactionSet ts, TFI_t fi);
+int installBinaryPackage(PSM_t psm)
+ /*@modifies psm @*/;
/**
* Erase binary package (from transaction set).
- * @param ts transaction set
- * @param fi transaction element file info
+ * @param psm package state machine data
* @return 0 on success
*/
-int removeBinaryPackage(const rpmTransactionSet ts, TFI_t fi);
+int removeBinaryPackage(PSM_t psm)
+ /*@modifies psm @*/;
/**
- * @param ts transaction set
- * @param fi transaction element file info
+ * @param psm package state machine data
* @return 0 on success
*/
-int repackage(const rpmTransactionSet ts, TFI_t fi);
+int repackage(PSM_t psm)
+ /*@modifies psm @*/;
+
+/**
+ */
+int psmStage(PSM_t psm, fileStage stage)
+ /*@modifies psm @*/;
#ifdef __cplusplus
}
diff --git a/lib/rpmlib.h b/lib/rpmlib.h
index 9c82b24b1..233159936 100644
--- a/lib/rpmlib.h
+++ b/lib/rpmlib.h
@@ -935,6 +935,11 @@ typedef /*@abstract@*/ struct fsmIterator_s * FSMI_t;
typedef /*@abstract@*/ struct fsm_s * FSM_t;
/** \ingroup rpmtrans
+ * Package state machine data.
+ */
+typedef /*@abstract@*/ struct psm_s * PSM_t;
+
+/** \ingroup rpmtrans
*/
typedef /*@abstract@*/ struct transactionFileInfo_s * TFI_t;
diff --git a/lib/transaction.c b/lib/transaction.c
index 5c7d808ac..11c877a6c 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -40,6 +40,7 @@
/*@access rpmdb@*/
/*@access rpmTransactionSet@*/
/*@access TFI_t@*/
+/*@access PSM_t@*/
/*@access rpmProblemSet@*/
/*@access rpmProblem@*/
@@ -1377,6 +1378,8 @@ int rpmRunTransactions( rpmTransactionSet ts,
int lastFailed;
int oc;
fingerPrintCache fpc;
+ struct psm_s psmbuf;
+ PSM_t psm = &psmbuf;
void * tsi;
/* FIXME: what if the same package is included in ts twice? */
@@ -1397,6 +1400,9 @@ int rpmRunTransactions( rpmTransactionSet ts,
ts->chrootDone = 0;
ts->id = time(NULL);
+ memset(psm, 0, sizeof(*psm));
+ psm->ts = ts;
+
/* Get available space on mounted file systems. */
if (!(ts->ignoreSet & RPMPROB_FILTER_DISKSPACE) &&
!rpmGetFilesystemList(&ts->filesystems, &ts->filesystemCount)) {
@@ -1755,6 +1761,7 @@ int rpmRunTransactions( rpmTransactionSet ts,
tsi = tsInitIterator(ts);
while ((fi = tsNextIterator(tsi)) != NULL) {
+ psm->fi = fi;
if (fi->fc == 0)
continue;
fi->fps = _free(fi->fps);
@@ -1787,12 +1794,13 @@ int rpmRunTransactions( rpmTransactionSet ts,
if (ts->transFlags & (RPMTRANS_FLAG_DIRSTASH | RPMTRANS_FLAG_REPACKAGE)) {
tsi = tsInitIterator(ts);
while ((fi = tsNextIterator(tsi)) != NULL) {
+ psm->fi = fi;
switch (fi->type) {
case TR_ADDED:
break;
case TR_REMOVED:
if (ts->transFlags & RPMTRANS_FLAG_REPACKAGE)
- repackage(ts, fi);
+ repackage(psm);
break;
}
}
@@ -1809,6 +1817,7 @@ int rpmRunTransactions( rpmTransactionSet ts,
int gotfd;
gotfd = 0;
+ psm->fi = fi;
switch (fi->type)
{
case TR_ADDED:
@@ -1851,7 +1860,7 @@ assert(alp == fi->ap);
ts->transFlags |= RPMTRANS_FLAG_MULTILIB;
if (fi->ap == NULL) fi->ap = alp; /* XXX WTFO? */
- if (installBinaryPackage(ts, fi)) {
+ if (installBinaryPackage(psm)) {
ourrc++;
lastFailed = i;
}
@@ -1880,7 +1889,7 @@ if (fi->ap == NULL) fi->ap = alp; /* XXX WTFO? */
if (ts->order[oc].u.removed.dependsOnIndex == lastFailed)
break;
- if (removeBinaryPackage(ts, fi))
+ if (removeBinaryPackage(psm))
ourrc++;
break;