Re: [gentoo-dev] [RFC] office-ext.eclass

2011-08-30 Thread Tomáš Chvátal

Dne 29.8.2011 21:24, Nathan Phillip Brink napsal(a):

On Mon, Aug 29, 2011 at 10:35:41AM +0200, Tom Chv??tal wrote:

How about this attachment? :)



# @FUNCTION: openoffice-ext_add_extension
# @DESCRIPTION:
# Install the extension into the office suite.
openoffice-ext_add_extension() {
debug-print-function ${FUNCNAME} $@
local ext=$1
local tmpdir=$(mktemp -d --tmpdir=${T})


Isn't it just as important to doublequote ${T} as it is to doublequote
${D}?


Good catch,
See the attachment for the latest version :)

Tom
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: office-ext.eclass
# @MAINTAINER:
# The office team openoff...@gentoo.org
# @BLURB: Eclass for installing libreoffice/openoffice extensions
# @DESCRIPTION:
# Eclass for easing maitenance of libreoffice/openoffice extensions.

case ${EAPI:-0} in
4) OEXT_EXPORTED_FUNCTIONS=src_install pkg_postinst pkg_prerm ;;
*) die EAPI=${EAPI} is not supported ;;
esac

EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
unset OEXT_EXPORTED_FUNCTIONS

inherit eutils multilib

UNOPKG_BINARY=${EPREFIX}/usr/bin/unopkg

# @ECLASS-VARIABLE: OO_EXTENSIONS
# @REQUIRED
# @DESCRIPTION:
# Array containing list of extensions to install.
[[ -z ${OO_EXTENSIONS} ]]  die OO_EXTENSIONS variable is unset.
if [[ $(declare -p OO_EXTENSIONS 2/dev/null 21) != declare -a* ]]; then
die OO_EXTENSIONS variable is not an array.
fi

DEPEND=virtual/ooo
RDEPEND=virtual/ooo

# @FUNCTION: office-ext_flush_unopkg_cache
# @DESCRIPTION:
# Flush the cache after removal of an extension.
office-ext_flush_unopkg_cache() {
debug-print-function ${FUNCNAME} $@

debug-print ${FUNCNAME}: ${UNOPKG_BINARY} list --shared  /dev/null
${UNOPKG_BINARY} list --shared  /dev/null
}

# @FUNCTION: office-ext_get_implementation
# @DESCRIPTION:
# Determine the implementation we are building against.
office-ext_get_implementation() {
debug-print-function ${FUNCNAME} $@
local implementations=(
libreoffice
openoffice
)
local i

for i in ${implementations[$@]}; do
if [[ -d ${EPREFIX}/usr/$(get_libdir)/${i} ]]; then
debug-print ${FUNCNAME}: Determined implementation is: 
\${EPREFIX}/usr/$(get_libdir)/${i}\
echo ${EPREFIX}/usr/$(get_libdir)/${i}
return
fi
done

die Unable not determine libreoffice/openoffice implementation!
}

# @FUNCTION: office-ext_add_extension
# @DESCRIPTION:
# Install the extension into the libreoffice/openoffice.
office-ext_add_extension() {
debug-print-function ${FUNCNAME} $@
local ext=$@
local tmpdir=$(mktemp -d --tmpdir=${T})

debug-print ${FUNCNAME}: ${UNOPKG_BINARY} add --shared \${ext}\
ebegin Adding extension: \${ext}\
${UNOPKG_BINARY} add --shared ${ext} \
-env:UserInstallation=file:///${tmpdir} \
-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1
eend $?
rm -rf ${tmpdir}
}

