Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=5e3af8913259d860d1c3b3ee1539657ea70fd92a

commit 5e3af8913259d860d1c3b3ee1539657ea70fd92a
Author: Michel Hermier <herm...@frugalware.org>
Date:   Sun Nov 3 11:57:27 2013 +0100

libpacman: Replace pre/post triggers thinko with simplier triggers in hook 
manner.

diff --git a/lib/libpacman/be_files.c b/lib/libpacman/be_files.c
index 967c588..856096b 100644
--- a/lib/libpacman/be_files.c
+++ b/lib/libpacman/be_files.c
@@ -441,10 +441,8 @@ static int _pacman_db_read_desc(pmdb_t *db, unsigned int 
inforeq, pmpkg_t *info)
}
_pacman_strtrim(tmp);
info->reason = atol(tmp);
-                       } else if(!strcmp(line, "%PRETRIGGERS%")) {
-                               _pacman_db_read_lines(db, &info->pretriggers, 
line, sline, fp);
-                       } else if(!strcmp(line, "%POSTTRIGGERS%")) {
-                               _pacman_db_read_lines(db, &info->posttriggers, 
line, sline, fp);
+                       } else if(!strcmp(line, "%TRIGGERS%")) {
+                               _pacman_db_read_lines(db, &info->triggers, 
line, sline, fp);
} else if(!strcmp(line, "%SIZE%") || !strcmp(line, "%CSIZE%")) {
/* NOTE: the CSIZE and SIZE fields both share the "size" field
*       in the pkginfo_t struct.  This can be done b/c CSIZE
@@ -756,8 +754,7 @@ int _pacman_db_write(pmdb_t *db, pmpkg_t *info, unsigned 
int inforeq)
fprintf(fp, "%%REASON%%\n"
"%d\n\n", info->reason);
}
-                       _pacman_db_write_stringlist("PRETRIGGERS", 
info->pretriggers, fp);
-                       _pacman_db_write_stringlist("POSTTRIGGERS", 
info->pretriggers, fp);
+                       _pacman_db_write_stringlist("TRIGGERS", info->triggers, 
fp);
} else {
if(info->size) {
fprintf(fp, "%%CSIZE%%\n"
diff --git a/lib/libpacman/package.c b/lib/libpacman/package.c
index a5d39e1..c08eba0 100644
--- a/lib/libpacman/package.c
+++ b/lib/libpacman/package.c
@@ -100,8 +100,7 @@ pmpkg_t *_pacman_pkg_dup(pmpkg_t *pkg)
newpkg->groups     = _pacman_list_strdup(pkg->groups);
newpkg->provides   = _pacman_list_strdup(pkg->provides);
newpkg->replaces   = _pacman_list_strdup(pkg->replaces);
-       newpkg->pretriggers = _pacman_list_strdup(pkg->pretriggers);
-       newpkg->posttriggers = _pacman_list_strdup(pkg->posttriggers);
+       newpkg->triggers = _pacman_list_strdup(pkg->triggers);

/* internal */
newpkg->origin     = pkg->origin;
@@ -130,8 +129,7 @@ void _pacman_pkg_free(void *data)
FREELIST(pkg->groups);
FREELIST(pkg->provides);
FREELIST(pkg->replaces);
-       FREELIST(pkg->pretriggers);
-       FREELIST(pkg->posttriggers);
+       FREELIST(pkg->triggers);
if(pkg->origin == PKG_FROM_FILE) {
FREE(pkg->data);
}
@@ -230,10 +228,8 @@ static int pkginfo_read(char *descfile, pmpkg_t *info, int 
output)
info->provides = _pacman_stringlist_append(info->provides, ptr);
} else if(!strcmp(key, "BACKUP")) {
info->backup = _pacman_stringlist_append(info->backup, ptr);
-                       } else if(!strcmp(key, "PRETRIGGER")) {
-                               info->pretriggers = 
_pacman_stringlist_append(info->pretriggers, ptr);
-                       } else if(!strcmp(key, "POSTTRIGGER")) {
-                               info->posttriggers = 
_pacman_stringlist_append(info->posttriggers, ptr);
+                       } else if(!strcmp(key, "TRIGGER")) {
+                               info->triggers = 
_pacman_stringlist_append(info->triggers, ptr);
} else {
_pacman_log(PM_LOG_DEBUG, _("%s: syntax error in description file line %d"),
info->name[0] != '\0' ? info->name : "error", linenum);
diff --git a/lib/libpacman/package.h b/lib/libpacman/package.h
index 8476c90..f60215a 100644
--- a/lib/libpacman/package.h
+++ b/lib/libpacman/package.h
@@ -77,8 +77,7 @@ struct __pmpkg_t {
pmlist_t *requiredby;
pmlist_t *conflicts;
pmlist_t *provides;
-       pmlist_t *pretriggers;
-       pmlist_t *posttriggers;
+       pmlist_t *triggers;
/* internal */
unsigned char origin;
void *data;
diff --git a/lib/libpacman/packages_transaction.c 
b/lib/libpacman/packages_transaction.c
index 91dc619..cbafffe 100644
--- a/lib/libpacman/packages_transaction.c
+++ b/lib/libpacman/packages_transaction.c
@@ -48,7 +48,7 @@ _pacman_packages_transaction_set_state(pmtrans_t *trans, int 
new_state)

_pacman_log(PM_LOG_FLOW2, _("executing %s triggers..."), trigger_function);

-       for(lp = trans->pretriggers; lp; lp = lp->next) {
+       for(lp = trans->triggers; lp; lp = lp->next) {
const char *trigger = lp->data;
char buf[PATH_MAX];

diff --git a/lib/libpacman/trans.c b/lib/libpacman/trans.c
index 5667915..490223a 100644
--- a/lib/libpacman/trans.c
+++ b/lib/libpacman/trans.c
@@ -91,8 +91,7 @@ void _pacman_trans_free(pmtrans_t *trans)
FREELISTPKGS(trans->packages);
}
FREELIST(trans->skiplist);
-       FREELIST(trans->pretriggers);
-       FREELIST(trans->posttriggers);
+       FREELIST(trans->triggers);

_pacman_trans_fini(trans);
free(trans);
@@ -202,11 +201,9 @@ int _pacman_trans_compute_triggers(pmtrans_t *trans)
for(lp = trans->packages; lp; lp = lp->next) {
pmpkg_t *pkg = lp->data;

-               trans->pretriggers = 
_pacman_stringlist_append_stringlist(trans->pretriggers, pkg->pretriggers);
-               trans->posttriggers = 
_pacman_stringlist_append_stringlist(trans->posttriggers, pkg->posttriggers);
+               trans->triggers = 
_pacman_stringlist_append_stringlist(trans->triggers, pkg->triggers);
}
-       trans->pretriggers = _pacman_list_remove_dupes(trans->pretriggers);
-       trans->posttriggers = _pacman_list_remove_dupes(trans->posttriggers);
+       trans->triggers = _pacman_list_remove_dupes(trans->triggers);
/* FIXME: Sort the triggers to have a predictable execution order */

return 0;
diff --git a/lib/libpacman/trans.h b/lib/libpacman/trans.h
index be28a25..de47230 100644
--- a/lib/libpacman/trans.h
+++ b/lib/libpacman/trans.h
@@ -62,8 +62,7 @@ struct __pmtrans_t {
pmlist_t *targets;     /* pmlist_t of (char *) */
pmlist_t *packages;    /* pmlist_t of (pmpkg_t *) or (pmsyncpkg_t *) */
pmlist_t *skiplist;    /* pmlist_t of (char *) */
-       pmlist_t *pretriggers; /* pmlist_t of (char *) */
-       pmlist_t *posttriggers;/* pmlist_t of (char *) */
+       pmlist_t *triggers;    /* pmlist_t of (char *) */
pmtrans_cbs_t cbs;
};

diff --git a/scripts/makepkg b/scripts/makepkg
index 21760cd..58be5c7 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -619,11 +619,8 @@ create_pkg()
for it in ${backup[@]}; do
$ECHO "backup = $it" >>.PKGINFO
done
-       for it in ${pretriggers[@]}; do
-               $ECHO "pretrigger = $it" >>.PKGINFO
-       done
-       for it in ${posttriggers[@]}; do
-               $ECHO "posttrigger = $it" >>.PKGINFO
+       for it in ${triggers[@]}; do
+               $ECHO "trigger = $it" >>.PKGINFO
done

# check for an install script
@@ -957,7 +954,7 @@ if [ $CLEANCACHE -ge 1 ]; then
fi

unset pkgname pkgver pkgrel pkgdesc url license groups provides force
-unset replaces depends removes conflicts backup pretriggers posttriggers 
source install makedepends
+unset replaces depends removes conflicts backup triggers source install 
makedepends
unset rodepends options pkdesc_localized
for i in `set|grep ^_F_|sed 's/\(=.*\| ()\)//'`; do unset $i; done
umask 0022
@@ -1109,10 +1106,7 @@ if [ ! -z "$subpkgs" ]; then
if [ "${#subbackup[@]}" != 0 -a "${#subbackup[@]}" != "${#subpkgs[@]}" ]; then
goodsubpkgs=0
fi
-       if [ "${#subpretriggers[@]}" != 0 -a "${#subpretriggers[@]}" != 
"${#subpkgs[@]}" ]; then
-               goodsubpkgs=0
-       fi
-       if [ "${#subposttriggers[@]}" != 0 -a "${#subposttriggers[@]}" != 
"${#subpkgs[@]}" ]; then
+       if [ "${#subtriggers[@]}" != 0 -a "${#subtriggers[@]}" != 
"${#subpkgs[@]}" ]; then
goodsubpkgs=0
fi
if [ "${#subinstall[@]}" != 0 -a "${#subinstall[@]}" != "${#subpkgs[@]}" ]; then
@@ -1825,7 +1819,7 @@ if [ ! -z "$subpkgs" ]; then
i=0
for subpkg in "${subpkgs[@]}"
do
-               unset pkgdesc license replaces groups depends rodepends removes 
conflicts provides backup pretriggers posttrigger install
+               unset pkgdesc license replaces groups depends rodepends removes 
conflicts provides backup triggers install
unset options pkgdesc_localized archs
pkgdesc="${subdescs[$i]}"
pkgdesc_localized="${subdescs_localized[$i]}"
@@ -1838,8 +1832,7 @@ if [ ! -z "$subpkgs" ]; then
conflicts="${subconflicts[$i]}"
provides="${subprovides[$i]}"
backup="${subbackup[$i]}"
-               pretriggers="${subpretriggers[$i]}"
-               posttriggers="${subposttriggers[$i]}"
+               triggers="${subtriggers[$i]}"
install="${subinstall[$i]}"
options="${suboptions[$i]}"
archs="${subarchs[$i]}"
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to