rpms/imagej/F-11 imagej-1.43-patch0.patch, NONE, 1.1 imagej-1.43-patch1.patch, NONE, 1.1 imagej.desktop, NONE, 1.1 imagej.spec, NONE, 1.1 import.log, NONE, 1.1 unix-script.txt, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2

Fabien Georget manawy at fedoraproject.org
Mon Dec 14 20:24:38 UTC 2009


Author: manawy

Update of /cvs/pkgs/rpms/imagej/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv2757/F-11

Modified Files:
	.cvsignore sources 
Added Files:
	imagej-1.43-patch0.patch imagej-1.43-patch1.patch 
	imagej.desktop imagej.spec import.log unix-script.txt 
Log Message:


first-commit : imagej 1.43-1.m


imagej-1.43-patch0.patch:
 build.xml |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- NEW FILE imagej-1.43-patch0.patch ---
diff -up ./source/build.xml.patch0 ./source/build.xml
--- ./source/build.xml.patch0	2008-06-09 11:47:52.000000000 +0200
+++ ./source/build.xml	2009-11-15 17:47:01.731056352 +0100
@@ -19,8 +19,8 @@
     <copy file="IJ_Props.txt" todir="build" />
     <copy file="images/microscope.gif" tofile="build/microscope.gif" />
     <copy file="images/about.jpg" tofile="build/about.jpg" />
-	<copy file="plugins/MacAdapter.class" tofile="build/MacAdapter.class" /> 
-	<copy file="plugins/JavaScriptEvaluator.class" tofile="build/JavaScriptEvaluator.class" /> 
+	<!--<copy file="plugins/MacAdapter.class" tofile="build/MacAdapter.class" /> 
+	<copy file="plugins/JavaScriptEvaluator.class" tofile="build/JavaScriptEvaluator.class" /> -->
     <copy todir="build/macros"><fileset dir="macros"/></copy>
     <!-- Build ij.jar. -->
     <jar jarfile="ij.jar" basedir="build"

imagej-1.43-patch1.patch:
 imagej.sh |   97 +++++++++++++++++++++++++++++++-------------------------------
 1 file changed, 49 insertions(+), 48 deletions(-)

--- NEW FILE imagej-1.43-patch1.patch ---
diff -up .find ./imagej.sh.patch1 ./imagej.sh
--- ./imagej.sh.patch1	2009-11-16 17:24:43.486407325 +0100
+++ ./imagej.sh	2009-11-16 17:29:56.947412083 +0100
@@ -6,50 +6,38 @@
 # This program is free software, but comes with no warrenty or guarantee
 # send bug reports or feedback to jjackson at familyjackson dot net
 # Author: Jon Jackson
-# Last modified date: $Date: 2008-09-17 10:31:27 +0100 (Wed, 17 Sep 2008) $
-# $Revision: 51 $
+# Maintainer : Fabien Georget for fedora
+# Last modified date: 2009-11-18
+# Revision: 52 
 #
-# INSTALLATION INSTRUCTIONS
 #
 ### WARNING ###########################################################
 # This file must be edited with a program that supports unix new line characters
 # - it won't run if edited in 'Notepad' !
 #######################################################################
 
-# Source location: http://rsb.info.nih.gov/ij/download/linux/unix-script.txt
-# 1) Save this script in the ImageJ directory as 'imagej'
-# 2) Modify path variables according to your system 
-# 3) Give the new file execute permission
-# 4) Be sure the 'imagej' wrapper is in the 'PATH' 
-
 # setup environment
-set +u # don't give error for unset variables (matters for environment variables)
+set +u 
+# don't give error for unset variables (matters for environment variables)
 shopt -s extglob # allow extended pattern matching
 
 ############ SITE SPECIFIC VARIABLES #########################
 # Trailing / is not required for path variables
 # IMAGEJ PATH - production installation
-ij_path='/local/ImageJ'
-# Path to ImageJ development installation
-ij_path_dev='/home/jjackson/ImageJ'
+ij_path='/usr/share/java'
+#path to data files
+ij_data_path='/usr/share/imagej'
+# Path to user
+ij_user_path="${HOME}/.imagej"
 # JAVA PATH
-# assumes executable is ${java_home}/bin/java
-# set java_home variables ='' to use JAVA_HOME environment variable
-if [[ -d /usr/java/jdk1.5 ]] ; then
-	java_home='/usr/java/jdk1.5'
-else
-	# Optionally specify java path for all available OS / architecture combinations
-	java_home_Linux="${ij_path}/jre"
-	java_home_Linux_x86_64="${ij_path}/jre64"
-	java_home_SunOS="${ij_path}/jre64"
-	# 
-fi
-ijadmin=''
+JAVA_HOME=$(dirname $(dirname $(readlink /etc/alternatives/java)))
+# report bug to http://bugzilla.redhat.com/
+ijadmin='Fedora project'
 # DOCUMENTATION URL
 doc_url='http://rsb.info.nih.gov/ij/'
 
 # TEMP FOLDER
-ij_tmp='/tmp/imagej'
+ij_tmp="${HOME}/.imagej/tmp"
 # LOG FILE
 #ij_log="${ij_tmp}/log.txt"
 # default behaviour when an ImageJ window is already open