# @FUNCTION: office-ext_remove_extension
# @DESCRIPTION:
# Remove the extension from the libreoffice/openoffice.
office-ext_remove_extension() {
debug-print-function ${FUNCNAME} $@
local ext=$@
local tmpdir=$(mktemp -d --tmpdir=${T})

debug-print ${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \${ext}\
ebegin Removing extension: \${ext}\
${UNOPKG_BINARY} remove --shared ${ext} \
-env:UserInstallation=file:///${tmpdir} \
-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1
eend $?
flush_unopkg_cache
rm -rf ${tmpdir}
}

# @FUNCTION: office-ext_src_install
# @DESCRIPTION:
# Install the extension source to the proper location.
office-ext_src_install() {
debug-print-function ${FUNCNAME} $@
local i

# subshell to not polute rest of the env with the insinto redefinition
(
insinto 
$(openoffice-ext_get_implementation)/share/extension/install/
for i in ${OO_EXTENSIONS[$@]}; do
doins ${i}
done
)

einfo Remember that if you replace your office implementation,
einfo you need to recompile all the extensions.
einfo Your current implementation location is: 
einfo $(openoffice-ext_get_implementation)
}

# @FUNCTION: office-ext_pkg_postinst
# @DESCRIPTION:
# Add the extensions to the libreoffice/openoffice.
office-ext_pkg_postinst() {
debug-print-function ${FUNCNAME} $@
local i

for i in ${OO_EXTENSIONS[$@]}; do
openoffice-ext_add_extension ${i}
done

}

# @FUNCTION: office-ext_pkg_prerm
# @DESCRIPTION:
# Remove the extensions from the libreoffice/openoffice.
office-ext_pkg_prerm() {
debug-print-function ${FUNCNAME} $@
  

Re: [gentoo-dev] [RFC] office-ext.eclass

2011-08-30 Thread Ulrich Mueller
 On Tue, 30 Aug 2011, Tomáš Chvátal wrote:

 See the attachment for the latest version :)

 # @FUNCTION: office-ext_get_implementation
 [...]
   for i in ${implementations[$@]}; do

I think this should read ${implementations[@]} instead, if the
intention is to loop over all array elements.

 # @FUNCTION: office-ext_remove_extension
 [...]
   ${UNOPKG_BINARY} remove --shared ${ext} \

Not sure what unopkg accepts, but I guess you want to pass several
arguments here. So ${ext} shouldn't be quoted.

And why is the intermediate variable ext needed here, in the first
place? You could use $@ directly (this time, with the quotes).

 # @FUNCTION: office-ext_src_install
 [...]
   # subshell to not polute rest of the env with the insinto redefinition

s/polute/pollute/

   for i in ${OO_EXTENSIONS[$@]}; do

See above about $@.

 # @FUNCTION: office-ext_pkg_postinst
 [...]
   for i in ${OO_EXTENSIONS[$@]}; do

Ditto.

 # @FUNCTION: office-ext_pkg_prerm
 [...]
   for i in ${OO_EXTENSIONS[$@]}; do

Ditto.

Ulrich



[gentoo-dev] [RFC] check-reqs.eclass.patch

2011-08-30 Thread Tomáš Chvátal

Hi,
I got enough annoyed by check-reqs.eclass using epause and other nasty 
things so I updated it to do this things:


* eclassdoc
* use pkg_pretend and pkg_setup phases to run the checks
* warn if ebuild use deprecated calls and keep backompat
* remove duplicated/unused code
* support for metrics 1G 15T instead of requiring all values to be 
entered in megabytes.


Cheers

Tom
Index: check-reqs.eclass
===
RCS file: /var/cvsroot/gentoo-x86/eclass/check-reqs.eclass,v
retrieving revision 1.8
diff -u -b -B -r1.8 check-reqs.eclass
--- check-reqs.eclass	22 Aug 2011 04:46:31 -	1.8
+++ check-reqs.eclass	30 Aug 2011 06:56:43 -
@@ -4,8 +4,9 @@
 
 # @ECLASS: check-reqs.eclass
 # @MAINTAINER:
-# Bo Ørsted Andresen z...@gentoo.org
+# QA Team q...@gentoo.org
 # @AUTHOR:
+# Bo Ørsted Andresen z...@gentoo.org
 # Original Author: Ciaran McCreesh ciar...@gentoo.org
 # @BLURB: Provides a uniform way of handling ebuild which have very high build requirements
 # @DESCRIPTION:
@@ -13,49 +14,34 @@
 # build requirements in terms of memory or disk space. It provides a function
 # which should usually be called during pkg_setup().
 #
-# From a user perspective, the variable CHECKREQS_ACTION can be set to:
-#* warn (default), which will display a warning and wait for 15s
-#* error, which will make the ebuild error out
-#* ignore, which will not take any action
-#
 # The chosen action only happens when the system's resources are detected
 # correctly and only if they are below the threshold specified by the package.
 #
-# For ebuild authors: only use this eclass if you reaaally have stupidly
-# high build requirements. At an absolute minimum, you shouldn't be using this
-# unless the ebuild needs 256MBytes RAM or 1GByte temporary or install space.
-# The code should look something like:
-#
 # @CODE
-# pkg_setup() {
-# # values in MBytes
-#
 # # need this much memory (does *not* check swap)
-# CHECKREQS_MEMORY=256
+# CHECKREQS_MEMORY=256M
 #
 # # need this much temporary build space
-# CHECKREQS_DISK_BUILD=2048
+# CHECKREQS_DISK_BUILD=2G
 #
 # # install will need this much space in /usr
-# CHECKREQS_DISK_USR=1024
+# CHECKREQS_DISK_USR=1G
 #
 # # install will need this much space in /var
-# CHECKREQS_DISK_VAR=1024
+# CHECKREQS_DISK_VAR=1024M
 #
 # # go!
-# check_reqs
+# pkg_pretend() {
+#check-reqs_pkg_pretend
+# }
+# 
+# # Run once again to ensure that environment didn't
+# # change since the pretend phase.
+# pkg_setup() {
+#check-reqs_pkg_setup
 # }
 # @CODE
 #
-# Alternatively, the check_reqs_conditional function can be used to carry out
-# alternate actions (e.g. using a much slower but far less memory intensive
-# build option that gives the same end result).
-#
-# You should *not* override the user's CHECKREQS_ACTION setting, nor should you
-# attempt to provide a value if it is unset. Note that the environment variables
-# are used rather than parameters for a few reasons:
-#   * easier to do if use blah ; then things
-#   * we might add in additional requirements things later
 # If you don't specify a value for, say, CHECKREQS_MEMORY, then the test is not
 # carried out.
 #
@@ -66,80 +52,234 @@
 
 # @ECLASS-VARIABLE: CHECKREQS_MEMORY
 # @DESCRIPTION:
-# How much RAM is needed in MB?
+# @DEAULT_UNSET
+# How much RAM is needed?
 
 # @ECLASS-VARIABLE:  CHECKREQS_DISK_BUILD
 # @DESCRIPTION:
-# How much diskspace is needed to build the package? In MB
+# @DEAULT_UNSET
+# How much diskspace is needed to build the package?
 
 # @ECLASS-VARIABLE: CHECKREQS_DISK_USR
 # @DESCRIPTION:
-# How much space in /usr is needed to install the package? In MB
+# @DEAULT_UNSET
+# How much space in /usr is needed to install the package?
 
 # @ECLASS-VARIABLE: CHECKREQS_DISK_VAR
 # @DESCRIPTION:
-# How much space is needed in /var? In MB
+# @DEAULT_UNSET
+# How much space is needed in /var?
+
+CHECKREQS_EXPORTED_FUNCTIONS=pkg_setup
+case ${EAPI:-0} in
+	0|1|2|3) ;;
+	4) CHECKREQS_EXPORTED_FUNCTIONS=${EXPORTED_FUNCTIONS} pkg_pretend ;;
+	*) die EAPI=${EAPI} is not supported ;;
+esac
 
 # @FUNCTION: check_reqs
 # @DESCRIPTION:
