diff --git a/xbps-src/shutils/metadata.sh b/xbps-src/shutils/metadata.sh
index ef0bb0baca..abbfa9ed9a 100644
--- a/xbps-src/shutils/metadata.sh
+++ b/xbps-src/shutils/metadata.sh
@@ -289,6 +289,12 @@ _EOF
echo "" >> $TMPFPROPS
fi
+ # pkg needs to preserve its files after removal/upgrade?
+ if [ -n "$preserve" ]; then
+ echo "preserve" >> $TMPFPROPS
+ echo "" >> $TMPFPROPS
+ fi
+
# Dependencies
if [ -n "$run_depends" ]; then
echo "run_depends" >> $TMPFPROPS
diff --git a/xbps-src/shutils/tmpl_funcs.sh b/xbps-src/shutils/tmpl_funcs.sh
index dec0aefff1..b21c2a0ad3 100644
--- a/xbps-src/shutils/tmpl_funcs.sh
+++ b/xbps-src/shutils/tmpl_funcs.sh
@@ -71,7 +71,7 @@ reset_tmpl_vars()
post_configure post_build post_install nostrip \
make_install_target version revision essential \
sgml_catalogs xml_catalogs xml_entries sgml_entries \
- disable_parallel_build run_depends font_dirs \
+ disable_parallel_build run_depends font_dirs preserve \
only_for_archs conf_files keep_libtool_archives \
noarch subpackages sourcepkg gtk_iconcache_dirs \
abi_depends api_depends triggers openrc_services \