From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Mon, 8 Sep 2008 13:51:06 +0400 From: Alexey Tourbin To: devel@lists.altlinux.org Message-ID: <20080908095106.GS6477@altlinux.org> Mail-Followup-To: devel@lists.altlinux.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="z7TGvjQjjVo70d0G" Content-Disposition: inline Subject: [devel] posttrans filetriggers [2] X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.10b3 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Sep 2008 09:51:08 -0000 Archived-At: List-Archive: List-Post: --z7TGvjQjjVo70d0G Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable =E0=D2=C9=CA =F3=C5=C4=D5=CE=CF=D7 =D0=D2=CF=D3=C9=CC =CD=C5=CE=D1 =D2=C5= =C1=CC=C9=DA=CF=D7=C1=D4=D8 posttrans filetriggers, =DE=D4=CF=C2=D9 =D2=C5=DB=C9=D4=D8 =D0=D2=CF=C2=CC=C5=CD=D5 c gtk icon cach= e =D7 branch-4.1 (=C4=CC=D1 =D0=D2=C5=C4=CF=D3=D4=D1=DD=C5=C7=CF =D2=C5=CC=C9=DA=C1 =C4=C9=D3=D4=D2=C9=C2=D5=D4=C9=D7=C1). =F0=D2=CF=C2=CC=C5=CD=C1 =DC=D4=CF =D4=C1=CB=C1=D1: =C2=C9=C2=CC=C9=CF=D4= =C5=CB=C1 libgtk+2 =CD=CF=D6=C5=D4 =C9=D3=D0=CF=CC=D8=DA=CF=D7=C1=D4=D8 =CB= =C5=DB =C9=CB=CF=CE=CF=CB /usr/share/icons/hicolor/icon-theme.cache, =DE=D4=CF=C2= =D9 =D5=D3=CB=CF=D2=C9=D4=D8 =DA=C1=C7=D2=D5=DA=CB=D5 =C9=CB=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ger: #!/bin/sh if grep -qs ^/usr/share/icons/hicolor/; then gtk-update-icon-cache --force --ignore-theme-index fi =F5=D0=D2=CF=DD=C5=CE=CE=D9=CA =D0=D2=C9=CD=C5=D2 =C4=CC=D1 =D2=C5=C7=C9=D3= =D4=D2=C1=C3=C9=C9 GConf2 =D3=C8=C5=CD. /usr/lib/rpm/GConf2-schemas.filetrigger: #!/bin/sh install=3D remove=3D while read -r f; do case "$f" in /etc/gconf/schemas/*.schemas) ;; *) continue ;; esac if [ -f "$f" ]; then install=3D"$install $f" else remove=3D"$remove $f" fi done [ -z "$install" ] || gconftool-2 --makefile-install-rule $install [ -z "$remove" ] || gconftool-2 --makefile-uninstall-rule $remove =F0=CF=D3=CC=C5=C4=CE=C9=CA =D0=D2=C9=CD=C5=D2 =D0=CF=CB=C1=DA=D9=D7=C1=C5= =D4, =DE=D4=CF =CD=CF=D6=CE=CF =D2=C5=C1=CC=C9=DA=CF=D7=C1=D4=D8 =C4=CF=D3= =D4=C1=D4=CF=DE=CE=CF =D3=CC=CF=D6=CE=D9=C5 =D3=CC=D5=DE=C1=C9 =CF=C2=D2=C1=C2=CF=D4=CB=C9 =C1=D2=C7=D5=CD=C5=CE=D4=CF= =D7, =CE=C1=CB=C1=D0=CC=C9=D7=C1=D1 =C1=D2=C7=D5=CD=C5=CE=D4=D9 =D7 =C3=C9= =CB=CC=C5 (=DE=D4=CF=C2=D9 =DA=C1=D0=D5=D3=D4=C9=D4=D8 =D0=D2=CF=C7=D2=CD=CD=D5 =D7=D3=C5=C7=CF =CF=C4= =CE=C9 =D2=C1=DA). =EE=C1 =D3=C1=CD=CF=CD =C4=C5=CC=C5 =D7 =D2=C5=C1=CC=D8= =CE=CF=CD =D3=CB=D2=C9=D0=D4=C5 =CC=D5=DE=DB=C5 =C9=D3=D0=CF=CC=D8=DA=CF=D7=C1=D4=D8 xargs --delimiter=3D'\= n', =D0=CF=D4=CF=CD=D5 =DE=D4=CF argv =CD=CF=D6=C5=D4 =D0=C5=D2=C5=D0=CF=CC=CE=C9=D4=D8=D3=D1, =C1 =C6=C1=CA=CC=D9 =CD=CF=C7=D5= =D4 =D3=CF=C4=C5=D2=D6=C1=D4=D8 =D0=D2=CF=C2=C5=CC=D9). =F7 =CF=D4=CC=C9=DE=C9=C5 =CF=D4 =CD=C1=CE=C4=D2=C9=D7=CF=D7=D3=CB=CF=C7=CF= =D0=C1=D4=DE=C1, =D1 =CE=C5 =D3=D4=C1=CC =C4=C5=CC=C1=D4=D8 =D5 =C6=C1=CA= =CC=CF=D7 =D0=D2=C5=C6=C9=CB=D3=D9 "+" =C9 "-", =D4.=CB. =C9=DA-=DA=C1 =CF=D3=CF=C2=C5=CE=CE=CF=D3=D4=C5=CA li= brpm =CE=C5=CC=D8=DA=D1 =D3=C4=C5=CC=C1=D4=D8 =DE=D4=CF=C2=D9 =DC=D4=CF =C8=CF=D2=CF=DB=CF =D2=C1=C2=CF=D4=C1=CC=CF (=D4.=C5. "+" =CD=CF=D6=C5=D4 = =C9 =CE=C5 =CF=DA=CE=C1=DE=C1=D4=D8, =DE=D4=CF =C6=C1=CA=CC =C2=D9=CC =C4= =CF=C2=C1=D7=CC=C5=CE, =C1 "-" =CD=CF=D6=C5=D4 =CE=C5 =CF=DA=CE=C1=DE=C1=D4=D8, =DE=D4=CF =C6=C1= =CA=CC =D4=C1=CB=C9 =C2=D9=CC =D5=C4=C1=CC=A3=CE). =F7 =D0=CF=D3=CC=C5=C4= =CE=C5=CD =D0=D2=C9=CD=C5=D2=C5 =D1 =D0=D2=CF=D3=D4=CF =D1=D7=CE=CF =D0=D2=CF=D7=C5=D2=D1=C0 [ -f "$f" ]. Changelog since common ancestor `4.0.4-alt95.M41.2' follows: commit 462bd2a2b95b6946ccd347b8d1848943d5ae3c99 Author: Alexey Tourbin Date: Mon Sep 8 10:57:19 2008 +0400 implemented posttrans filetriggers, vaguely based on Mandriva patch Full diff since common ancestor `4.0.4-alt95.M41.2' follows: diff --git a/a b/a new file mode 100644 index 0000000..e69de29 diff --git a/configure.in b/configure.in index 2e7b53e..82a959c 100644 --- a/configure.in +++ b/configure.in @@ -1022,6 +1022,7 @@ AC_OUTPUT([ Doxyfile Makefile rpmrc macros platform r= pmpopt rpm.spec scripts/strip_files scripts/symlinks.req scripts/verify-elf + scripts/posttrans-filetriggers tests/Makefile tests/rpmrc tests/macros tests/hello-test/Makefile po/Makefile.in doc/Makefile doc/manual/Makefile diff --git a/lib/psm.c b/lib/psm.c index b9e6f8e..3ccaf60 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -900,7 +900,7 @@ static int runScript(PSM_t psm, Header h, int freePrefixes =3D 0; FD_t out; rpmRC rc =3D RPMRC_OK; - const char *n, *v, *r; + const char *n =3D NULL, *v =3D NULL, *r =3D NULL; char arg1_str [sizeof(int)*3+1] =3D ""; char arg2_str [sizeof(int)*3+1] =3D ""; =20 @@ -917,6 +917,7 @@ static int runScript(PSM_t psm, Header h, argc =3D progArgc; } =20 + if (h) xx =3D headerNVR(h, &n, &v, &r); =20 if (arg1 >=3D 0) @@ -924,9 +925,9 @@ static int runScript(PSM_t psm, Header h, if (arg2 >=3D 0) sprintf(arg2_str, "%d", arg2); =20 - if (hge(h, RPMTAG_INSTPREFIXES, &ipt, (void **) &prefixes, &numPrefixe= s)) { + if (h && hge(h, RPMTAG_INSTPREFIXES, &ipt, (void **) &prefixes, &numPr= efixes)) { freePrefixes =3D 1; - } else if (hge(h, RPMTAG_INSTALLPREFIX, NULL, (void **) &oldPrefix, NU= LL)) { + } else if (h && hge(h, RPMTAG_INSTALLPREFIX, NULL, (void **) &oldPrefi= x, NULL)) { prefixes =3D &oldPrefix; numPrefixes =3D 1; } else { @@ -1038,6 +1039,7 @@ static int runScript(PSM_t psm, Header h, } } =20 + if (n) dosetenv ("RPM_INSTALL_NAME", n, 1); =20 if (*arg1_str) @@ -2130,3 +2132,58 @@ fprintf(stderr, "*** PSM_RDB_LOAD: header #%u not fo= und\n", fi->record); return rc; /*@=3Dnullstate@*/ } + +static +void saveTriggerFiles(PSM_t psm) +{ + const rpmTransactionSet ts =3D psm->ts; + if (ts->transFlags & RPMTRANS_FLAG_TEST) + return; + if (ts->transFlags & (_noTransScripts | _noTransTriggers)) + return; + const TFI_t fi =3D psm->fi; + if (fi->fc < 1) + return; + psmStage(psm, PSM_CHROOT_IN); + const char *file =3D rpmGetPath(ts->rpmdb->db_home, "/files-awaiting-f= iletriggers"); + FILE *fp =3D fopen(file, "a"); + if (fp =3D=3D NULL) + rpmError(RPMERR_OPEN, "open of %s failed: %s\n", file, strerror(errno)); + else { + int i; + for (i =3D 0; i < fi->fc; i++) + fprintf(fp, "%s%s\n", fi->dnl[fi->dil[i]], fi->bnl[i]); + fclose(fp); + } + file =3D _free(file); + psmStage(psm, PSM_CHROOT_OUT); +} + +void psmTriggerAdded(PSM_t psm) +{ + saveTriggerFiles(psm); +} + +void psmTriggerRemoved(PSM_t psm) +{ + saveTriggerFiles(psm); +} + +void psmTriggerPosttrans(PSM_t psm) +{ + const rpmTransactionSet ts =3D psm->ts; + if (ts->transFlags & RPMTRANS_FLAG_TEST) + return; + if (ts->transFlags & (_noTransScripts | _noTransTriggers)) + return; + psmStage(psm, PSM_CHROOT_IN); + const char *file =3D rpmGetPath(ts->rpmdb->db_home, "/files-awaiting-f= iletriggers"); + const char *script =3D RPMCONFIGDIR "/posttrans-filetriggers"; + const char *argv[] =3D { script, file, NULL }; + rpmMessage(RPMMESS_VERBOSE, _("Running %s\n"), script); + int rc =3D runScript(psm, NULL, script, 2, argv, NULL, 0, 0); + if (rc =3D=3D 0) + unlink(file); + file =3D _free(file); + psmStage(psm, PSM_CHROOT_OUT); +} diff --git a/lib/psm.h b/lib/psm.h index 968178b..90f1419 100644 --- a/lib/psm.h +++ b/lib/psm.h @@ -233,6 +233,11 @@ int psmStage(PSM_t psm, pkgStage stage) /*@modifies psm, rpmGlobalMacroContext, fileSystem, internalState @*/; =20 +/* ALT: hack to implement file triggers */ +void psmTriggerAdded(PSM_t psm); +void psmTriggerRemoved(PSM_t psm); +void psmTriggerPosttrans(PSM_t psm); + #ifdef __cplusplus } #endif diff --git a/lib/transaction.c b/lib/transaction.c index 2073882..ade1c46 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -2068,6 +2068,9 @@ assert(alp =3D=3D fi->ap); ourrc++; lastFailed =3D i; } + else { + psmTriggerAdded(psm); + } fi->h =3D headerFree(fi->h); if (hsave) { fi->h =3D headerLink(hsave); @@ -2094,11 +2097,18 @@ assert(alp =3D=3D fi->ap); =20 if (psmStage(psm, PSM_PKGERASE)) ourrc++; + else { + psmTriggerRemoved(psm); + } =20 break; } (void) rpmdbSync(ts->rpmdb); } + + if (ourrc =3D=3D 0) + psmTriggerPosttrans(psm); + tsi =3D tsFreeIterator(tsi); =20 ts->flList =3D freeFl(ts, ts->flList); diff --git a/rpm-4_0.spec b/rpm-4_0.spec index 46c08b8..435831f 100644 --- a/rpm-4_0.spec +++ b/rpm-4_0.spec @@ -291,6 +291,7 @@ for dbi in \ do touch "%buildroot%_localstatedir/%name/$dbi" done +touch %buildroot%_localstatedir/%name/files-awaiting-filetriggers =20 # Prepare documentation. bzip2 -9 CHANGES ||: @@ -444,6 +445,7 @@ fi %rpmdbattr %_localstatedir/%name/Sigmd5 %rpmdbattr %_localstatedir/%name/Sha1header %rpmdbattr %_localstatedir/%name/Triggername +%rpmdbattr %_localstatedir/%name/files-awaiting-filetriggers =20 /bin/rpm %_bindir/rpm @@ -465,6 +467,8 @@ fi %_prefix/lib/rpmpopt %_prefix/lib/rpmrc =20 +%rpmattr %_rpmlibdir/posttrans-filetriggers + %rpmattr %_rpmlibdir/functions %rpmattr %_rpmlibdir/find-package %rpmdatattr %_rpmlibdir/.provides.sh diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 6d5a5c1..b9900ba 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -3,6 +3,7 @@ AUTOMAKE_OPTIONS =3D 1.4 foreign =20 EXTRA_DIST =3D \ + posttrans-filetriggers \ functions find-package .provides.sh \ find-scriptlet-requires \ brp-adjust_libraries brp-alt brp-bytecompile_python \ @@ -32,6 +33,7 @@ all: configdir =3D ${prefix}/lib/rpm config_DATA =3D .provides.sh 0common-files.req.list config_SCRIPTS =3D \ + posttrans-filetriggers \ functions find-package \ find-scriptlet-requires \ brp-adjust_libraries brp-alt brp-bytecompile_python \ diff --git a/scripts/posttrans-filetriggers.in b/scripts/posttrans-filetrig= gers.in new file mode 100755 index 0000000..1f80c51 --- /dev/null +++ b/scripts/posttrans-filetriggers.in @@ -0,0 +1,32 @@ +#!/bin/sh -efu +# +# File triggers are run at the end of successful transaction. +# +# Copyright (C) 2008 Alexey Tourbin +# +# Vaguely based on filetriggers.patch from Mandriva Linux. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +filelist=3D$1 +shift + +RC=3D0 + +if [ -s "$filelist" ]; then + LC_ALL=3DC sort -u -o "$filelist" "$filelist" + set +f + for filetrigger in @RPMCONFIGDIR@/*.filetrigger; do + [ -x "$filetrigger" ] || continue + "$filetrigger" <"$filelist" || + { + echo >&2 "$filetrigger failed" + RC=3D1 + } + done +fi + +exit $RC --z7TGvjQjjVo70d0G Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkjE9YoACgkQfBKgtDjnu0YdvACgt9BDrH2ilxC+vYANVvas523h Nh0An1YKWOJGrZP8nizGS5dXcYLRmcMc =f3YY -----END PGP SIGNATURE----- --z7TGvjQjjVo70d0G--