-# Checks the requirements given in the specific variables. If not reached,
-# either prints a warning or dies.
+# Obsolete function executing all the checks and priting out results
 check_reqs() {
-	[[ -n ${1} ]]  die Usage: check_reqs
+	debug-print-function ${FUNCNAME} $@
+
+	echo
+	ewarn QA: Package calling old ${FUNCNAME} function.
+	ewarn QA: Please file a bug against the package.
+	ewarn QA: It should call check-reqs_pkg_pretend and check-reqs_pkg_setup
+	ewarn QA: and possibly use EAPI=4 or later.
+	echo
+
+	check-reqs_pkg_setup $@
+}
 
-	export CHECKREQS_NEED_SLEEP= CHECKREQS_NEED_DIE=
-	if [[ $CHECKREQS_ACTION != ignore ]] ; then
-		[[ -n $CHECKREQS_MEMORY ]]  check_build_memory
-		[[ -n $CHECKREQS_DISK_BUILD ]]  check_build_disk \
-			${T} ${CHECKREQS_DISK_BUILD}
-		[[ -n 

Re: [gentoo-dev] [RFC] office-ext.eclass

2011-08-30 Thread Tomáš Chvátal

Dne 30.8.2011 09:02, Ulrich Mueller napsal(a):

On Tue, 30 Aug 2011, Tomáš Chvátal wrote:



See the attachment for the latest version :)



# @FUNCTION: office-ext_get_implementation
[...]
for i in ${implementations[$@]}; do


I think this should read ${implementations[@]} instead, if the
intention is to loop over all array elements.



You are right hell of a copypasto :)



# @FUNCTION: office-ext_remove_extension
[...]
${UNOPKG_BINARY} remove --shared ${ext} \


Not sure what unopkg accepts, but I guess you want to pass several
arguments here. So ${ext} shouldn't be quoted.

And why is the intermediate variable ext needed here, in the first
place? You could use $@ directly (this time, with the quotes).

Nah i want to give it just one argument, the name of the extension and 
it can contain spaces - $@.


For what is worth i prefer to use local variables just because it is 
easier if I decide to change what i want to parse from $@ to something else.


