public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-x86 commit in app-admin/zprod-manager/files/0.3.2: zprod-manager
@ 2008-05-06 21:53 Alfredo Tupone (tupone)
  0 siblings, 0 replies; 3+ messages in thread
From: Alfredo Tupone (tupone) @ 2008-05-06 21:53 UTC (permalink / raw
  To: gentoo-commits

tupone      08/05/06 21:53:47

  Added:                zprod-manager
  Log:
  New version. Bug #220311 by me
  (Portage version: 2.1.4.4)
   (Signed Manifest commit)

Revision  Changes    Path
1.1                  app-admin/zprod-manager/files/0.3.2/zprod-manager

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/zprod-manager/files/0.3.2/zprod-manager?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/zprod-manager/files/0.3.2/zprod-manager?rev=1.1&content-type=text/plain

Index: zprod-manager
===================================================================
#!/bin/bash
# Gentoo Zope Product selection tool.
# Copyright 2003 Jason Shoemaker <kutsuya@gentoo.org>
# Distributed under GPL v2
# $Header: /var/cvsroot/gentoo-x86/app-admin/zprod-manager/files/0.3.2/zprod-manager,v 1.1 2008/05/06 21:53:47 tupone Exp $

VERSION="0.3.1"
COMMAND_LIST="add del"
ZS_DIR="/usr/share/zope/"
ZI_DIR="/var/lib/zope/"
ZPROD_DIR="/usr/share/zproduct/"

ZINST_DEFAULT=".default"
ZPROD_FLIST_FNAME=".zfolder.lst" 
ZPROD_LLIST_FNAME=".zlfolder.lst" 
ZPROD_PLIST_FNAME=".zproduct.lst"

# Assume the standard dialog return codes
#DIALOG_CANCEL=1
#DIALOG_ERROR=-1
#DIALOG_ESC=-255
#DIALOG_OK=0
#DIALOG_ERROR may equal #DIALOG_ESC

# Return codes used in this program:
E_SUCCESS=0
E_FAILURE=1

E_ZPLIST=20
E_ZILIST=22
E_COMMAND=24
E_OVERWRITE=26

## copied from zope-config

zinst_dir_get()
{
    local RESULT=${E_FAILURE}
    local LIST=$(ls ${ZI_DIR})
    local LIST_CNT=$(echo ${LIST} | wc -w)
    local DLIST=

    if [ ${LIST_CNT} -eq 1 ] ; then
	ZINST_DIR=${LIST}
	RESULT=${E_SUCCESS}
    elif [ ${LIST_CNT} -ne 0 ] ; then 
	for N in ${LIST} ; do
	    DLIST="${DLIST} $N -"
	done
	ZINST_DIR=$(dialog --stdout \
	    --title "Zope Instance List" \
	    --menu "Select desired zinstance:" 0 0 ${LIST_CNT} ${DLIST})
	RESULT=$?
    else
	RESULT=${E_ZILIST}   # There are no zinstances
    fi
    ZINST_DIR="${ZI_DIR}${ZINST_DIR}"
    return ${RESULT}
}

# params: none
# TODO: Maybe try to break this function down some more.
# TODO: verify items in ZP_PLIST and ZI_PLIST

mode_interactive()
{
    local RESULT=
    if [ $(is_command "${COMMAND_LIST}" ${1})${?} -ne 0 ] ; then
        RESULT=${?}
        return ${RESULT}
    fi
    ZP_PLIST=$(ls ${ZPROD_DIR})
    if [ "${ZP_PLIST}" ] ; then
	zinst_dir_get
	RESULT=$?
	if [ ${RESULT} -eq 0 ] ; then
	    ZI_PLIST=$(cat ${ZINST_DIR}/${ZPROD_PLIST_FNAME})
	    # Create CLIST for --menu
	    if [ "${ZI_PLIST}" ] ; then
		for N in ${ZP_PLIST} ; do
		    echo ${ZI_PLIST} |grep ${N} >/dev/null
		    if [ $? -eq 0 ] ; then
			STATUS=ON
		    else
			STATUS=OFF
		    fi
		    CLIST="${CLIST} ${N} - ${STATUS}"
		done
		CTAGS=$(dialog --stdout \
		    --backtitle "Select the zproducts you want installed for zinstance(${ZINST_DIR})." \
		    --checklist "Select:" 0 0 0 ${CLIST})
		RESULT=$?
		CTAGS=$(echo ${CTAGS} | sed -e "s:\"::g")
		# Prepare to add and delete zproducts installed in zinstance
		if [[ ${RESULT} -eq 0 && "${CTAGS}" ]] ; then   
		    for N in ${ZI_PLIST} ; do
			echo "$CTAGS" |grep ${N} >/dev/null
			if [ $? -ne 0 ] ; then
			    prod_del ${ZPROD_DIR}/${N} ${ZINST_DIR}
			fi
		    done
		    for N in ${CTAGS} ; do
			echo ${ZI_PLIST} |grep ${N} >/dev/null
			if [ $? -ne 0 ] ; then
			    prod_add ${ZPROD_DIR}/${N} ${ZINST_DIR}
			fi
		    done
		    RESULT=$?
		elif [ ${RESULT} -eq 0 ] ; then  # $CTAGS is empty
		    for N in ${ZI_PLIST} ; do
			prod_del ${ZPROD_DIR}/${N} ${ZINST_DIR}
		    done
		    RESULT=$?
		fi
	    else     # ZI_PLIST is empty
		for N in ${ZP_PLIST} ; do
		    CLIST="${CLIST} ${N} - 0"
		done
		CTAGS=$(dialog --stdout \
		    --backtitle "Select the zproducts you want installed for zinstance(${ZINST_DIR})." \
		    --checklist "Select:" 0 0 0 ${CLIST})
		RESULT=$?
		CTAGS=$(echo "${CTAGS}" | sed -e "s:\"::g")
		if [[ ${RESULT} -eq 0 && "${CTAGS}" ]] ; then 
		    for N in ${CTAGS} ; do
                        # as this is empty Products directory in instance if-case, we can safely ignore
                        # RESULT returned from prod_add in case of overwrite error. It can not happen
                        # when ZI_PLIST is empty, right? ;) <radek@gentoo.org>
			prod_add ${ZPROD_DIR}/${N} ${ZINST_DIR}
		    done
		fi
	    fi
	fi
    else    # ZP_PLIST is empty
	RESULT=${E_ZPLIST}
    fi
    return ${RESULT}
}


# Parameters:
#    $1 = command list
#    $2 = command received
# Returns: 
#    true or false

is_command()
{
    local RESULT=${E_COMMAND}
    local N=
   
    echo ${1} |grep ${2} >/dev/null
    if [ $? -eq 0 ] ; then 
	RESULT=0
    fi

    return ${RESULT}
}

# Parameters:
#    $1 = /path/to/zinstance
# Returns: 
#    true or false  

is_zinstanceDir()
{
    local RESULT=${E_ZILIST}
    # If can't find these, probably not a zinstance.
    if [[ -d "${1}/Products" && -d "${1}/var" && -d "${1}/import" && -d "${1}/Extensions" ]] ; then
	RESULT=0
    fi
    return ${RESULT}
}

# Parameters:
#    $1 = /path/to/zproduct
# Returns: 
#    true or false 

is_zproductDir()
{
    local RESULT=${E_ZPLIST}
    # look for something in .zproduct.lst in $1, if we can't find that...
    if [ -s "${1}/${ZPROD_FLIST_FNAME}" ] ; then
	RESULT=0
    fi
    return ${RESULT}
}

# Parameters:
#    $1 = /path/to/zinst_dir
# Returns: 
#    stdout = name of defautl zinstance, if any.   

zinst_default_get()
{
    if [ -s ${1}/${ZINST_DEFAULT} ] ; then
	cat ${1}/${ZINST_DEFAULT}
    fi
}

# Parameters:
#    $1 = /path/to/zproduct
#    $2 = /path/to/zinstance

# be warned, using this function you have to immediately fail if functionss returns error.

prod_add()
{
    local RESULT=
    local  N=

    # checks if some products components are already installed,
    # if yes, we have to break with error, as overwrites are DANGEROUS!
    for N in $(cat "${1}/${ZPROD_FLIST_FNAME}")
    do
        if [ -d ${2}/Products/${N} ]
        then
            echo "ZPROD-MANAGER WARNING: Overwrite possiblity detected at ${N}"
            return ${E_OVERWRITE}
        fi
    done
    for N in $(cat "${1}/${ZPROD_LLIST_FNAME}")
    do
        if [ -d ${2}/lib/python/${N} ]
        then
            echo "ZPROD-MANAGER WARNING: Overwrite possiblity detected at ${N}"
            return ${E_OVERWRITE}
        fi
    done

    if [ -e ${1}/Products ] ; then
    	for N in $(cat "${1}/${ZPROD_FLIST_FNAME}") ; do
            # we do copy instead of link, because its much safer, and zope-development-way compliant
	    cp -Ra ${1}/Products/${N} ${2}/Products
    	done
    else
    	for N in $(cat "${1}/${ZPROD_FLIST_FNAME}") ; do
            # we do copy instead of link, because its much safer, and zope-development-way compliant
	    cp -Ra ${1}/${N} ${2}/Products
    	done
    fi
    for N in $(cat "${1}/${ZPROD_LLIST_FNAME}") ; do
        # we do copy instead of link, because its much safer, and zope-development-way compliant
	cp -Ra ${1}/lib/python/${N} ${2}/lib/python
    done
    RESULT=$?
    if [ ${RESULT} -eq 0 ] ; then
	# basically adding ${PF} to .zproduct.lst
	echo $(basename $1) >> ${2}/${ZPROD_PLIST_FNAME}
	sort -u ${2}/${ZPROD_PLIST_FNAME} > ${2}/.tmp 
	mv -f ${2}/.tmp ${2}/${ZPROD_PLIST_FNAME}
	RESULT=$?
    
        for N in $(cat "${1}/${ZPROD_FLIST_FNAME}") ; do
            # setting owner and group as in Products folder, so we can compile
            # python scripts with the zope user
        
            chown -R  `stat -c %U:%G ${2}/Products` ${2}/Products/${N}

            # gives group writing perms (very often need in development teams)
            # takes all perms from others to comply with 770 instance policy
            chmod -R g+rwX,o-rwx ${2}/Products/${N}
        done
        for N in $(cat "${1}/${ZPROD_LLIST_FNAME}") ; do
            # setting owner and group as in Products folder, so we can compile
            # python scripts with the zope user
        
            chown -R  `stat -c %U:%G ${2}/Products` ${2}/lib/python/${N}

            # gives group writing perms (very often need in development teams)
            # takes all perms from others to comply with 770 instance policy
            chmod -R g+rwX,o-rwx ${2}/lib/python/${N}
        done
    fi

    return ${RESULT}
}

# Parameters:
#    $1 = /path/to/zproduct
#    $2 = /path/to/zinstance

prod_del()
{
    local RESULT=
    local N=
    local PF=$(basename $1)
    
    grep "${PF}" "${2}/${ZPROD_PLIST_FNAME}" >/dev/null
    RESULT=$?
    if [ ${RESULT} -eq 0 ] ; then
	for N in $(cat ${1}/${ZPROD_FLIST_FNAME}) ; do
	    rm -rf ${2}/Products/${N}
    	done
	for N in $(cat ${1}/${ZPROD_LLIST_FNAME}) ; do
	    rm -rf ${2}/lib/python/${N}
    	done
	# remove zproduct from .zproduct.lst
	sed -i -e "s/${PF}$//" -e "/^$/d" ${2}/${ZPROD_PLIST_FNAME}
	RESULT=$?
    fi	
    return ${RESULT}
}

# Parameters:
#    $1 = (optional) error message

mode_help()
{
    echo "$(basename $0) version ${VERSION}"
    echo "A Gentoo Zope Product selection tool."
    echo
    echo "Interactive usage:"
    echo -e "\t$(basename $0) [add | del]"
    echo "Default zinstance usage:"
    echo -e "\t$(basename $0) [add |del] /path/of/zproduct"
    echo "Non-interactive usage:"
    echo -e "\t$(basename $0) [add | del] /path/of/zproduct /path/of/zinstance/"
}

# Parameters:
#    $1 = command
#    $2 = /path/to/zproductDir

mode_defaultZinst()
{
    local DEFAULT_ZINST=$(zinst_default_get ${ZI_DIR})
    local RESULT=$?
    if [ -n "${DEFAULT_ZINST}" ] ; then
	mode_explicit ${1} ${2} ${ZI_DIR}/${DEFAULT_ZINST}
	RESULT=${?}
    fi
    return ${RESULT}
}
 
# Parameters:
#    $1 = command
#    $2 = /path/to/zproduct
#    $3 = /path/to/zinstance

mode_explicit()
{
    local RESULT=
    if [[ $(is_command "${COMMAND_LIST}" ${1})${?} -eq 0 && \
	$(is_zproductDir ${2})${?} -eq 0 && \
	$(is_zinstanceDir ${3})${?} -eq 0 ]] ; then
	if [ ${1} = "add" ] ; then
	    prod_add ${2} ${3}
	    RESULT=$?
	elif [ ${1} = "del" ] ; then
	    prod_del ${2} ${3}
	    RESULT=$?
	else
	    RESULT=${E_COMMAND}
	fi
    fi
    return ${RESULT}
}

### MAIN

if [ ${!#} = "--help" ] ; then
    mode_help
else
    case "${#}" in
        0) mode_help ;;
        1) mode_interactive ${1} ;;
        2) mode_defaultZinst ${1} ${2} ;;
        3) mode_explicit ${1} ${2} ${3} ;;
        *) mode_help "Error: Too many parameters" ;;
    esac
