[arch-general] [PATCH 1/4] Add skeleton for hooks support
This begins work on adding some sort of hook infrastructure to pacman.
There has been much discussion and little code that I have seen, so I figured
I would go ahead an implement a very basic skeleton for transaction hooks
support.
---
lib/libalpm/Makefile.am | 1 +
lib/libalpm/{sync.h => hooks.c} | 34 +++++++++++++++++++++++++---------
lib/libalpm/{add.h => hooks.h} | 19 ++++++++-----------
3 files changed, 34 insertions(+), 20 deletions(-)
diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am
index 3473a73..b4fdadf 100644
--- a/lib/libalpm/Makefile.am
+++ b/lib/libalpm/Makefile.am
@@ -44,6 +44,7 @@ libalpm_la_SOURCES = \
sync.h sync.c \
trans.h trans.c \
util.h util.c \
+ hooks.h hooks.c \
version.c
libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO)
diff --git a/lib/libalpm/sync.h b/lib/libalpm/hooks.c
similarity index 65%
copy from lib/libalpm/sync.h
copy to lib/libalpm/hooks.c
index 000a09c..9630c70 100644
--- a/lib/libalpm/sync.h
+++ b/lib/libalpm/hooks.c
@@ -1,9 +1,10 @@
/*
- * sync.h
+ * hooks.c
*
* Copyright (c) 2006-2010 Pacman Development Team
If a transaction is interrupted, the hooks need to know so that they can roll back anything that needs to be rolled back. --- lib/libalpm/trans.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index ed26aa6..d212f50 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -235,6 +235,7 @@ int SYMEXPORT alpm_trans_interrupt() RET_ERR(PM_ERR_TRANS_TYPE, -1)); trans->state = STATE_INTERRUPTED; + alpm_hook_transact("INTERRUPTED"); return(0); } -- 1.7.1.1
We don't need the whole usual pkgbuild, but having one in the git tree sure
makes testing simpler.
---
PKGBUILD | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 0000000..16cf977
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,60 @@
+# $Id: PKGBUILD 83376 2010-06-21 12:52:09Z dan $
+# Maintainer: Aaron Griffin
libalpm compliant programs now support running pre-commit and post-commit
hooks. Currently, the implementation is as simple as I can make it --
if /etc/pacman.d/hooks.d/transact.sh exists, it will be run with the
'pre-commit' parameter just before a transaction is committed, and it will
be run with 'post-commit' after the transaction has been completed.
The intent is for transact.sh to be a wrapper that calls scripts in
/etc/pacman.d/hooks.d/transact.d with the arg it is passed, but since this
is just for a demo I did not actually include any of that.
I also didn't bother adhering to any of the coding standards, as that will
be easy enough to fix up once we have something a bit more fleshed out.
---
lib/libalpm/hooks.c | 28 ++++++++++++++++++++++++++++
lib/libalpm/hooks.h | 4 ++++
lib/libalpm/trans.c | 4 +++-
3 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/lib/libalpm/hooks.c b/lib/libalpm/hooks.c
index 9630c70..5982ea5 100644
--- a/lib/libalpm/hooks.c
+++ b/lib/libalpm/hooks.c
@@ -30,6 +30,7 @@
#include
Am 23.07.2010 23:07, schrieb Victor Lowther:
This begins work on adding some sort of hook infrastructure to pacman. There has been much discussion and little code that I have seen, so I figured I would go ahead an implement a very basic skeleton for transaction hooks support.
You probably want to post that to pacman-dev instead. It might not get a proper audience, and thus lack of review, on arch-general.
On Fri, Jul 23, 2010 at 4:26 PM, Thomas Bächler
Am 23.07.2010 23:07, schrieb Victor Lowther:
This begins work on adding some sort of hook infrastructure to pacman. There has been much discussion and little code that I have seen, so I figured I would go ahead an implement a very basic skeleton for transaction hooks support.
You probably want to post that to pacman-dev instead. It might not get a proper audience, and thus lack of review, on arch-general.
Is it closed the way arch-dev-public is?
Am 23.07.2010 23:30, schrieb Victor Lowther:
On Fri, Jul 23, 2010 at 4:26 PM, Thomas Bächler
wrote: Am 23.07.2010 23:07, schrieb Victor Lowther:
This begins work on adding some sort of hook infrastructure to pacman. There has been much discussion and little code that I have seen, so I figured I would go ahead an implement a very basic skeleton for transaction hooks support.
You probably want to post that to pacman-dev instead. It might not get a proper audience, and thus lack of review, on arch-general.
Is it closed the way arch-dev-public is?
No, you can join just like arch-general.
participants (2)
-
Thomas Bächler
-
Victor Lowther