Good question is if it handles the extension name with spaces or that it 
require quotes. As we don't have one with spaces for now I would rather 
keep the quotes and alter it only in future if we find out that it is 
not really required.



# @FUNCTION: office-ext_src_install
[...]
# subshell to not polute rest of the env with the insinto redefinition


s/polute/pollute/


for i in ${OO_EXTENSIONS[$@]}; do


See above about $@.


# @FUNCTION: office-ext_pkg_postinst
[...]
for i in ${OO_EXTENSIONS[$@]}; do


Ditto.


# @FUNCTION: office-ext_pkg_prerm
[...]
for i in ${OO_EXTENSIONS[$@]}; do


Ditto.



Addressed :)

Tom
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: office-ext.eclass
# @AUTHOR:
# Tomáš Chvátal scarab...@gentoo.org
# @MAINTAINER:
# The office team openoff...@gentoo.org
# @BLURB: Eclass for installing libreoffice/openoffice extensions
# @DESCRIPTION:
# Eclass for easing maitenance of libreoffice/openoffice extensions.

case ${EAPI:-0} in
4) OEXT_EXPORTED_FUNCTIONS=src_install pkg_postinst pkg_prerm ;;
*) die EAPI=${EAPI} is not supported ;;
esac

EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
unset OEXT_EXPORTED_FUNCTIONS

inherit eutils multilib

UNOPKG_BINARY=${EPREFIX}/usr/bin/unopkg

# @ECLASS-VARIABLE: OO_EXTENSIONS
# @REQUIRED
# @DESCRIPTION:
# Array containing list of extensions to install.
[[ -z ${OO_EXTENSIONS} ]]  die OO_EXTENSIONS variable is unset.
if [[ $(declare -p OO_EXTENSIONS 2/dev/null 21) != declare -a* ]]; then
die OO_EXTENSIONS variable is not an array.
fi

DEPEND=virtual/ooo
RDEPEND=virtual/ooo

# @FUNCTION: office-ext_flush_unopkg_cache
# @DESCRIPTION:
# Flush the cache after removal of an extension.
office-ext_flush_unopkg_cache() {
debug-print-function ${FUNCNAME} $@

debug-print ${FUNCNAME}: ${UNOPKG_BINARY} list --shared  /dev/null
${UNOPKG_BINARY} list --shared  /dev/null
}

# @FUNCTION: office-ext_get_implementation
# @DESCRIPTION:
# Determine the implementation we are building against.
office-ext_get_implementation() {
debug-print-function ${FUNCNAME} $@
local implementations=(
libreoffice
openoffice
)
local i

for i in ${implementations[@]}; do
if [[ -d ${EPREFIX}/usr/$(get_libdir)/${i} ]]; then
debug-print ${FUNCNAME}: Determined implementation is: 
\${EPREFIX}/usr/$(get_libdir)/${i}\
echo ${EPREFIX}/usr/$(get_libdir)/${i}
return
fi
done

die Unable not determine libreoffice/openoffice implementation!
}

# @FUNCTION: office-ext_add_extension
# @DESCRIPTION:
# Install the extension into the libreoffice/openoffice.
office-ext_add_extension() {
debug-print-function ${FUNCNAME} $@
local ext=$@
local tmpdir=$(mktemp -d --tmpdir=${T})

debug-print ${FUNCNAME}: ${UNOPKG_BINARY} add --shared \${ext}\
ebegin Adding extension: \${ext}\
${UNOPKG_BINARY} add --shared ${ext} \
-env:UserInstallation=file:///${tmpdir} \
-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1
eend $?
rm -rf ${tmpdir}
}