fi

RESULT=$?

if [ ${RESULT} -ne 0 ] ; then
    echo "ERROR ${?}"
fi


# vim:ts=8



-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [gentoo-commits] gentoo-x86 commit in app-admin/zprod-manager/files/0.3.2: zprod-manager
@ 2008-05-24 20:46 Alfredo Tupone (tupone)
  0 siblings, 0 replies; 3+ messages in thread
From: Alfredo Tupone (tupone) @ 2008-05-24 20:46 UTC (permalink / raw
  To: gentoo-commits

tupone      08/05/24 20:46:27

  Modified:             zprod-manager
  Log:
  Removing unused files. Removed warning when product does not use lib/python
  (Portage version: 2.1.4.4)

Revision  Changes    Path
1.2                  app-admin/zprod-manager/files/0.3.2/zprod-manager

file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/zprod-manager/files/0.3.2/zprod-manager?rev=1.2&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/zprod-manager/files/0.3.2/zprod-manager?rev=1.2&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/zprod-manager/files/0.3.2/zprod-manager?r1=1.1&r2=1.2

Index: zprod-manager
===================================================================
RCS file: /var/cvsroot/gentoo-x86/app-admin/zprod-manager/files/0.3.2/zprod-manager,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- zprod-manager	6 May 2008 21:53:47 -0000	1.1
+++ zprod-manager	24 May 2008 20:46:27 -0000	1.2
@@ -2,7 +2,7 @@
 # Gentoo Zope Product selection tool.
 # Copyright 2003 Jason Shoemaker <kutsuya@gentoo.org>
 # Distributed under GPL v2
-# $Header: /var/cvsroot/gentoo-x86/app-admin/zprod-manager/files/0.3.2/zprod-manager,v 1.1 2008/05/06 21:53:47 tupone Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-admin/zprod-manager/files/0.3.2/zprod-manager,v 1.2 2008/05/24 20:46:27 tupone Exp $
 
 VERSION="0.3.1"
 COMMAND_LIST="add del"
@@ -220,30 +220,31 @@
             return ${E_OVERWRITE}
         fi
     done
-    for N in $(cat "${1}/${ZPROD_LLIST_FNAME}")
-    do
-        if [ -d ${2}/lib/python/${N} ]
-        then
-            echo "ZPROD-MANAGER WARNING: Overwrite possiblity detected at ${N}"
-            return ${E_OVERWRITE}
-        fi
-    done
+    if [ -f "${1}/${ZPROD_LLIST_FNAME}" ]; then
+    	for N in $(cat "${1}/${ZPROD_LLIST_FNAME}"); do
+	    if [ -d ${2}/lib/python/${N} ]; then
+	    	echo "ZPROD-MANAGER WARNING: Overwrite detected at ${N}"
+		return ${E_OVERWRITE}
+	    fi
+	done
+    fi
 
+     # we do copy instead of link, because its much safer,
+     # and zope-development-way compliant
     if [ -e ${1}/Products ] ; then
     	for N in $(cat "${1}/${ZPROD_FLIST_FNAME}") ; do
-            # we do copy instead of link, because its much safer, and zope-development-way compliant
 	    cp -Ra ${1}/Products/${N} ${2}/Products
     	done
     else
     	for N in $(cat "${1}/${ZPROD_FLIST_FNAME}") ; do
-            # we do copy instead of link, because its much safer, and zope-development-way compliant
 	    cp -Ra ${1}/${N} ${2}/Products
     	done
     fi
-    for N in $(cat "${1}/${ZPROD_LLIST_FNAME}") ; do
-        # we do copy instead of link, because its much safer, and zope-development-way compliant
-	cp -Ra ${1}/lib/python/${N} ${2}/lib/python
-    done
+    if [ -f "${1}/${ZPROD_LLIST_FNAME}" ]; then
+    	for N in $(cat "${1}/${ZPROD_LLIST_FNAME}") ; do
+	    cp -Ra ${1}/lib/python/${N} ${2}/lib/python
+    	done
+    fi
     RESULT=$?
     if [ ${RESULT} -eq 0 ] ; then
 	# basically adding ${PF} to .zproduct.lst
@@ -252,26 +253,20 @@
 	mv -f ${2}/.tmp ${2}/${ZPROD_PLIST_FNAME}
 	RESULT=$?
     
+        # setting owner and group as in Products folder, so we can compile
+        # python scripts with the zope user
+        # gives group writing perms (very often need in development teams)
+        # takes all perms from others to comply with 770 instance policy
         for N in $(cat "${1}/${ZPROD_FLIST_FNAME}") ; do
-            # setting owner and group as in Products folder, so we can compile
-            # python scripts with the zope user
-        
             chown -R  `stat -c %U:%G ${2}/Products` ${2}/Products/${N}
-
-            # gives group writing perms (very often need in development teams)
-            # takes all perms from others to comply with 770 instance policy
             chmod -R g+rwX,o-rwx ${2}/Products/${N}
         done
-        for N in $(cat "${1}/${ZPROD_LLIST_FNAME}") ; do
-            # setting owner and group as in Products folder, so we can compile
-            # python scripts with the zope user
-        
-            chown -R  `stat -c %U:%G ${2}/Products` ${2}/lib/python/${N}
-
-            # gives group writing perms (very often need in development teams)
-            # takes all perms from others to comply with 770 instance policy
-            chmod -R g+rwX,o-rwx ${2}/lib/python/${N}
-        done
+    	if [ -f "${1}/${ZPROD_LLIST_FNAME}" ]; then
+            for N in $(cat "${1}/${ZPROD_LLIST_FNAME}") ; do
+            	chown -R  `stat -c %U:%G ${2}/Products` ${2}/lib/python/${N}
+            	chmod -R g+rwX,o-rwx ${2}/lib/python/${N}
+            done
+	fi
     fi
 
     return ${RESULT}
@@ -293,9 +288,11 @@
 	for N in $(cat ${1}/${ZPROD_FLIST_FNAME}) ; do
 	    rm -rf ${2}/Products/${N}
     	done
-	for N in $(cat ${1}/${ZPROD_LLIST_FNAME}) ; do
-	    rm -rf ${2}/lib/python/${N}
-    	done
+    	if [ -f "${1}/${ZPROD_LLIST_FNAME}" ]; then
+	    for N in $(cat ${1}/${ZPROD_LLIST_FNAME}) ; do
+	    	rm -rf ${2}/lib/python/${N}
+    	    done
+	fi
 	# remove zproduct from .zproduct.lst
 	sed -i -e "s/${PF}$//" -e "/^$/d" ${2}/${ZPROD_PLIST_FNAME}
 	RESULT=$?



-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [gentoo-commits] gentoo-x86 commit in app-admin/zprod-manager/files/0.3.2: zprod-manager
@ 2012-03-01 15:07 Patrick Lauer (patrick)
  0 siblings, 0 replies; 3+ messages in thread
From: Patrick Lauer (patrick) @ 2012-03-01 15:07 UTC (permalink / raw
  To: gentoo-commits

patrick     12/03/01 15:07:21

  Removed:              zprod-manager
  Log:
  Removing p.masked net-zope deps



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-01 15:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-06 21:53 [gentoo-commits] gentoo-x86 commit in app-admin/zprod-manager/files/0.3.2: zprod-manager Alfredo Tupone (tupone)
  -- strict thread matches above, loose matches on Subject: below --
2008-05-24 20:46 Alfredo Tupone (tupone)
2012-03-01 15:07 Patrick Lauer (patrick)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox