Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-pms
Navigation:
Lists: gentoo-pms: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: Ulrich Mueller <ulm@g.o>
From: Brian Harring <ferringb@...>
Subject: Re: License for code snippets included in PMS
Date: Sun, 13 Mar 2011 09:40:36 -0700
On Sun, Mar 13, 2011 at 03:10:55PM +0100, Ulrich Mueller wrote:
> >>>>> On Sun, 13 Mar 2011, Petteri Räty wrote:
> 
> >>> Could we put all code snippets under some unrestrictive license
> >>> please? Like CC0-1.0-Universal?
> 
> > To be on the safe side I think we should get permission from
> > everyone who has worked on the code snippets before applying this
> > patch.
> 
> Here's the complete list from git history:
>    env-saving.listing (21 lines):
>       Ciaran McCreesh

This section wasn't accurate, as such I threw it out- attached is a 
brain dump of exactly what characteristics can be relied on for
env saving, and should be reasonably complete.

Could stand to have some comments added though.

As for license, CC0-1.0-universal/public domain/whatever floats your 
boat.

~harring
From a02ba65376e463818aa3d7abc2f845bd5ca745ff Mon Sep 17 00:00:00 2001
From: Brian Harring <ferringb@...>
Date: Sun, 13 Mar 2011 09:09:43 -0700
Subject: [PATCH] correct env-saving.listing to be accurate/complete

Version that was in place wasn't particularly accurate nor complete.
As such, and to cover copyright/licensing concerns, a from-scratch
version was written covering array behaviours, functions, unset behaviour,
and exports.

Signed-off-by: Brian Harring <ferringb@...>
---
 env-saving.listing |   84 +++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 64 insertions(+), 20 deletions(-)

diff --git a/env-saving.listing b/env-saving.listing
index 1650aa7..4391553 100644
--- a/env-saving.listing
+++ b/env-saving.listing
@@ -1,27 +1,71 @@
-GLOBAL_VARIABLE="a"
-
-src_compile()
-{
-    GLOBAL_VARIABLE="b"
-    DEFAULT_VARIABLE="c"
-    export EXPORTED_VARIABLE="d"
-    local LOCAL_VARIABLE="e"
+GLOBAL_SCOPE_VARIABLE="initial"
+VAR_TO_WIPE=initial
+declare -a ARRAY_VARIABLE=( a b )
+
+my_function() {
+	echo "exists"
+}
+
+src_compile() {
+	[[ ${GLOBAL_SCOPE_VARIABLE} == initial ]] || \
+		die "GLOBAL_SCOPE_VARIABLE must be preserved"
+
+	export GLOBAL_SCOPE_VARIABLE=set_twice
+
+	[[ ${VAR_TO_WIPE} == initial ]] || \
+		die "VAR_TO_WIPE must be preserved"
+
+	# now we wipe the var, to ensure that the env saving doesn't preserve it.
+	unset VAR_TO_WIPE
+
+	local LOCAL_SCOPE_VARIABLE=unseen
+
+	DEFAULT_SCOPE_VARIABLE=set
+
+	{ [[ ${#ARRAY_VARIABLE[@]} == 2 ]] && \
+		[[ ${ARRAY_VARIABLE[0]} == a ]] &&  \
+		[[ ${ARRAY_VARIABLE[1]} == b ]]; \
+	} || \
+		die "ARRAY_VARIABLE contents must be preserved exactly, and accessible"
+	ARRAY_VARIABLE[2]=c
+
+	[[ $(my_function 2> /dev/null) == exists ]] || \
+		die "'my_function' must be preserved"
 }
 
-src_install(){
-    [[ ${GLOBAL_VARIABLE} == "a" ]] \
-        || [[ ${GLOBAL_VARIABLE} == "b" ]] \
-        || die "broken env saving for globals"
 
-    [[ ${DEFAULT_VARIABLE} == "c" ]] \
-        || die "broken env saving for default"
+src_install() {
+	[[ ${GLOBAL_SCOPE_VARIABLE} == set_twice ]] || \
+		die "GLOBAL_SCOPE_VARIABLE modifications in src_compile must be preserved"
+
+	[[ -n $(declare -xp GLOBAL_SCOPE_VARIABLE 2> /dev/null) ]] || \
+		die "GLOBAL_SCOPE_VARIABLE must be exported due to src_compile exporting it"
+
+	[[ ${LOCAL_SCOPE_VARIABLE-unset} == unset ]] || \
+		die "a local defined variable should be impossible to propagate"
+
+	[[ ${VAR_TO_WIPE-unset} == unset ]] || \
+		die "VAR_TO_WIPE was unset during src_compile; this wiping must be preserved"
+
+	[[ ${DEFAULT_SCOPE_VARIABLE} == set ]] || \
+		die "DEFAULT_SCOPE_VARIABLE must be preserved"
+
+	[[ -n $(declare -xp DEFAULT_SCOPE_VARIABLE 2> /dev/null) ]] || \
+		die "DEFAULT_SCOPE_VARIABLE wasn't exported; environment saving must be preserved that fact."
+
+	[[ ${ARRAY_VARIABLE-unset} != unset ]] || \
+		die "ARRAY_VARIABLE must be preserved"
 
-    [[ ${EXPORTED_VARIABLE} == "d" ]] \
-        || die "broken env saving for exported"
+	[[ -n $(declare -ap ARRAY_VARIABLE 2> /dev/null) ]] || \
+		die "ARRAY_VARIABLE created during src_compile, must have it's array type preserved"
 
-    [[ $(printenv EXPORTED_VARIABLE ) == "d" ]] \
-        || die "broken env saving for exported"
+	{ [[ ${#ARRAY_VARIABLE[@]} == 3 ]] && \
+		[[ ${ARRAY_VARIABLE[0]} == a ]] &&  \
+		[[ ${ARRAY_VARIABLE[1]} == b ]]; \
+		[[ ${ARRAY_VARIABLE[2]} == c ]]; \
+	} || \
+		die "ARRAY_VARIABLE contents must be preserved exactly"
 
-    [[ -z ${LOCAL_VARIABLE} ]] \
-        || die "broken env saving for locals"
+	[[ $(my_function 2> /dev/null) == exists ]] || \
+		die "'my_function' must be preserved"
 }
-- 
1.7.4

Attachment:
pgpojxfA2fw5r.pgp (PGP signature)
Replies:
Re: License for code snippets included in PMS
-- David Leverton
References:
License for code snippets included in PMS
-- Ulrich Mueller
Re: License for code snippets included in PMS
-- Ulrich Mueller
Re: License for code snippets included in PMS
-- Petteri Räty
Re: License for code snippets included in PMS
-- Ulrich Mueller
Navigation:
Lists: gentoo-pms: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
Re: License for code snippets included in PMS
Next by thread:
Re: License for code snippets included in PMS
Previous by date:
Re: License for code snippets included in PMS
Next by date:
Re: License for code snippets included in PMS


Updated Jul 18, 2012

Summary: Archive of the gentoo-pms mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.