# @FUNCTION: office-ext_remove_extension
# @DESCRIPTION:
# Remove the extension from the libreoffice/openoffice.
office-ext_remove_extension() {
debug-print-function ${FUNCNAME} $@
local ext=$@
local tmpdir=$(mktemp -d --tmpdir=${T})

debug-print ${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \${ext}\
ebegin Removing extension: \${ext}\
${UNOPKG_BINARY} remove --shared ${ext} \
-env:UserInstallation=file:///${tmpdir} \
-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1
eend $?
flush_unopkg_cache
rm -rf ${tmpdir}
}

# @FUNCTION: office-ext_src_install
# @DESCRIPTION:
# Install 

Re: [gentoo-dev] [RFC] office-ext.eclass

2011-08-30 Thread Michał Górny
On Tue, 30 Aug 2011 09:26:16 +0200
Tomáš Chvátal scarab...@gentoo.org wrote:

  # @FUNCTION: office-ext_remove_extension
  [...]
 ${UNOPKG_BINARY} remove --shared ${ext} \
 
  Not sure what unopkg accepts, but I guess you want to pass several
  arguments here. So ${ext} shouldn't be quoted.
 
  And why is the intermediate variable ext needed here, in the first
  place? You could use $@ directly (this time, with the quotes).
 
 Nah i want to give it just one argument, the name of the extension
 and it can contain spaces - $@.

Then you are supposed to use ${1}, and caller is supposed to quote
that name.

Running things like 'foo bar baz' is a no go. If the file was named
'bar  baz' instead, it'd fail because of whitespace collapsing. So,
the only allowed solution is 'foo bar baz', and ${1}.

 For what is worth i prefer to use local variables just because it is 
 easier if I decide to change what i want to parse from $@ to
 something else.

BTW You can go with exts=( ${@} ) as well, to support multiple exts.

-- 
Best regards,
Michał Górny


signature.asc
Description: PGP signature


Re: [gentoo-dev] [RFC] check-reqs.eclass.patch

2011-08-30 Thread Tomáš Chvátal

Dne 30.8.2011 09:35, Michał Górny napsal(a):

On Tue, 30 Aug 2011 09:11:40 +0200
Tomáš Chvátalscarab...@gentoo.org  wrote:


@@ -66,80 +52,234 @@

  # @ECLASS-VARIABLE: CHECKREQS_MEMORY
  # @DESCRIPTION:
-# How much RAM is needed in MB?
+# @DEAULT_UNSET
+# How much RAM is needed?


Typo. Also, shouldn't defaults go before @DESCRIPTION: ?

Yeah sedding it failed :)



  # @ECLASS-VARIABLE:  CHECKREQS_DISK_BUILD
  # @DESCRIPTION:
-# How much diskspace is needed to build the package? In MB
+# @DEAULT_UNSET
+# How much diskspace is needed to build the package?


Ditto.


  # @ECLASS-VARIABLE: CHECKREQS_DISK_USR
  # @DESCRIPTION:
-# How much space in /usr is needed to install the package? In MB
+# @DEAULT_UNSET
+# How much space in /usr is needed to install the package?


Ditto.


  # @ECLASS-VARIABLE: CHECKREQS_DISK_VAR
  # @DESCRIPTION:
-# How much space is needed in /var? In MB
+# @DEAULT_UNSET
+# How much space is needed in /var?


Ditto.


+CHECKREQS_EXPORTED_FUNCTIONS=pkg_setup
+case ${EAPI:-0} in
+   0|1|2|3) ;;
+   4) CHECKREQS_EXPORTED_FUNCTIONS=${EXPORTED_FUNCTIONS}
pkg_pretend ;;


Not the same var.


+   *) die EAPI=${EAPI} is not supported ;;
+esac


CHECKREQS_EXPORTED_FUNCTIONS is not used anywhere.

Fixed.



  # @FUNCTION: check_reqs
  # @DESCRIPTION:
-# Checks the requirements given in the specific variables. If not
reached, -# either prints a warning or dies.
+# Obsolete function executing all the checks and priting out results
  check_reqs() {
-   [[ -n ${1} ]]  die Usage: check_reqs
+   debug-print-function ${FUNCNAME} $@
+
+   echo
+   ewarn QA: Package calling old ${FUNCNAME} function.
+   ewarn QA: Please file a bug against the package.
+   ewarn QA: It should call check-reqs_pkg_pretend and
check-reqs_pkg_setup
+   ewarn QA: and possibly use EAPI=4 or later.
+   echo
+
+   check-reqs_pkg_setup $@
+}

