Gentoo Archives: gentoo-dev

From: Alistair Bush <ali_bush@g.o>
To: gentoo-dev@l.g.o
Cc: Donnie Berkholz <dberkholz@g.o>, gentoo-java@l.g.o
Subject: Re: [gentoo-dev] New eclass to support java-virtuals
Date: Thu, 20 Sep 2007 19:16:25
Message-Id: 46F2C2DB.3070504@gentoo.org
In Reply to: Re: [gentoo-dev] New eclass to support java-virtuals by Donnie Berkholz
1 Donnie Berkholz wrote:
2 > On 23:20 Thu 20 Sep , Alistair Bush wrote:
3 >> - # Create package.env
4 >> - (
5 >> - echo "DESCRIPTION=\"${DESCRIPTION}\""
6 >> - echo "GENERATION=\"2\""
7 >> -
8 >> - [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
9 >> - [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
10 >> - [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
11 >> - [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
12 >> - && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
13 >> - [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
14 >> - && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
15 >> - echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
16 >> - ) > "${JAVA_PKG_ENV}"
17 >
18 > Why not use a code block {} instead of a subshell ()?
19
20 You would have to ask the original author about that, but point taken.
21
22 >
23 >> - # register target/source
24 >> - local target="$(java-pkg_get-target)"
25 >> - local source="$(java-pkg_get-source)"
26 >> - [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
27 >> - [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
28 >> -
29 >> - # register javadoc info
30 >> - [[ -n ${JAVADOC_PATH} ]] && echo "JAVADOC_PATH=\"${JAVADOC_PATH}\"" \
31 >> - >> ${JAVA_PKG_ENV}
32 >> - # register source archives
33 >> - [[ -n ${JAVA_SOURCES} ]] && echo "JAVA_SOURCES=\"${JAVA_SOURCES}\"" \
34 >> - >> ${JAVA_PKG_ENV}
35 >> -
36 >> -
37 >> - echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
38 >> - [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
39 >
40 > I don't understand why all these things are done down here instead of in the
41 > same code block as $JAVA_PKG_ENV is created.
42
43 That to is also historical, and i'm less inclined to changed it. I've
44 already broken the tree once with a eclass change, breaking this would
45 completely break java support. It could be updated as part of our
46 general QA, but I believe that it should be done separately, and not
47 bundled in with the changes i've made.
48
49 >
50 >> - # Strip unnecessary leading and trailing colons
51 >> - # TODO try to cleanup if possible
52 >> - sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
53 >> +
54 >> + if [[ $1 != provider ]]; then
55 >
56 > Could you explain what the next section is supposed to do, as opposed to
57 > the above section? Are they expected to be mutually exclusive? The
58 > comments suggest so, since both have a 'Create package.env'. But the
59 > tests suggest otherwise, since it's not an if...else pair.
60
61 normally java-pkg_do_write_ is called to write the package.env out, as
62 can be seen, and is the default behavior for the function. What I am
63 adding is the ability to _do_write of a "[virtual|provider].env" file.
64 While at present it only contains 3 variables, I see no reason why
65 eventually it will not include other vars that are shared between the
66 package.env and "virtual.env" ( e.g DESCRIPTION )
67
68 Therefore this change can be summarized as
69
70 + if [[ $1 != provider ]]; then
71 #Do the default package.env behaviour
72 + else
73 + #Create a "virtual.env" file. This will only be invoked by
74 + #ebuilds that inherit java-virtuals.eclass
75 + fi
76
77 I could very well reflactor the java-pkg_do_write_ function back to its
78 current state and create a new function java-pkg_do_write_virtual to be
79 called by java-virtuals-2.eclass.
80
81 The documentation could (and will) be updated to more correctly reflect
82 whats happening.
83
84
85 >
86 >> + # Create directory for package.env
87 >> + dodir "${JAVA_PKG_SHAREPATH}"
88 >> + if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
89 >> + "${JAVA_PKG_DEPEND_FILE}" || -f \
90 >> + "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
91 >> + # Create package.env
92 >> + (
93 >> + echo "DESCRIPTION=\"${DESCRIPTION}\""
94 >> + echo "GENERATION=\"2\""
95 >> +
96 >> + [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
97 >> + [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
98 >> + [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
99 >> + [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
100 >> + && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
101 >> + [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
102 >> + && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
103 >> + echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
104 >> + ) > "${JAVA_PKG_ENV}"
105 >
106 > Thanks,
107 > Donnie
108 --
109 gentoo-dev@g.o mailing list

Replies

Subject Author
Re: [gentoo-dev] New eclass to support java-virtuals Donnie Berkholz <dberkholz@g.o>