- did some code review and typo fixes git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@991 cd1c1023-2f26-0410-ae45-c471fc1f0318
93 lines
3.5 KiB
Plaintext
93 lines
3.5 KiB
Plaintext
'''
|
|
Copyright (C) 2007 Fabio Erculiani
|
|
Released under GPLv2 License
|
|
|
|
- This is a template for external triggers. Only 4 functions will be called by Entropy:
|
|
@ preinstall(): triggered before injecting data into the database and copying files on the system
|
|
@ preremove(): triggered before removing files from the system and from the database
|
|
@ postinstall(): triggered after injecting data into the database and copying files on the system
|
|
@ postremove(): triggered after removing files from the system and from the database
|
|
|
|
- You must always specify them.
|
|
- Each function can only print errors and ONLY in case of critical ones, return != 0 that will be grabbed by the trigger (setting ext_status)
|
|
|
|
How it works:
|
|
- this file will be stored inside the entropy database
|
|
- trigger code will be extracted and saved into a file with the name trigger inside the package unpack directory
|
|
- will be issued:
|
|
stage = 'postinstall' # this can be postinstall, preinstall, postremove, preremove
|
|
execfile(etpConst['entropyunpackdir']+...+"trigger")
|
|
- code will have access to the entropy package dictionary and will be executed inside TriggersInterface (postinstall(),preinstall(),postremove(),preremove())
|
|
|
|
Example of pkgdata:
|
|
{
|
|
'config_protect_mask': u'/etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/splash /etc/terminfo /etc/texmf/web2c /etc/udev/rules.d',
|
|
'etpapi': 1,
|
|
'config_protect': u'/usr/NX/etc /usr/NX/home /etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/share/config/kdm /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config',
|
|
'sources': set([u'http://www.zlib.net/zlib-1.2.3.tar.bz2', u'http://www.gzip.org/zlib/zlib-1.2.3.tar.bz2']),
|
|
'download': u'packages/amd64/3.5/zlib-1.2.3-r1.tbz2',
|
|
'digest': u'35c9749fb6f782d76a746cb6c8ec1d82',
|
|
'description': u'Standard (de)compression library',
|
|
'category': u'sys-libs',
|
|
'versiontag': u'',
|
|
'provide': set([]),
|
|
'conflicts': set([]),
|
|
'content': {'/path/to/file': "filetype (can be sym,obj,dir)"},
|
|
'needed': set([u'libc.so.6']),
|
|
'version': u'1.2.3-r1',
|
|
'cflags': u'-Os -march=x86-64 -pipe',
|
|
'size': u'154723',
|
|
'homepage': u'http://www.zlib.net/',
|
|
'slot': u'0',
|
|
'datecreation': u'1194274924.0',
|
|
'branch': u'3.5',
|
|
'useflags': set([]),
|
|
'eclasses': set([u'toolchain-funcs', u'multilib', u'portability', u'eutils', u'flag-o-matic']),
|
|
'binkeywords': set([u'x86', u'amd64']),
|
|
'mirrorlinks': [],
|
|
'cxxflags': u'-Os -march=x86-64 -pipe',
|
|
'dependencies': set([]),
|
|
'chost': u'x86_64-pc-linux-gnu',
|
|
'systempackage': 'xxx',
|
|
'name': u'zlib',
|
|
'license': u'ZLIB',
|
|
'counter': 14629,
|
|
'messages': [],
|
|
'keywords': set([u'ppc', u's390', u'amd64', u'~x86-fbsd', u'x86', u'ppc64', u'm68k', u'arm', u'sparc', u'sh', u'mips', u'ia64', u'alpha', u'hppa', u'~sparc-fbsd']),
|
|
'disksize': 434998
|
|
}
|
|
|
|
'''
|
|
|
|
'''
|
|
space for real triggers
|
|
'''
|
|
def ext_postinstall(pkgdata):
|
|
print my_ext_printhello()+" postinstall"
|
|
return 0
|
|
|
|
def ext_preinstall(pkgdata):
|
|
print my_ext_printhello()+" preinstall"
|
|
return 0
|
|
|
|
def ext_postremove(pkgdata):
|
|
print my_ext_printhello()+" postremove"
|
|
return 0
|
|
|
|
def ext_preremove(pkgdata):
|
|
print my_ext_printhello()+" preremove"
|
|
return 0
|
|
|
|
'''
|
|
space for private functions
|
|
Important: function must be declared globally and have suffix my_ext_
|
|
'''
|
|
global my_ext_printhello
|
|
def my_ext_printhello():
|
|
return "hello!"
|
|
|
|
'''
|
|
run the selected function
|
|
'''
|
|
global my_ext_status
|
|
my_ext_status = eval("ext_"+stage)(pkgdata) |