-   export CHECKREQS_NEED_SLEEP= CHECKREQS_NEED_DIE=
-   if [[ $CHECKREQS_ACTION != ignore ]] ; then
-   [[ -n $CHECKREQS_MEMORY ]]  check_build_memory
-   [[ -n $CHECKREQS_DISK_BUILD ]]  check_build_disk
\
-   ${T} ${CHECKREQS_DISK_BUILD}
-   [[ -n $CHECKREQS_DISK_USR ]]  check_build_disk \
-   ${ROOT}/usr ${CHECKREQS_DISK_USR}
-   [[ -n $CHECKREQS_DISK_VAR ]]  check_build_disk \
-   ${ROOT}/var ${CHECKREQS_DISK_VAR}
+# @FUNCTION: check-reqs_pkg_setup
+# @DESCRIPTION:
+# Exported function running the resources checks in pkg_setup phase.
+# It should be run in both phases to ensure condition changes between
+# pkg_pretend and pkg_setup won't affect the build.
+check-reqs_pkg_setup() {
+   debug-print-function ${FUNCNAME} $@
+
+   check-reqs_prepare
+   check-reqs_run
+   check-reqs_output
+}
+
+# @FUNCTION: check-reqs_pkg_pretend
+# @DESCRIPTION:
+# Exported function running the resources checks in pkg_pretend
phase. +check-reqs_pkg_pretend() {
+   debug-print-function ${FUNCNAME} $@
+
+   check-reqs_pkg_setup $@
+}
+
+# @FUNCTION: check-reqs_prepare
+# @DESCRIPTION:
+# Internal function that checks the variables that should be defined.
+check-reqs_prepare() {
+   debug-print-function ${FUNCNAME} $@
+
+   if [[ -z ${CHECKREQS_MEMORY}
+   -z ${CHECKREQS_DISK_BUILD}
+   -z ${CHECKREQS_DISK_USR}
+   -z ${CHECKREQS_DISK_VAR} ]]; then
+   eerror Set some check-reqs eclass variables if you
want to use it.
+   eerror If you are user and see this message fill a
bug against the package.
+   die ${FUNCNAME}: check-reqs eclass called but not
actualy used! fi
+}

-   if [[ -n ${CHECKREQS_NEED_SLEEP} ]] ; then
-   echo
-   ewarn Bad things may happen! You may abort the
build by pressing ctrl+c in
-   ewarn the next 15 seconds.
-   ewarn  
-   einfo To make this kind of warning a fatal error,
add a line to /etc/make.conf
-   einfo setting CHECKREQS_ACTION=\error\. To skip
build requirements checking,
-   einfo set CHECKREQS_ACTION=\ignore\.
-   epause 15
+# @FUNCTION: check-reqs_run
+# @DESCRIPTION:
+# Internal function that runs the check based on variable settings.
+check-reqs_run() {
+   debug-print-function ${FUNCNAME} $@
+
+   # some people are *censored*
+   unset CHECKREQS_FAILED
+
+   [[ -n ${CHECKREQS_MEMORY} ]]  \
+   check-reqs_memory \
+   ${CHECKREQS_MEMORY}
+
+   [[ -n ${CHECKREQS_DISK_BUILD} ]]  \
+   check-reqs_disk \
+   ${T} \
+   ${CHECKREQS_DISK_BUILD}


Why not WORKDIR?
I thought workdir is present later than $T plus it was used before and I 
just kept it.



+
+   [[ -n ${CHECKREQS_DISK_USR} ]]  \
+   check-reqs_disk \
+   ${EROOT}/usr \
+  

Re: [gentoo-dev] [RFC] office-ext.eclass

2011-08-30 Thread Tomáš Chvátal

Dne 30.8.2011 09:49, Michał Górny napsal(a):

On Tue, 30 Aug 2011 09:26:16 +0200
Tomáš Chvátalscarab...@gentoo.org  wrote:


# @FUNCTION: office-ext_remove_extension
[...]
${UNOPKG_BINARY} remove --shared ${ext} \


Not sure what unopkg accepts, but I guess you want to pass several
arguments here. So ${ext} shouldn't be quoted.

And why is the intermediate variable ext needed here, in the first
place? You could use $@ directly (this time, with the quotes).


Nah i want to give it just one argument, the name of the extension
and it can contain spaces -  $@.


Then you are supposed to use ${1}, and caller is supposed to quote
that name.

Running things like 'foo bar baz' is a no go. If the file was named
'bar  baz' instead, it'd fail because of whitespace collapsing. So,
the only allowed solution is 'foo bar baz', and ${1}.

Good point, lets keep it $1 :)



For what is worth i prefer to use local variables just because it is
easier if I decide to change what i want to parse from $@ to
something else.


BTW You can go with exts=( ${@} ) as well, to support multiple exts.



Nah too much arrays.
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: office-ext.eclass
# @AUTHOR:
# Tomáš Chvátal scarab...@gentoo.org
# @MAINTAINER:
# The office team openoff...@gentoo.org
# @BLURB: Eclass for installing libreoffice/openoffice extensions
# @DESCRIPTION:
# Eclass for easing maitenance of libreoffice/openoffice extensions.

case ${EAPI:-0} in
4) OEXT_EXPORTED_FUNCTIONS=src_install pkg_postinst pkg_prerm ;;
*) die EAPI=${EAPI} is not supported ;;
esac

EXPORT_FUNCTIONS ${OEXT_EXPORTED_FUNCTIONS}
unset OEXT_EXPORTED_FUNCTIONS

inherit eutils multilib

UNOPKG_BINARY=${EPREFIX}/usr/bin/unopkg