@@ -84,26 +72,17 @@ declare -i mem
 declare -i max_mem
 declare -i free_mem
 
-java_home="${java_home:-$JAVA_HOME}"
+java_path="${JAVA_HOME}/bin/java"
 
-if [[ "$OS" == 'SunOS' ]] ; then
-    java_arch='-d64'
-	JAVA_HOME="${java_home_SunOS:-$java_home}"	
-	max_mem=`vmstat | awk 'BEGIN{maxMem='$max_64bit'} NR == 3 {fmem=int($5 / 1024); if (fmem < maxMem) {print fmem} else {print maxMem}}'`
-	free_mem="max_mem"
-	mem=${free_mem}/2
-	if (( $mem > $default_mem || $mem < $min_mem )) ; then mem=$default_mem ; fi
-elif [[ "$OS" == 'Linux' ]] ; then
+if [[ "$OS" == 'Linux' ]] ; then
 	if [[ "$processor" == 'x86_64' ]] ; then
     	java_arch='-d64'
-        JAVA_HOME="${java_home_Linux_x86_64:-$java_home}"
     	max_mem=`free | awk -v maxMem=$max_64bit 'NR == 2 {fmem=int($2 / 1024); if (fmem < maxMem) {print fmem} else {print maxMem}}'`
 		free_mem=`free | awk -v maxMem=$max_64bit 'NR == 3 {fmem=int($4 / 1024); if (fmem < maxMem) {print fmem} else {print maxMem}}'`
 		mem=${free_mem}/3*2
 		if (( $mem > $default_mem || $mem < $min_mem )) ; then mem=$default_mem ; fi
 	else
 		java_arch='-d32'
-    	JAVA_HOME="${java_home_Linux:-$java_home}"
     	max_mem=`free | awk -v maxMem=$max_32bit 'NR == 2 {fmem=int($2 / 1024); if (fmem < maxMem) {print fmem} else {print maxMem}}'`
 		free_mem=`free | awk -v maxMem=$max_32bit 'NR == 3 {fmem=int($4 / 1024); if (fmem < maxMem) {print fmem} else {print maxMem}}'`
 		mem=${free_mem}/3*2
@@ -112,16 +91,38 @@ elif [[ "$OS" == 'Linux' ]] ; then
 fi
 
 
-# if tools.jar is not in ${ij_path}/jre/lib/ext/ edit the 'tools=' line 
-# to point to tools.jar. The -compile switch will load tools.jar into the 
-# classpath and enable plugins to be compiled in imagej
+# create plugins, macros, luts dirs
+mkdir -p $ij_user_path/plugins
+mkdir -p $ij_user_path/macros
+mkdir -p $ij_user_path/luts
 
-if [[ -f "${ij_path}/tools.jar" ]] ; then
-    tools="${ij_path}/tools.jar"
-else
-    tools=''
+if [[ ! -d "$ij_tmp" ]] ; then
+    mkdir -p "$ij_tmp"
 fi
 
+# makes symbolik links from shared plugins, macros and luts 
+
+ls $ij_data_path/plugins | while read p ; do
+  if [ ! -e "$ij_user_path/plugins/$p" ] ; then
+    ln -s $ij_data_path/plugins/$p $ij_user_path/plugins/$p
+  fi
+done
+
+ls $ij_data_path/macros | while read p; do
+  if [ ! -e "$ij_user_path/macros/$p" ] ; then
+      ln -s "$ij_data_path/macros/$p" "$ij_user_path/macros/$p"
+  fi
+done
+
+ls $ij_data_path/luts | while read p ; do
+    if [ ! -e "$ij_user_path/luts/$p" ] ; then
+	ln -s $ij_data_path/luts/$p $ij_user_path/luts/$p
+    fi
+done
+
+# enable plugins to be compiled with imageJ
+tools="${JAVA_HOME}/../lib/tools.jar"
+
 # End Site specific variables ---------------------------------------------------------
 
 # other variables 
@@ -320,9 +321,9 @@ fi	
 
 # Resolving ij.jar path.  If ij.jar is a symbolic link to ij_<version>.jar
 # this allows updating ij.jar without crashing running sessions
-ij_jar_path=$(derefln ${ij_path}/ij.jar)    
+ij_jar_path=$(derefln ${ij_path}/ImageJ-1.43.jar)    
                                          
