>Submitter-Id: current-users >Originator: Marcus von Appen >Organization: >Confidential: no >Synopsis: [PATCH]: prevent checksum mismatches for compiled python files >on installing python ports via the ports tree >Severity: non-critical >Priority: medium >Category: ports >Class: sw-bug >Release: FreeBSD 9.0-STABLE amd64 >Environment: System: FreeBSD medusa.sysfault.org 9.0-STABLE FreeBSD 9.0-STABLE #0: Mon May 14 15:08:44 CEST 2012 r...@medusa.sysfault.org:/usr/obj/usr/src/sys/MEDUSA amd64
>Description: The default configuration within bsd.python.mk installs python packages that use distutils or easy_install with byte-compiled files. The compiled (.pyc/.pyo) files contain a timestamp and magic number which are used as identicators for recompiling the files, if their original source (.py) differs in its st_mtime value or if Python's magic number changes. Whenever the byte-compiled files change, a checksum mismatch will be raised on deinstall or reinstalling the port. For a lengthy rant about this issue, check http://wiki.freebsd.org/Ports/Python/CompiledPackages >How-To-Repeat: - install a python port that installs .pyc/.pyo files - slightly modify one of the original .py files - OR - - change the date/timestamp on the original file (using touch) - deinstall/reinstall the Python interpreter - (as root user) import the file as module in the python interpreter - deinstall the port >Fix: The following fix introduces a new _CLEANUP_CONTENTS command chain, which is injected into the fake-pkg: target. It can be used to perform clean-up operations on the +CONTENTS file of the pkg_install toolchain. Within bsd.python.mk _CLEANUP_CONTENTS will be enhanced, so that the @comment MD5: entry for +CONTENTS entries, that denote a .pyc or .py file, is removed. The change will need an -exp run to verify that the installation and deinstallation still works for all ports. Index: Mk/bsd.port.mk =================================================================== RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v retrieving revision 1.724 diff -u -r1.724 bsd.port.mk --- Mk/bsd.port.mk 31 May 2012 14:27:23 -0000 1.724 +++ Mk/bsd.port.mk 3 Jun 2012 12:24:32 -0000 @@ -5850,6 +5850,8 @@ .endif .endif +_CLEANUP_CONTENTS?= ${DO_NADA}; + # Fake installation of package so that user can pkg_delete it later. # Also, make sure that an installed port is recognized correctly in # accordance to the @pkgdep directive in the packing lists @@ -5869,6 +5871,7 @@ ${ECHO_MSG} "===> Registering installation for ${PKGNAME}"; \ ${MKDIR} ${PKG_DBDIR}/${PKGNAME}; \ ${PKG_CMD} ${PKG_ARGS} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \ + ${_CLEANUP_CONTENTS} \ ${CP} ${DESCR} ${PKG_DBDIR}/${PKGNAME}/+DESC; \ ${ECHO_CMD} ${COMMENT:Q} > ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \ if [ -f ${PKGINSTALL} ]; then \ Index: Mk/bsd.python.mk =================================================================== RCS file: /home/pcvs/ports/Mk/bsd.python.mk,v retrieving revision 1.146 diff -u -r1.146 bsd.python.mk --- Mk/bsd.python.mk 30 May 2012 14:54:34 -0000 1.146 +++ Mk/bsd.python.mk 3 Jun 2012 12:24:32 -0000 @@ -515,6 +515,10 @@ PYDISTUTILS_EGGINFO?= ${PYDISTUTILS_PKGNAME:C/[^A-Za-z0-9.]+/_/g}-${PYDISTUTILS_PKGVERSION:C/[^A-Za-z0-9.]+/_/g}-py${PYTHON_VER}.egg-info PYDISTUTILS_EGGINFODIR?=${PYTHONPREFIX_SITELIBDIR} +# Override bsd.port.mk's setting +_CLEANUP_CONTENTS+= \ + ${SED} -i -e '/\.py[co]$$/{n;d;}' ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; + .if !defined(PYDISTUTILS_NOEGGINFO) && \ (defined(INSTALLS_EGGINFO) || \ (defined(USE_PYDISTUTILS) && \ _______________________________________________ freebsd-python@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-python To unsubscribe, send any mail to "freebsd-python-unsubscr...@freebsd.org"