# @ECLASS-VARIABLE: OO_EXTENSIONS
# @REQUIRED
# @DESCRIPTION:
# Array containing list of extensions to install.
[[ -z ${OO_EXTENSIONS} ]]  die OO_EXTENSIONS variable is unset.
if [[ $(declare -p OO_EXTENSIONS 2/dev/null 21) != declare -a* ]]; then
die OO_EXTENSIONS variable is not an array.
fi

DEPEND=virtual/ooo
RDEPEND=virtual/ooo

# @FUNCTION: office-ext_flush_unopkg_cache
# @DESCRIPTION:
# Flush the cache after removal of an extension.
office-ext_flush_unopkg_cache() {
debug-print-function ${FUNCNAME} $@

debug-print ${FUNCNAME}: ${UNOPKG_BINARY} list --shared  /dev/null
${UNOPKG_BINARY} list --shared  /dev/null
}

# @FUNCTION: office-ext_get_implementation
# @DESCRIPTION:
# Determine the implementation we are building against.
office-ext_get_implementation() {
debug-print-function ${FUNCNAME} $@
local implementations=(
libreoffice
openoffice
)
local i

for i in ${implementations[@]}; do
if [[ -d ${EPREFIX}/usr/$(get_libdir)/${i} ]]; then
debug-print ${FUNCNAME}: Determined implementation is: 
\${EPREFIX}/usr/$(get_libdir)/${i}\
echo ${EPREFIX}/usr/$(get_libdir)/${i}
return
fi
done

die Unable not determine libreoffice/openoffice implementation!
}

# @FUNCTION: office-ext_add_extension
# @DESCRIPTION:
# Install the extension into the libreoffice/openoffice.
office-ext_add_extension() {
debug-print-function ${FUNCNAME} $@
local ext=$1
local tmpdir=$(mktemp -d --tmpdir=${T})

debug-print ${FUNCNAME}: ${UNOPKG_BINARY} add --shared \${ext}\
ebegin Adding extension: \${ext}\
${UNOPKG_BINARY} add --shared ${ext} \
-env:UserInstallation=file:///${tmpdir} \
-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1
eend $?
rm -rf ${tmpdir}
}

# @FUNCTION: office-ext_remove_extension
# @DESCRIPTION:
# Remove the extension from the libreoffice/openoffice.
office-ext_remove_extension() {
debug-print-function ${FUNCNAME} $@
local ext=$1
local tmpdir=$(mktemp -d --tmpdir=${T})

debug-print ${FUNCNAME}: ${UNOPKG_BINARY} remove --shared \${ext}\
ebegin Removing extension: \${ext}\
${UNOPKG_BINARY} remove --shared ${ext} \
-env:UserInstallation=file:///${tmpdir} \
-env:JFW_PLUGIN_DO_NOT_CHECK_ACCESSIBILITY=1
eend $?
flush_unopkg_cache
rm -rf ${tmpdir}
}

# @FUNCTION: office-ext_src_install
# @DESCRIPTION:
# Install the extension source to the proper location.
office-ext_src_install() {
debug-print-function ${FUNCNAME} $@
local i

# subshell to not pollute rest of the env with the insinto redefinition
(
insinto 
$(openoffice-ext_get_implementation)/share/extension/install/
for i in ${OO_EXTENSIONS[@]}; do
doins ${i}
done
)

einfo Remember that if you replace your office implementation,
einfo you need to recompile 

Re: [gentoo-dev] [RFC] check-reqs.eclass.patch

2011-08-30 Thread Ulrich Mueller
 On Tue, 30 Aug 2011, Tomáš Chvátal wrote:

 CHECKREQS_EXPORTED_FUNCTIONS=pkg_setup
 case ${EAPI:-0} in
   0|1|2|3) ;;
   4) CHECKREQS_EXPORTED_FUNCTIONS=${CHECKREQS_EXPORTED_FUNCTIONS} 
 pkg_pretend ;;
   *) die EAPI=${EAPI} is not supported ;;
 esac

 EXPORT_FUNCTIONS ${CHECKREQS_EXPORTED_FUNCTIONS}
 unset CHECKREQS_EXPORTED_FUNCTIONS

No need for a global variable here, the following works as well and is
easier to read:

EXPORT_FUNCTIONS pkg_setup
case ${EAPI:-0} in
0|1|2|3) ;;
4) EXPORT_FUNCTIONS pkg_pretend ;;
*) die EAPI=${EAPI} is not supported ;;
esac

Ulrich



Re: [gentoo-dev] [RFC] check-reqs.eclass.patch