-for mod_jar in ${ij_path}/lib/*jar  ; do
+for mod_jar in ${ij_path}/*jar  ; do
     modules="${modules:-}${modules+:}$mod_jar"
 done
 modules="-cp ${ij_jar_path}:${modules+:}${modules:-}"
@@ -470,9 +471,9 @@ if [[ "$portopen" == 'false' ]] ; then
 fi
 
 if (( $verbosity > 0 )) ; then
-    echo ${JAVA_HOME}/bin/java ${java_arch} -mx${mem}m ${modules} ij.ImageJ -ijpath ${ij_path} -port${count} ${images} ${macrocmd} ${macroargs}
+    echo ${JAVA_HOME}/bin/java ${java_arch} -mx${mem}m ${modules} ij.ImageJ -ijpath ${ij_user_path} -port${count} ${images} ${macrocmd} ${macroargs}
 fi
 
 cd "$dir"
-eval "${JAVA_HOME}/bin/java ${java_arch} -mx${mem}m ${modules} ij.ImageJ -ijpath ${ij_path} -port${count} ${images} ${macrocmd} ${macroargs} "
+eval "${JAVA_HOME}/bin/java ${java_arch} -mx${mem}m ${modules} ij.ImageJ  -ijpath ${ij_user_path} -port${count} ${images} ${macrocmd} ${macroargs} "
 exit 0


--- NEW FILE imagej.desktop ---
[Desktop Entry]
Encoding=UTF-8
Name=ImageJ
GenericName=Image Editor                                       
GenericName[ar]=محرر صور                                       
GenericName[be]=Рэдактар відарысаў                             
GenericName[bg]=Редактор на изображения                        
GenericName[ca]=Editor d'imatges                               
GenericName[ca at valencia]=Editor d'imatges                      
GenericName[cs]=Editor obrázků                                 
GenericName[da]=Billedredigering                               
GenericName[de]=Bildeditor                                     
GenericName[dz]=གཟགས་བརན་ ཞན་དག་པ།                             
GenericName[el]=Επεξεργαστής εικόνων                           
GenericName[en_CA]=Image Editor                                
GenericName[en_GB]=Image Editor                                
GenericName[eo]=Bilada Redaktilo                               
GenericName[es]=Editor de imagen                               
GenericName[et]=Pildiredaktor                                  
GenericName[eu]=Irudi-editorea                                 
GenericName[fa]=ویرایشگر تصویر                                 
GenericName[fi]=Kuvankäsittely                                 
GenericName[fr]=Éditeur d'image                                
GenericName[gl]=Editor de imaxes                               
GenericName[gu]=ચિતર સપાદક                                     
GenericName[hu]=Képszerkesztő                                  
GenericName[is]=Myndvinnsluforrit                              
GenericName[it]=Editor immagine                                
GenericName[ja]=画像エディタ                                   
GenericName[ka]=გამოსახულებების რედაქტორი                      
GenericName[km]=កមមវធនពនធរបភាព                                 
GenericName[kn]=ಚತರ ಸಂಪಾದಕ                                     
GenericName[ko]=이미지 편집기                                  
GenericName[lt]=Paveikslėlių rengyklė                          
GenericName[lv]=Attēla redaktors                               
GenericName[mk]=Уредник за слики                               
GenericName[mr]=परतिमा सपादक                                   
GenericName[nb]=Bildebehandler                                 
GenericName[ne]=छवि समपादक                                     
GenericName[nl]=Afbeeldingsbewerker                            
GenericName[nn]=Biletbehandlar                                 
GenericName[or]=ପରତଛବ ସମପାଦକ                                   
GenericName[pa]=ਚਿਤਰ ਐਡੀਟਰ                                     
GenericName[pl]=Edytor obrazu                                  
GenericName[pt]=Editor de Imagens                              
GenericName[pt_BR]=Editor de Imagens                           
GenericName[ro]=Editor de imagine                              
GenericName[ru]=Редактор изображений                           
GenericName[sk]=Editor obrázkov                                
GenericName[sl]=Urejevalnik slik                               
GenericName[sr]=Обрада слика                                   
GenericName[sr at latin]=Obrada slika                             
GenericName[sv]=Bildredigerare                                 
GenericName[ta]=பிமப திருததி                                   
GenericName[th]=ตวแกไขภาพ                                      
GenericName[tr]=Resim Düzenleyici                              
GenericName[tt]=Sürät Tözätkeç                                 
GenericName[uk]=Редактор зображень                             
GenericName[vi]=Bộ biên soạn ảnh                               
GenericName[xh]=UmHleli woMfanekiso                            
GenericName[zh_CN]=图像编辑器                                  
GenericName[zh_HK]=圖片編輯器                                  
GenericName[zh_TW]=圖片編輯器    
Comment=Image Processing and Analysis in Java
Exec=imagej %f
TryExec=imagej 
Icon=/usr/share/pixmaps/microscope.gif
Terminal=false
Type=Application
Categories=Application;Graphics;
MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjeg;image/png;image/tiff;image/x-bmp;image/x-fits;image/x-png;image/x-psd;image/x-xbitmap;application/dicom;


--- NEW FILE imagej.spec ---
Name:           imagej
Version:        1.43
Release:        1.m%{?dist}
Summary:        Image Processing and Analysis in Java

Group:          Applications/Engineering
License:        Public Domain
URL:            http://rsbweb.nih.gov/ij/index.html
Source0:        http://rsbweb.nih.gov/ij/download/src/ij143m-src.zip
Source1:        %{name}.desktop
Source2:        http://rsbweb.nih.gov/ij/macros/macros.zip
Source3:        http://rsb.info.nih.gov/ij/download/linux/unix-script.txt
# don't copy .class files 
patch0:         %{name}-%{version}-patch0.patch
# modify imagej.sh for fedora compatibility
patch1:         %{name}-%{version}-patch1.patch
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)


BuildRequires:  jpackage-utils
BuildRequires:  java-devel >= 1.6.0
BuildRequires:  ant
BuildRequires:  desktop-file-utils


Requires:       jpackage-utils
# java-devel not java for plugins build
Requires:       java-devel >= 1.6.0

%description
ImageJ is a public domain Java image processing program. It can display,        
edit, analyze a wide variety of image data, including image sequences. Imagej   
can be used for quantitative analysis of engineering and scientific image data.

%package javadoc
Summary:        Javadocs for %{name}
Group:          Development Documentation
BuildArch:      noarch
Requires:       %{name} = %{version}-%{release}
Requires:       jpackage-utils

%description javadoc
This package contains the API documentation for %{name}.

%prep
%setup -q -c -n "%{name}-%{version}" 
# patch build.xml
%patch0 -p1 -b .patch0
# unzip macros.zip
unzip -u %{SOURCE2} 
# erase binary and useless files 
rm -rf macros/.FBC*
rm macros/build.xml
rm -rf __MACOSX
#get and patch unix-script.txt
cp %{SOURCE3} ./imagej.sh
%patch1 -p1 -b .patch1

find -name '*.class' -exec rm -f '{}' \;
find -name '*.jar' -exec rm -f '{}' \;

%build
cd source
ant build javadocs
cd ..

%install
rm -rf $RPM_BUILD_ROOT

# install jar
mkdir -p $RPM_BUILD_ROOT%{_javadir}
cp -p source/ij.jar   \
$RPM_BUILD_ROOT%{_javadir}/%{name}-%{version}.jar

# install javadoc
mkdir -p $RPM_BUILD_ROOT%{_javadocdir}/%{name}
cp -rp api  \
$RPM_BUILD_ROOT%{_javadocdir}/%{name}

# install icon
mkdir -p $RPM_BUILD_ROOT%{_datadir}/pixmaps
cp -p source/build/microscope.gif $RPM_BUILD_ROOT%{_datadir}/pixmaps

# install data files
mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{name}
cp -p source/build/about.jpg $RPM_BUILD_ROOT%{_datadir}/%{name}/about.jpg
cp -p source/build/IJ_Props.txt $RPM_BUILD_ROOT%{_datadir}/%{name}/IJ_Props.txt

#install macros
chmod 644 macros/About\ Startup\ Macros 
find ./macros -name \*.txt -type f -exec chmod 644 {} \;
find ./macros -type d -exec chmod 755 {} \;
cp -rp macros $RPM_BUILD_ROOT%{_datadir}/%{name}


#install luts
mkdir $RPM_BUILD_ROOT%{_datadir}/%{name}/luts 

# install script
mkdir -p $RPM_BUILD_ROOT%{_bindir}
chmod +x imagej.sh
cp -p imagej.sh $RPM_BUILD_ROOT%{_bindir}/%{name}

# directory for plugins
mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{name}/plugins
cp source/plugins/JavaScriptEvaluator.source $RPM_BUILD_ROOT%{_datadir}/%{name}/plugins/JavaScriptEvaluator.java

# desktop file
desktop-file-install --vendor=""                     \
       --dir=%{buildroot}%{_datadir}/applications/   \
       %{SOURCE1}

%post

#update icon cache
touch --no-create %{_datadir}/icons/hicolor
if [ -x %{_bindir}/gtk-update-icon-cache ]; then
  %{_bindir}/gtk-update-icon-cache -q %{_datadir}/icons/hicolor;
fi
update-desktop-database &> /dev/null || :

%postun
# update icon cache
touch --no-create %{_datadir}/icons/hicolor
if [ -x %{_bindir}/gtk-update-icon-cache ]; then
  %{_bindir}/gtk-update-icon-cache -q %{_datadir}/icons/hicolor;
fi
update-desktop-database &> /dev/null || :


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%{_javadir}/*
%{_datadir}/%{name}/
%{_datadir}/applications/%{name}.desktop
%{_datadir}/pixmaps/microscope.gif
%{_bindir}/%{name}
%doc source/aREADME.txt source/release-notes.html source/applet.html

%files javadoc
%defattr(-,root,root,-)
%{_javadocdir}/%{name}


%changelog
* Fri Dec 11 2009 Georget Fabien <fabien.georget at gmail.com> 1.43-1.m
- version 1.43m 

* Sun Nov 21 2009 Georget Fabien <fabien.georget at gmail.com> 1.43-0.5.j
- set build directory to {name}-{version}
- modify wrapper script
- add java-devel to requires

* Sun Nov 15 2009 Georget Fabien <fabien.georget at gmail.com> 1.43-0.4.j
- modify name from ImageJ to imagej
- modify wrapper script for fedora compatibility 

* Mon Nov 10 2009 Georget Fabien <fabien.georget at gmail.com> 1.43-0.3.j
- get macros from  http://rsbweb.nih.gov/ij/macros/macros.zip
- get launch script from  http://rsb.info.nih.gov/ij/download/linux/unix-script.txt
- don't copy macros in the jar but in /usr/share/ImageJ/macros

* Mon Nov 10 2009 Georget Fabien <fabien.georget at gmail.com> 1.43-0.2.j
- change group to Application/Engineering
- change description
- add comments
- change version tag

* Sat Nov 7 2008 Georget Fabien <fabien.georget at gmail.com> 1.43-0.1
- Creation


--- NEW FILE import.log ---
imagej-1_43-1_m_fc12:F-11:imagej-1.43-1.m.fc12.src.rpm:1260822119


--- NEW FILE unix-script.txt ---
#!/bin/bash 
# A wrapper script to launch imagej from the UNIX command line
# Images given as arguments will be opened, macros may also be given as arguments
# Looks for macros in the imagej macro directory
#
# This program is free software, but comes with no warrenty or guarantee
# send bug reports or feedback to jjackson at familyjackson dot net
# Author: Jon Jackson
# Last modified date: $Date: 2008-09-17 10:31:27 +0100 (Wed, 17 Sep 2008) $
# $Revision: 51 $
#
# INSTALLATION INSTRUCTIONS
#
### WARNING ###########################################################
# This file must be edited with a program that supports unix new line characters
# - it won't run if edited in 'Notepad' !
#######################################################################

# Source location: http://rsb.info.nih.gov/ij/download/linux/unix-script.txt
# 1) Save this script in the ImageJ directory as 'imagej'
# 2) Modify path variables according to your system 
# 3) Give the new file execute permission
# 4) Be sure the 'imagej' wrapper is in the 'PATH' 

# setup environment
set +u # don't give error for unset variables (matters for environment variables)
shopt -s extglob # allow extended pattern matching

############ SITE SPECIFIC VARIABLES #########################
# Trailing / is not required for path variables
# IMAGEJ PATH - production installation
ij_path='/local/ImageJ'
# Path to ImageJ development installation
ij_path_dev='/home/jjackson/ImageJ'
# JAVA PATH
# assumes executable is ${java_home}/bin/java
# set java_home variables ='' to use JAVA_HOME environment variable
if [[ -d /usr/java/jdk1.5 ]] ; then
	java_home='/usr/java/jdk1.5'
else
	# Optionally specify java path for all available OS / architecture combinations
	java_home_Linux="${ij_path}/jre"
	java_home_Linux_x86_64="${ij_path}/jre64"
	java_home_SunOS="${ij_path}/jre64"
	# 
fi
ijadmin=''
# DOCUMENTATION URL
doc_url='http://rsb.info.nih.gov/ij/'

# TEMP FOLDER
ij_tmp='/tmp/imagej'
# LOG FILE
#ij_log="${ij_tmp}/log.txt"
# default behaviour when an ImageJ window is already open
newwindow='true'
#newwindow='false'
# macro argument delimiter character
separator=':'
# a ' ' may work provided no arguments would contain spaces
# use macro functions:  args=getArgument(); argArray=split(args, ':'); 
# to recover macro arguments

############ DEFAULT MEMORY SETTINGS  #########################

declare -i default_mem=768
declare -i min_mem=32
declare -i max_32bit=1800 # empirical
declare -i max_64bit=17000000000 # conservative

############ SITE SPECIFIC MODULES #########################

# JAR libraries for additional modules may be placed in ${ij_path}/lib
# jmf.jar jai_codec.jar jai_core.jar mlibwrapper_jai.jar

# Native libraries may be placed in ${ij_path}/lib/$OS
# where OS matches the output of the 'uname' command

############ END SITE SPECIFIC VARIABLES #########################

OS=$(uname)
processor=$(uname -m) # -p doesn't work on ubuntu
declare -i mem
declare -i max_mem
declare -i free_mem

java_home="${java_home:-$JAVA_HOME}"

if [[ "$OS" == 'SunOS' ]] ; then
    java_arch='-d64'
	JAVA_HOME="${java_home_SunOS:-$java_home}"	
	max_mem=`vmstat | awk 'BEGIN{maxMem='$max_64bit'} NR == 3 {fmem=int($5 / 1024); if (fmem < maxMem) {print fmem} else {print maxMem}}'`
	free_mem="max_mem"
	mem=${free_mem}/2
	if (( $mem > $default_mem || $mem < $min_mem )) ; then mem=$default_mem ; fi
elif [[ "$OS" == 'Linux' ]] ; then
	if [[ "$processor" == 'x86_64' ]] ; then
    	java_arch='-d64'
        JAVA_HOME="${java_home_Linux_x86_64:-$java_home}"
    	max_mem=`free | awk -v maxMem=$max_64bit 'NR == 2 {fmem=int($2 / 1024); if (fmem < maxMem) {print fmem} else {print maxMem}}'`
		free_mem=`free | awk -v maxMem=$max_64bit 'NR == 3 {fmem=int($4 / 1024); if (fmem < maxMem) {print fmem} else {print maxMem}}'`
		mem=${free_mem}/3*2
		if (( $mem > $default_mem || $mem < $min_mem )) ; then mem=$default_mem ; fi
	else
		java_arch='-d32'
    	JAVA_HOME="${java_home_Linux:-$java_home}"
    	max_mem=`free | awk -v maxMem=$max_32bit 'NR == 2 {fmem=int($2 / 1024); if (fmem < maxMem) {print fmem} else {print maxMem}}'`
		free_mem=`free | awk -v maxMem=$max_32bit 'NR == 3 {fmem=int($4 / 1024); if (fmem < maxMem) {print fmem} else {print maxMem}}'`
		mem=${free_mem}/3*2
		if (( $mem > $default_mem || $mem < $min_mem )) ; then mem=$default_mem ; fi	
	fi
fi


# if tools.jar is not in ${ij_path}/jre/lib/ext/ edit the 'tools=' line 
# to point to tools.jar. The -compile switch will load tools.jar into the 
# classpath and enable plugins to be compiled in imagej

if [[ -f "${ij_path}/tools.jar" ]] ; then
    tools="${ij_path}/tools.jar"
else
    tools=''
fi

# End Site specific variables ---------------------------------------------------------

# other variables 
dir=`pwd`
user=`whoami`
host=`hostname`
if [[ -z "$DISPLAY" ]] ; then
    echo 'Display variable not set'
    echo 'If ImageJ fails to load, try '
    echo '% setenv DISPLAY yourcomputer:0'
    echo 'if you use the "csh" or for "bash" try'
    echo '% export DISPLAY=yourcomputer:0'
    display='default' 
else
    display="$DISPLAY"
fi

declare -i port=0
declare -i verbosity=0
images=''
macrocmd=''
macroargs=''


function usage {
    echo 
    echo 'Image display and analysis program. Opens formats including:'
    echo 'UNC, Analyze, Dicom, NIFTI, Tiff, Jpeg, Gif, PNG ...'  
    echo
    echo 'imagej [options] image [ image2 ... image3 ]'
    echo '    -h        print help and more options'
    echo '    -o        open images in an open ImageJ panel'
    echo '    -p <N>    open images in ImageJ panel number <N>' 
    echo "    -x <MB>   set available memory (default=${mem} max=${max_mem})"     
    echo 
}

function fullusage {
    echo 
    echo 'Image display and analysis program. Opens formats including:'
    echo 'UNC, Analyze, Dicom, NIFTI, Tiff, Jpeg, Gif, PNG ...'  
    echo 
    echo 'imagej [options] image [ image2 ... image3 ] -> open images'
    echo
    echo 'basic options:'
    echo '  -h        print help and more options'
    echo '  -o        open images in existing ImageJ panel if one exists'
    echo '  -p <N>    open images in existing ImageJ panel number <N>' 
    echo "  -x <MB>   set available memory (default=${mem} max=${max_mem})"
    echo
    echo 'advanced options:'
    echo '  -c        enable plugin compilation within imagej'
    echo '  -d        use development version'
    echo '  -v        be verbose (vv or vvv increases verbosity)'  
    echo
    echo 'options for batch processing:'
    echo "  -e 'Macro Code'            execute macro code"
    echo "  -r 'Menu Command'          run menu command"
    echo "Quotation marks '' are required around commands including spaces"
    echo 'Commands can be sent to open ImageJ panels with the -p option'
    echo 
    echo 'options for macros:'
    echo 'imagej [-i image] [-b|-m] [arg1 ... argN] '
    echo '  -b macro    run macro without graphics window' 
    echo '  -m macro    run macro' 
    echo '"image" will be opened before macro is run'
    echo 'all following arguments are passed to macro'        
    echo 
    echo "Documentation - $doc_url "
	echo "Report problems with this software to $ijadmin"
    echo
}

function macroCmdError {
	fullusage 
	echo 'Only one command option (-b -e -m OR -r) may be specified' 1>&2
	exit 1
}

function getFullPath {
    # Return full path to file
    # treats multiple arguments as a single file with spaces
    if (( $# == 0 )) ; then
        echo "error getting full path for '${*}'" 1>&2
    fi
    pwd_getFullPath="$PWD"
    \cd $(dirname "${*}") > /dev/null
    dir_getFullPath="$PWD"
    \cd "$pwd_getFullPath" > /dev/null
    echo "$dir_getFullPath"/$(basename "${*}")
}
function derefln { 
    # Returns the full path of file to which link points
    # following multiple levels of symbolic links.
    # NOTE: if you use this function in a script, don't use any
    # of the variable names used here
    if (( $# == 0 )) ; then
        return
    fi
    local the_link="$1"
    local link_dir 
    local current_dir="$PWD"
    while file "$the_link" | grep symbolic > /dev/null ; do # resolve links until target is regular file
        if [[ "$the_link" == */* ]] ; then # path contains  /
            \cd $(dirname "${the_link}") > /dev/null
            the_link=$(basename "$the_link")
        fi
        link_dir="$PWD" 
	    # some versions of 'file' surround the path in `' quotes, hence the tr to remove them
        the_link=$(file "${the_link}" | awk '/symbolic link/ {print $NF}' | tr -d "\140\047" )
        if [[ "$the_link" != /* ]] ; then # path is not absolute path  - make it one
            the_link="$link_dir/$the_link"
        fi
        \cd "$current_dir" > /dev/null
    done 
    echo $the_link
}


# parse input arguments
while getopts b:cde:hi:m:nop:r:vx: options
do
	case $options in
		b)	if [[ -n "$macrocmd" ]] ; then macroCmdError ; fi
			macrocmd="-batch ${OPTARG}"
			;;
		c)	modules="${modules:-}${modules+:}${tools}"
			;;
		d)	ij_path="$ij_path_dev"
			;;
		e)  if [[ -n "$macrocmd" ]] ; then macroCmdError ; fi
			macrocmd='-eval'
			macroargs="'${OPTARG}'"
			;;
		h)  fullusage
			exit 0
			;;
		i)  images="${images}'${OPTARG}' "
			;;
		m)	if [[ -n "$macrocmd" ]] ; then macroCmdError ; fi
			macrocmd="-macro ${OPTARG}"
			;;
        n)  newwindow='true'
            ;;
		o)  newwindow='false'
			;;
		p)	newwindow='false'
			port="${OPTARG}"
        	if (( "$port" < 1 || "$port" > 99 )) ; then
            	echo "${OPTARG} is not a permissible value for port number (-p)" 1>&2
            	exit 1
        	fi
			;;
		r)	if [[ -n "$macrocmd" ]] ; then macroCmdError ; fi
			macrocmd='-run'
			macroargs="'${OPTARG}'"
			;;
		v)	verbosity=verbosity+1
			if (( $verbosity == 2 )) ; then set -x ; fi
			if (( $verbosity == 3 )) ; then set -v ; fi
			;;
		x)	mem="${OPTARG}"
            newwindow='true'
			if (( $mem < $min_mem || $mem > $max_mem )) ; then
            	echo "${OPTARG} is not a permissible value for memory (-x)" 1>&2
            	echo "min=${min_mem}, max=${max_mem}" 1>&2
            	exit 1				
			fi
			;;
		\?) usage
			exit 1 
			;;
	esac
done
			
#for ((i=1; i < $OPTIND; i++)) 
#do
#	shift
#done
## above syntax not supported in bash < 2.05
declare -i i=1
while (( i < $OPTIND )) ; do
	shift
	i=i+1
done

if [[ "$#" == 0 && -z "$macrocmd" ]] ; then
	usage
fi	

# The best way to install .jar libraries required by plugins is to copy them 
# to the imagej plugins/jars directory
# Alternatively, either copy them to ${ij_path}/jre/lib/ext/ or add the .jar
# filepath to the modules line below. Paths are separated by a colon
# Classpath must follow command line arguments, as ij_path is dependent on the -d option

# Resolving ij.jar path.  If ij.jar is a symbolic link to ij_<version>.jar
# this allows updating ij.jar without crashing running sessions
ij_jar_path=$(derefln ${ij_path}/ij.jar)    
                                         
for mod_jar in ${ij_path}/lib/*jar  ; do
    modules="${modules:-}${modules+:}$mod_jar"
done
modules="-cp ${ij_jar_path}:${modules+:}${modules:-}"
#${ij_path}/plugins/jars/dcmie.jar

export LD_LIBRARY_PATH="${ij_path}/lib/${OS}_$processor"
if (( $verbosity > 0 )) ; then
    echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
fi

# -b and -m options only:
# remaining command line arguments are passed as macro arguments 
# separated by $separator
if [[ -n "$macrocmd" && -z "$macroargs" ]] ; then
	while (( "$#" > 0 )) ; do
        if [[ -z "$macroargs" ]] ; then 
            macroargs="${1}"
        else
            macroargs="${macroargs}${separator}${1}"
        fi
        shift 		
	done
	macroargs="'$macroargs'"
fi

# PROTECT POSSIBLE SPACES IN IMAGE FILENAMES
if (( "$#" > 0 )) ; then
	while (( "$#" > 0 )) ; do
        filearg="${1}"
        # full file path required when sending images to running ImageJ panel
        if [[ "${newwindow}" == 'false' && -f "${filearg}" ]]  && ! expr "${filearg}" : '/.*' > /dev/null; then 
            filearg="$(getFullPath ${filearg})"
        fi
		images="${images}'$filearg' "
		shift 
	done
fi	

# CREATE IMAGEJ SOCKET-LOCK DIRECTORY IF NON EXISTANT 
if [[ ! -d "$ij_tmp" ]] ; then
    mkdir "$ij_tmp"
    chmod 777 "$ij_tmp"
fi

# CREATE IMAGEJ LOG FILE IF NON EXISTANT 
if [[ -n "$ij_log" && ! -f "$ij_log" ]] ; then
    touch "$ij_log"
    chmod 666 "$ij_log"
fi

# CREATES A TEMP FILE INDICATING A PORT IS IN USE BY IMAGEJ
cd "$ij_tmp"
declare -i count=1
portopen='false'
lockFileCreated='false'
declare -a locklist=(`ls | grep '[0-9][0-9]-.*'`)

[[ -n "$ij_log" ]] && echo -e "$$\t$(date)\tNew Window = $newwindow" >> "$ij_log" 2> /dev/null
[[ -n "$ij_log" ]] && echo -e "$$\t$(date)\tPort = $port" >> "$ij_log" 2> /dev/null
[[ -n "$ij_log" ]] && echo -e "$$\t$(date)\tlocklist: \n ${locklist[*]}" >> "$ij_log" 2> /dev/null
if (( $verbosity > 0 )) ; then echo -e "locklist: \n ${locklist[*]}" ; fi

# PORT SPECIFIED BY USER
if (( $port > 0 )) ; then
    # look for a lock on the port specified
    for lockname in ${locklist[*]} ; do
        prefix=`printf '%02u' $port`
        if [[ "$lockname" == ${prefix}-${user}-${host}* ]] ; then
        	# found lock on the requested port, owned by user on current display
            portopen='true'
            if (( $verbosity > 0 )) ; then echo "Using socket lock: $lockname" ; fi
            count=$port
            break
        elif [[ "$lockname" == ${prefix}-* ]] ; then
            echo "Port $port is in use by some other user or a different host" 1>&2
            if (( $verbosity > 0 )) ; then echo "Port lock: $lockname" ; fi
            exit 1
        fi
    done 
    # specified port not in use 
    count=$port

# IF EXISTING WINDOW IS REQUESTED, LOOK FOR LISTENING PORT
elif [[ "$newwindow" == 'false' && ${#locklist} != 0 ]] ; then
    # look for a lock on the current display for this user
    for lockname in ${locklist[*]} ; do
        if [[ "$lockname" == [0-9][0-9]-${user}-${host}-${display} ]] ; then
            portopen='true'
            if (( $verbosity > 0 )) ; then echo "Found socket lock: $lockname" ; fi
            # if a matching user/display is found, use this one
            count="${lockname%-*-*-*}"
            #count=`echo $lockname | sed  -e 's/^\([0-9][0-9]\).*/\1/' -e 's/^0//'` # csh?
            break
        fi
    done
fi

# IF A NEW PORT IS TO BE USED
if [[ "$portopen" == 'false' ]] ; then
    # new window requested or no matching port found
    # if port is not specified, look for first free port
    if (( "$port" == 0 )) ; then 
        if (( ${#locklist} == 0 )) ; then
            # no active locks - use first port
            count=1
        else
            # active locks - check each port number so see if it is in use
            # this is not synchronised!!
            count=0
            inuse='true'
            while [[ "$inuse" == 'true' ]] ; do
                count=count+1
                prefix=`printf '%02u' $count`
                inuse='false'
                for lockname in ${locklist[*]} ; do
                    if [[ "$lockname" == ${prefix}-* ]] ; then
                        inuse='true'
                    fi
                done
            done
        fi
    fi
    # CREATING A NEW PORT LOCK
    prefix=`printf '%02u' $count`
    lockname=${prefix}-${user}-${host}-${display}
    
    [[ -n "$ij_log" ]] && echo -e "$$\t$(date)\tCreating lock\t$lockname" >> "$ij_log" 2> /dev/null
	if (( $verbosity > 0 )) ; then echo -n "creating lock $lockname ... " ; fi
	touch $lockname
	trap '\rm -f ${ij_tmp}/$lockname >/dev/null ; [[ -n "$ij_log" ]] && echo -e "$$\t$(date)\tReleasing lock\t$lockname" >> "$ij_log" 2> /dev/null' EXIT TERM KILL 
	# Quitting ImageJ sends EXIT, as does a kill/kill -9 
	# CTRL+C in terminal sends INT + EXIT
	# System shutdown sends TERM (+EXIT??)
	
	if (( $verbosity > 0 )) ; then  echo 'done' ; fi

    lockFileCreated='true'
    if [[ -z "$macrocmd" ]] ; then 
	    echo 'Open other images in this ImageJ panel as follows:'
	    echo "  imagej -p $count <image1> [<image2> ... <imageN>]"
    fi
    [[ -n "$ij_log" ]] && echo -e "$$\t$(date)\tSocket lock:\t$lockname" >> "$ij_log" 2> /dev/null
    if (( $verbosity > 0 )) ; then echo "Socket lock: $lockname" ; fi
	echo
fi

if (( $verbosity > 0 )) ; then
    echo ${JAVA_HOME}/bin/java ${java_arch} -mx${mem}m ${modules} ij.ImageJ -ijpath ${ij_path} -port${count} ${images} ${macrocmd} ${macroargs}
fi

cd "$dir"
eval "${JAVA_HOME}/bin/java ${java_arch} -mx${mem}m ${modules} ij.ImageJ -ijpath ${ij_path} -port${count} ${images} ${macrocmd} ${macroargs} "
exit 0


Index: .cvsignore
===================================================================
RCS file: /cvs/pkgs/rpms/imagej/F-11/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- .cvsignore	14 Dec 2009 17:35:21 -0000	1.1
+++ .cvsignore	14 Dec 2009 20:24:37 -0000	1.2
@@ -0,0 +1,2 @@
+ij143m-src.zip
+macros.zip


Index: sources
===================================================================
RCS file: /cvs/pkgs/rpms/imagej/F-11/sources,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- sources	14 Dec 2009 17:35:21 -0000	1.1
+++ sources	14 Dec 2009 20:24:38 -0000	1.2
@@ -0,0 +1,2 @@
+266866864fd0a2d575338daccc09ec72  ij143m-src.zip
+8161ec95aa84e9fa3e46e68a00fada4d  macros.zip




More information about the fedora-extras-commits mailing list