Skip to content

Commit

Permalink
env/setup/sourcepkg: unset all exported variables
Browse files Browse the repository at this point in the history
except known to be good one.

See 581cdac and 253b9f0
  • Loading branch information
sgn committed Dec 3, 2022
1 parent c505e3f commit 6174bd6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions common/environment/setup/sourcepkg.sh
@@ -1,6 +1,37 @@
# This shell snippet unsets all variables/functions that can be used in
# the package template (excluding subpackages).

# Exported variables
for var in $(env | sed -e 's/=.*//'); do
# Those variables in chroot.sh will be kept
case "$var" in
XBPS_* | IN_CHROOT | CHROOT_READY | SOURCE_DATE_EPOCH)
# xbps-src specific
;;
SOURCEFORGE_SITE | NONGNU_SITE | XORG_SITE | DEBIAN_SITE | GNOME_SITE)
;;
KERNEL_SITE | CPAN_SITE | PYPI_SITE | MOZILLA_SITE | GNU_SITE)
;;
FREEDESKTOP_SITE | KDE_SITE | VIDEOLAN_SITE)
;;
_ | PWD | SHLVL | USER | PATH | SHELL | HOME | LC_COLLATE | LANG | TERM | PS1)
# known variables for shell
;;
DISTCC_HOSTS | DISTCC_DIR)
;;
CCACHE_DIR | CCACHE_COMPRESS)
;;
HTTP_PROXY | HTTPS_PROXY | SOCKS_PROXY | NO_PROXY | HTTP_PROXY_AUTH)
;;
FTP_PROXY | FTP_RETRIES)
;;
*)
unset -v "$var"
;;
esac
done
unset -v var

## VARIABLES
unset -v pkgname version revision short_desc homepage license maintainer
unset -v archs distfiles checksum build_style build_helper nocross broken
Expand All @@ -20,6 +51,7 @@ unset -v nopie build_options build_options_default bootstrap repository reverts
unset -v CFLAGS CXXFLAGS FFLAGS CPPFLAGS LDFLAGS LD_LIBRARY_PATH
unset -v CC CXX CPP GCC LD AR AS RANLIB NM OBJDUMP OBJCOPY STRIP READELF PKG_CONFIG
unset -v CMAKE_GENERATOR
unset -v scons_use_destdir
# build-helper python3
unset -v PYPREFIX LDSHARED PYTHON_CONFIG PYTHONPATH _PYTHON_SYSCONFIGDATA_NAME

Expand Down

1 comment on commit 6174bd6

@Anachron
Copy link
Contributor

@Anachron Anachron commented on 6174bd6 Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is broken on at least bash:

LANG=C ./xbps-src update-check bsdtar
/home/lap/var/bldr/gitsrc/common/environment/setup/sourcepkg.sh: line 31: unset: `BASH_FUNC_filew%%': not a valid identifier
/home/lap/var/bldr/gitsrc/common/environment/setup/sourcepkg.sh: line 31: unset: `BASH_FUNC_timer_handle%%': not a valid identifier
/home/lap/var/bldr/gitsrc/common/environment/setup/sourcepkg.sh: line 31: unset: `BASH_FUNC_welcome_prompt_handle%%': not a valid identifier
/home/lap/var/bldr/gitsrc/common/environment/setup/sourcepkg.sh: line 31: unset: `BASH_FUNC_vimw%%': not a valid identifier
/home/lap/var/bldr/gitsrc/common/environment/setup/sourcepkg.sh: line 31: unset: `BASH_FUNC_directory_not_found_handle%%': not a valid identifier
/home/lap/var/bldr/gitsrc/common/environment/setup/sourcepkg.sh: line 31: unset: `BASH_FUNC_shell_prompt_handle%%': not a valid identifier
/home/lap/var/bldr/gitsrc/common/environment/setup/sourcepkg.sh: line 31: unset: `BASH_FUNC_gitw%%': not a valid identifier
/home/lap/var/bldr/gitsrc/common/environment/setup/sourcepkg.sh: line 31: unset: `BASH_FUNC_cdw%%': not a valid identifier
/home/lap/var/bldr/gitsrc/common/environment/setup/sourcepkg.sh: line 31: unset: `BASH_FUNC_command_not_found_handle%%': not a valid identifier
libarchive-3.6.2 -> libarchive-3.7.0

Reported at #45239

Please sign in to comment.