[pacman-dev] makepkg: package_...() can export variables to each other
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Hi, I stumbled upon the fact, that variables set in one package_...() function of a split package are accessible by following package_...() functions. Is this by design or may I try to provide a patch to restore env after the call to package_...()? Note: packaging-relevant variables (e.g. depends_x86_64) are cleaned across function calls. Simple example: - ------8<------8<------8<------ arch=(any) pkgbase=test pkgname=(ta tb) pkgver=0 pkgrel=1 package_ta() { _test='hi, there!' } package_tb() { echo "$_test" } - ------>8------>8------>8------ regards, Erich -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEE3p92iMrPBP64GmxZCu7JB1Xae1oFAl7Z9qsACgkQCu7JB1Xa e1pc+xAAtKJyAv0JgX0skAmVmMEit+q456ZwKJAL0Kxe8059RNrwzwHvpcvso183 Pc3eqSbxMIRbTGrA2dyweWX42uO8DJuq39LTYNyHQR6KPY7rtaoAMEq/ypF6prc9 EKfD8wq+E5P3i3Ti4YyS8kKfEYfPLvA6O99r/U4GI8GZiFwNoq8LwvKvMnXYxqS2 6oEviKxYFw8wXlYjcCOOTb6WzgNZVyXbpos3B1kx0yuDRW6qhqicVa0levnWUp+M wh8Cx4LXIwCJKLawaA3VzmGXnsbHQq6UatMKeT4z+OcFFHq80q19KJlR8mfP41mc 1Wt+PYwQm+6zyekzcuzz/b6CX0RHK/hEHJJgXGu1awxpzADAWAt3l0HvjGJ+zKiK qhpnbWykGVAwBCE6EwrQsOFAfL9vqzwz9c1tIycKEmbIUs+aFPMbSQVOynnolXGj m1wpbs58+HOHVMcA/ozzkOT1Of+rlLZQHfc87QQuCaJp419sXEPTzFVdNg7d/ok2 m/Z3KmARycCeEu9TpNLYCcR1/OeayBlHnbjhGaESsgiqenqap27CKRiy2TextYt6 56kiGxIj3EbZz7tE3oJE0eQbAeefFctU42O1nbiPpmUZMHdobJqzNtBxB45pKmYm 3YRQqgd+WzMdY583ifqK7dlooUeLkc61eX+AppJrAZ2UNaHAoP4= =q2Yz -----END PGP SIGNATURE-----
On 5/6/20 5:39 pm, Erich Eckner wrote:
Hi,
I stumbled upon the fact, that variables set in one package_...() function of a split package are accessible by following package_...() functions. Is this by design or may I try to provide a patch to restore env after the call to package_...()? Note: packaging-relevant variables (e.g. depends_x86_64) are cleaned across function calls.
Simple example:
------8<------8<------8<------ arch=(any) pkgbase=test pkgname=(ta tb) pkgver=0 pkgrel=1
package_ta() { _test='hi, there!' }
package_tb() { echo "$_test" } ------>8------>8------>8------
PKGBUILDs are bash. Bash scope rules apply. Allan
On 6/5/20 3:59 AM, Allan McRae wrote:
On 5/6/20 5:39 pm, Erich Eckner wrote:
Hi,
I stumbled upon the fact, that variables set in one package_...() function of a split package are accessible by following package_...() functions. Is this by design or may I try to provide a patch to restore env after the call to package_...()? Note: packaging-relevant variables (e.g. depends_x86_64) are cleaned across function calls.
Simple example:
------8<------8<------8<------ arch=(any) pkgbase=test pkgname=(ta tb) pkgver=0 pkgrel=1
package_ta() { _test='hi, there!' }
package_tb() { echo "$_test" } ------>8------>8------>8------
PKGBUILDs are bash. Bash scope rules apply.
... with the caveat that makepkg --nobuild && makepkg --noextract will run prepare() and build() in separate program invocations, so you cannot *depend* on variables being persisted. And all package_*() functions are run -- together -- under fakeroot in a separate bash process, so they are separated in scope from non-package_*() functions. The packaging-relevant variables are special, we reset them precisely because they're documented to only be local to the package that defines them. For all other variables, as Allan said it's your job to scope them as you wish. People usually declare them with the "local" builtin. -- Eli Schwartz Bug Wrangler and Trusted User
participants (3)
-
Allan McRae
-
Eli Schwartz
-
Erich Eckner