xbps-src: only create metadata INSTALL/REMOVE scripts if it's really required.

This commit is contained in:
Juan RP 2011-10-28 11:56:39 +02:00
parent c1dfe75ae4
commit 148f02d804
2 changed files with 21 additions and 27 deletions

View file

@ -434,10 +434,21 @@ _EOF
# Create the INSTALL/REMOVE scripts if package uses them
# or uses any available trigger.
#
xbps_write_metadata_scripts_pkg install || \
msg_error "$pkgname: failed to write INSTALL metadata file!\n"
xbps_write_metadata_scripts_pkg remove || \
msg_error "$pkgname: failed to write REMOVE metadata file!\n"
local meta_install meta_remove
if [ -n "${sourcepkg}" -a "${sourcepkg}" != "${pkgname}" ]; then
meta_install=${XBPS_SRCPKGDIR}/${pkgname}/${pkgname}.INSTALL
meta_remove=${XBPS_SRCPKGDIR}/${pkgname}/${pkgname}.REMOVE
else
meta_install=${XBPS_SRCPKGDIR}/${pkgname}/INSTALL
meta_remove=${XBPS_SRCPKGDIR}/${pkgname}/REMOVE
fi
if [ -f "$meta_install" -o -n "$triggers" ]; then
xbps_write_metadata_scripts_pkg install ${meta_install} || \
msg_error "$pkgname: failed to write INSTALL metadata file!\n"
fi
if [ -f "$meta_remove" -o -n "$triggers" ]; then
xbps_write_metadata_scripts_pkg remove ${meta_remove} || \
msg_error "$pkgname: failed to write REMOVE metadata file!\n"
fi
msg_normal "$pkgver: successfully created package metadata.\n"
}

View file

@ -36,6 +36,7 @@ _add_trigger()
xbps_write_metadata_scripts_pkg()
{
local action="$1"
local action_file="$2"
local tmpf=$(mktemp -t xbps-install.XXXXXXXXXX) || exit 1
local fpattern="s|${DESTDIR}||g;s|^\./$||g;/^$/d"
local targets f info_files home shell descr groups
@ -316,38 +317,20 @@ _EOF
case "$action" in
install)
if [ -n "${sourcepkg}" -a "${sourcepkg}" != "${pkgname}" ]; then
install_file=$XBPS_SRCPKGDIR/$pkgname/$pkgname.INSTALL
else
install_file=$XBPS_SRCPKGDIR/$pkgname/INSTALL
fi
if [ -f ${install_file} ]; then
if [ -f ${action_file} ]; then
found=1
cat ${install_file} >> $tmpf
cat ${action_file} >> $tmpf
fi
echo "exit 0" >> $tmpf
if [ -z "$triggers_found" -a -z "$found" ]; then
rm -f $tmpf
return 0
fi
mv $tmpf ${DESTDIR}/INSTALL && chmod 755 ${DESTDIR}/INSTALL
;;
remove)
unset found
if [ -n "${sourcepkg}" -a "${sourcepkg}" != "${pkgname}" ]; then
remove_file=$XBPS_SRCPKGDIR/$pkgname/$pkgname.REMOVE
else
remove_file=$XBPS_SRCPKGDIR/$pkgname/REMOVE
fi
if [ -f ${remove_file} ]; then
if [ -f ${action_file} ]; then
found=1
cat ${remove_file} >> $tmpf
cat ${action_file} >> $tmpf
fi
echo "exit 0" >> $tmpf
if [ -z "$triggers_found" -a -z "$found" ]; then
rm -f $tmpf
return 0
fi
mv $tmpf ${DESTDIR}/REMOVE && chmod 755 ${DESTDIR}/REMOVE
;;
esac