2011-08-30 Thread Michał Górny
On Tue, 30 Aug 2011 10:04:50 +0200
Tomáš Chvátal scarab...@gentoo.org wrote:

  +  [[ -n ${CHECKREQS_DISK_BUILD} ]]  \
  +  check-reqs_disk \
  +  ${T} \
  +  ${CHECKREQS_DISK_BUILD}
 
  Why not WORKDIR?
 I thought workdir is present later than $T plus it was used before
 and I just kept it.

Ok, WORKDIR may not exist in pkg_setup()/pkg_pretend() indeed.

On the other hand, you should perform those checks only when building
sources and not when installing binpkg. Think about that.

  +
  +  [[ -n ${CHECKREQS_DISK_USR} ]]  \
  +  check-reqs_disk \
  +  ${EROOT}/usr \
  +  ${CHECKREQS_DISK_USR}
  +
  +  [[ -n ${CHECKREQS_DISK_VAR} ]]  \
  +  check-reqs_disk \
  +  ${EROOT}/var \
  +  ${CHECKREQS_DISK_VAR}
  +}
 
  Also, it may be a good idea to add some kind of generic var for
  this. Like:
 
  CHECKREQS_DISK_INSTALLED=( /usr 1234M /var 2345M )
 I dont think that syntax like this would be more readable than the 
 current one. Plus I preffer keeping backcompat the easy way

But it won't limit you to random dirs in the fs.

  +# @DESCRIPTION:
  +# Internal function that returns number in megabites.
  +# Converts from 1G=1024 or 1T=1048576
  +check-reqs_get_megs() {
  +  debug-print-function ${FUNCNAME} $@
  +
  +  [[ -z ${1} ]]  die Usage: ${FUNCNAME} [size]
  +
  +  local unit=${1//[[:digit:]]/}
  +  local size=${1//[[:alpha:]]/}
 
  Seems hacky and poor. What if one uses '1G234'? :P
 Yeah I will rather ignore it and just expect the users of the eclass
 are not complete asses.

Maybe you should simply use '#' and '%' like in clear shell
substitutions rather than running such a heavy substitutions?

Not to mention in your case basically getting the last char would
suffice.

  Start from scratch, write check-reqs-r1, make it SIMPLE.
 
 Won't create new function for simple usage like this.
 
 If you really consider this similar to python eclass you should look
 in that again, this is actually quite simple bash compared to it :)

Quite simple bash doesn't do regexps that much. And if someone uses
regexps that heavily, that means he misses a point.

-- 
Best regards,
Michał Górny


signature.asc
Description: PGP signature


[gentoo-dev] Re: [RFC] office-ext.eclass

2011-08-30 Thread Jonathan Callen
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Tomáš Chvátal wrote:
   die Unable not determine libreoffice/openoffice implementation!

Unable to determine ...

- -- 
Jonathan Callen
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.18 (GNU/Linux)

iQIcBAEBCgAGBQJOXW2uAAoJELHSF2kinlg4WgkQAI+qmxqmKVcz0Ay3Ldj7XZgv
pzsaWElCK+UBSTvdky9bXdyZmR1aGJ9EBnQ7QW2QWK7MpZRpZmyOoaxusgu0Jt72
+otMI/Jo6L9v15vEM8WpOGfTXjN3YW0FEKNIvtRSVQamvtB3Va6xKdbRJDC69Qiz
1x1KAVKoIV7owzCuo+yEjkyp8UXhkyrZfTVrOhKnvAmjK1n+8jw5g7fzRzVTaSfg
RSGG3bFWAlkfBrzaLToFN9DRWVXUhlDC00mjbhnsMmr1y6oKmagKdxsWsa7NpJn5
2mElUeW5vm8wYJJGikQZC2n69KMz6DApt9bu2nqni7G64K1N9S3VnhfkIhkf1JaV
GjdtlQxw9imJNzFfZhNIJkUmDJ8xmiqroVWi3bkTar6ySQC6wMjgutMYSc3KF7RF
ep89WflYgH8woAmvsYKdfZF9B9v1v2cFHp4Ra2fdryE9tYYlLy0KHG+kUmAoRcDv
CQ9vuxc63aD6ezc5qK8b2pvEH/C2OpYmQSby1im3/CIyoFfPTNf/S5iKq2W+jS8g
cP8/XFRynoYzdSbFIddU3fqc1uCfpv/AawNzRDhKegIU/j8Kt8FDDzNHnouriS7b
iPoZgMCz4OhQflWBTUxShLbYGAPUoX+v811AeWy+y6ViYMukdbmOsA8HMkfx6gmN
3j59tZmDp0b7pEKf63XV
=9bkW
-END PGP SIGNATURE-