173 lines
5.7 KiB
Bash
173 lines
5.7 KiB
Bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
|
##@require instinc/prefixes
|
|
|
|
######################################################################
|
|
# Chemins
|
|
|
|
# répertoires relatifs pour les applications
|
|
APP_SRVRESDIR="Contents/Resources"
|
|
APP_SRVJAVADIR="Contents/Resources/Java"
|
|
APP_CLTRESDIR="Contents/WebServerResources"
|
|
APP_CLTJAVADIR="Contents/WebServerResources/Java"
|
|
APP_UNIXCLSPTHDIR="Contents/UNIX"
|
|
APP_UNIXCLSPTH="Contents/UNIX/UNIXClassPath.txt"
|
|
APP_MACOSCLSPTHDIR="Contents/MacOS"
|
|
APP_MACOSCLSPTH="Contents/MacOS/MacOSClassPath.txt"
|
|
APP_WINCLSPTHDIR="Contents/Windows"
|
|
APP_WINCLSPTH="Contents/Windows/CLSSPATH.txt"
|
|
APP_HTDOCSDIR="WebObjects"
|
|
|
|
# répertoire relatifs pour les frameworks
|
|
FW_SRVRESDIR="Resources"
|
|
FW_SRVJAVADIR="Resources/Java"
|
|
FW_CLTRESDIR="WebServerResources"
|
|
FW_CLTJAVADIR="WebServerResources/Java"
|
|
FW_HTDOCSDIR="WebObjects/Frameworks"
|
|
|
|
function create_wodirs_maybe() {
|
|
mkdir -p "$WOAPPLICATIONS"
|
|
mkdir -p "$WOFRAMEWORKS"
|
|
}
|
|
|
|
######################################################################
|
|
# Informations sur des répertoires de projet et des bundles
|
|
|
|
function is_wosrcdir() {
|
|
# retourner true si le répertoire $1 est un répertoire de projet webobjects
|
|
|
|
# tester d'abord l'existence du répertoire
|
|
[ -d "$1" ] || return 1
|
|
|
|
# tester la présence de wobuild.conf
|
|
[ -f "$1/wobuild.conf" ] && return 0
|
|
|
|
# tester la présence d'un ou plusieurs répertoires *.pbproj
|
|
[ -n "$(list_dirs "$1" "*.pbproj")" ] && return 0
|
|
|
|
# tester la présence d'un ou plusieurs répertoires *.xcode
|
|
[ -n "$(list_dirs "$1" "*.xcode")" ] && return 0
|
|
[ -n "$(list_dirs "$1" "*.xcodeproj")" ] && return 0
|
|
|
|
# tester la présence de fichiers PB.project
|
|
[ -n "$(list_files "$1" "PB.project")" ] && return 0
|
|
|
|
# tester la présence de build.properties
|
|
[ -f "$1/build.properties" ] && return 0
|
|
|
|
# perdu...
|
|
return 1
|
|
}
|
|
|
|
function set_wobindir() {
|
|
# $1 étant le répertoire de projet, initialiser $2 avec le répertoire
|
|
# binaire correspondant, et $3 avec la description du projet
|
|
local project_name project_type project_desc
|
|
local wobindir__
|
|
|
|
if [ ! -f "$1/build.properties" ]; then
|
|
die "Ne supporte que les projets de type wobuild"
|
|
fi
|
|
file_get_properties "$1/build.properties" project.name "" project.type "framework" project.desc ""
|
|
if [ -z "project_name" -a -z "project_type" -a -z "project_desc" ]; then
|
|
file_get_properties "$1/build.properties" project_name "" project_type "application" project_desc ""
|
|
fi
|
|
if [ -z "$project_name" -o -z "$project_type" ]; then
|
|
die "Projet invalide: il faut spécifier project.name et project.type"
|
|
fi
|
|
if beginswith "$project_type" application; then
|
|
if [ -d "$1/dist/$project_name.woa" ]; then
|
|
wobindir__="$1/dist/$project_name.woa"
|
|
elif [ -d "$1/build/$project_name.woa" ]; then
|
|
wobindir_="$1/build/$project_name.woa"
|
|
else
|
|
wobindir__="$1/dist/$project_name.woa"
|
|
fi
|
|
elif beginswith "$project_type" framework; then
|
|
if [ -d "$1/dist/$project_name.framework" ]; then
|
|
wobindir__="$1/dist/$project_name.framework"
|
|
elif [ -d "$1/build/$project_name.framework" ]; then
|
|
wobindir_="$1/build/$project_name.framework"
|
|
else
|
|
wobindir__="$1/dist/$project_name.framework"
|
|
fi
|
|
else
|
|
die "Type de projet invalide: $project_type"
|
|
fi
|
|
if [ ! -d "$1" ]; then
|
|
die "Il faut construire le projet d'abord"
|
|
fi
|
|
|
|
[ -n "$2" ] && set_var "$2" "$wobindir__"
|
|
[ -n "$3" ] && set_var "$3" "$project_desc"
|
|
}
|
|
|
|
function is_woappdir() {
|
|
# retourner true si le répertoire $1 est un répertoire d'application
|
|
# webobjects
|
|
|
|
# tester d'abord l'existence du répertoire
|
|
[ -d "$1" ] || return 1
|
|
|
|
# tester la présence des répertoire de resources
|
|
test -d "$1/$APP_SRVRESDIR" || return 1
|
|
#test -d "$1/$APP_CLTRESDIR" || return 1
|
|
|
|
# tester la présence des répertoires de classpath
|
|
test -d "$1/$APP_UNIXCLSPTHDIR" || return 1
|
|
test -d "$1/$APP_MACOSCLSPTHDIR" || return 1
|
|
test -d "$1/$APP_WINCLSPTHDIR" || return 1
|
|
|
|
# on se contentera de ces tests sommaires...
|
|
return 0
|
|
}
|
|
|
|
function is_wofwdir() {
|
|
# retourner true sir le répertoire $1 est un répertoire de framework
|
|
# webobjects
|
|
|
|
# tester d'abord l'existence du répertoire
|
|
[ -d "$1" ] || return 1
|
|
|
|
# tester les présence d'un des répertoires de resources
|
|
test -d "$1/$FW_SRVRESDIR" -o -d "$1/$FW_CLTRESDIR" || return 1
|
|
|
|
# on se contentera de ces tests sommaires...
|
|
return 0
|
|
}
|
|
|
|
function get_jawotools_properties_path() {
|
|
if [ -f "$1/jawotools.properties" ]; then
|
|
echo "$1/jawotools.properties"
|
|
elif [ -f "$1/build_infos.txt" ]; then
|
|
echo "$1/build_infos.txt"
|
|
else
|
|
echo "$1/jawotools.properties"
|
|
fi
|
|
|
|
# jawotools.properties: description, developmentSnapshot, releaseDate, version
|
|
# build_infos.txt: desc, devel, date, version
|
|
}
|
|
|
|
function read_jawotools_properties() {
|
|
local file="$(basename "$1")"
|
|
if [ "$file" == "jawotools.properties" ]; then
|
|
file_get_properties "$1" description "--NOT-SET--" version "--NOT-SET--" releaseDate "--NOT-SET--" developmentSnapshot "--NOT-SET--"
|
|
elif [ "$file" == "build_infos.txt" ]; then
|
|
local desc date devel
|
|
file_get_properties "$1" desc "--NOT-SET--" version "--NOT-SET--" date "--NOT-SET--" devel "--NOT-SET--"
|
|
description="$desc"
|
|
releaseDate="$date"
|
|
developmentSnapshot="$devel"
|
|
fi
|
|
}
|
|
|
|
function get_version_txt_path() {
|
|
if [ -f "$1/VERSION.txt" ]; then
|
|
echo "$1/VERSION.txt"
|
|
elif [ -f "$1/version.txt" ]; then
|
|
echo "$1/version.txt"
|
|
else
|
|
echo "$1/VERSION.txt"
|
|
fi
|
|
}
|