2 XCOMM $XConsortium: dtappintegrate.src /main/4 1996/04/21 19:27:37 drk $
4 XCOMM ###################################################################
8 XCOMM (c) Copyright 1996 Digital Equipment Corporation. #
9 XCOMM (c) Copyright 1993,1994,1996 Hewlett-Packard Company. #
10 XCOMM (c) Copyright 1993,1994,1996 International Business Machines Corp.#
11 XCOMM (c) Copyright 1993,1994,1996 Sun Microsystems, Inc. #
12 XCOMM (c) Copyright 1996 Novell, Inc. #
13 XCOMM (c) Copyright 1996 FUJITSU LIMITED. #
14 XCOMM (c) Copyright 1996 Hitachi. #
15 XCOMM (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of #
18 XCOMM This is the dt application integration script to assist #
19 XCOMM in integrating applications into COSE Desktop Environment. #
21 XCOMM syntax: dtappintegrate -s <source> [-t <target>] [-l <lang>] [-u]#
23 XCOMM -s indicates application's root location. #
24 XCOMM source the path name of the application's root. #
25 XCOMM -t indicates a new location for the #
26 XCOMM application's group files. #
27 XCOMM target the path name of the target location. #
28 XCOMM -l indicates the language for this application. #
29 XCOMM language the language name as used by $LANG #
30 XCOMM environment variable. #
31 XCOMM -u indicates to unintegrate the application. #
34 XCOMM ###################################################################
36 XCOMM ------------------------------------------------------------------#
39 XCOMM This routine is used to echo the command line syntax. #
47 XCOMM ------------------------------------------------------------------#
50 echo "Usage: $SCRIPT_NAME -s <source> [-t <target>] [-l <language>] [-u]" | tee -a $LOGFILE
53 XCOMM ------------------------------------------------------------------#
54 XCOMM GetAbsolutePath #
56 XCOMM This routine is to resolve a path to its actual path, #
57 XCOMM following links, etc. #
65 XCOMM ------------------------------------------------------------------#
66 function GetAbsolutePath
68 if [ "/" = "$1" ]; then
71 GetAbsolutePath `ls -l $1 | awk '{print $NF}'` $2
74 if [ "." = "$1" -o ".." = "$1" ]; then
75 GetAbsolutePath / /`basename $1`$2
77 GetAbsolutePath `dirname $1` /`basename $1`$2
82 XCOMM ------------------------------------------------------------------#
83 XCOMM GetRelativePath #
85 XCOMM This routine is used to determine the relative path of #
86 XCOMM of the source path from the target path. #
89 XCOMM $1 = absolute source path #
90 XCOMM $2 = absolute target path #
96 XCOMM ------------------------------------------------------------------#
97 function GetRelativePath
102 a = split(src, A, "/");
103 b = split(dest, B, "/");
106 for (i = 2; i < a && i < b; i++) {
107 if (match(A[i],B[i])) {
113 for (i = 0 ; i <= (a - s - 2); i++) {
116 for (i = 2 + s; i <= b; i++) {
117 printf("%s%s", B[i], (i < b) ? "/":"\n");
121 XCOMM ------------------------------------------------------------------#
124 XCOMM This routine creates the actual links from the application's#
125 XCOMM root config files to the target location. #
129 XCOMM return codes: #
130 XCOMM n - number of files integrated or unintegrated #
132 XCOMM ------------------------------------------------------------------#
135 typeset source=$1 target=$2 torf=$3 spath="" tpath="" cfgfile="" rpath=""
136 typeset pattern="" files=""
139 if [[ -L $source || -L $(dirname $source) ]] then
140 spath=$(GetAbsolutePath $source)
144 if [[ -L $target || -L $(dirname $target) ]] then
145 tpath=$(GetAbsolutePath $target)
152 if [[ $pattern = "(*)" ]] then
153 files=$(ls -d $source/COMMENT_STAR 2>/dev/null)
155 files=$(ls -d $source/$pattern 2>/dev/null)
158 count=$(echo $files | wc -w)
159 for cfgfile in $files
161 basecfg=$(basename $cfgfile)
162 if [[ $torf = TRUE ]] then
163 if [[ $rpath = "" ]] then
164 rpath=$(GetRelativePath $spath $tpath)
166 rm -f $tpath/$basecfg
167 echo "ln -sf $rpath/$basecfg $tpath/$basecfg" >> $LOGFILE
168 ln -sf $rpath/$basecfg $tpath/$basecfg >> $LOGFILE 2>&1
170 rm $tpath/$basecfg >/dev/null 2>&1
172 echo "rm $tpath/$basecfg" >> $LOGFILE
181 XCOMM ------------------------------------------------------------------#
182 XCOMM IntegrateUnintegrate #
184 XCOMM This routine integrates the files into the cose desktop #
185 XCOMM environment or unintegrates them depending on the boolean #
186 XCOMM input parameter. #
189 XCOMM $1 = Integrate or not. TRUE=integrate. FALSE=unintegrate. #
191 XCOMM return codes: #
192 XCOMM 0 - work was done #
193 XCOMM 1 - no work done #
195 XCOMM ------------------------------------------------------------------#
196 function IntegrateUnintegrate
198 typeset torf=$1 srcs="" trgs="" fpats="" langs="" tpath="" spath="" rpath="" k="" languages="" lang=""
199 typeset cfgs="" srcabs="" trgabs=""
200 integer i=0 icons=0 types=1 help=2 appmgr=3
202 srcabs=$(GetAbsolutePath $APP_ROOT)
203 trgabs=$(GetAbsolutePath $APP_TARGET)
205 srcs[0]=$srcabs$ICONS$APP_LANG
206 srcs[1]=$srcabs$TYPES$APP_LANG
207 srcs[2]=$srcabs$HELP$APP_LANG
208 srcs[3]=$srcabs$APPMANAGER$APP_LANG
210 trgs[0]=$trgabs$ICONS$APP_LANG
211 trgs[1]=$trgabs$TYPES$APP_LANG
212 trgs[2]=$trgabs$HELP$APP_LANG
213 trgs[3]=$trgabs$APPMANAGER$APP_LANG
215 fpats[0]="$PIXMAP_FILES $BITMAP_FILES"
216 fpats[1]="$ACTIONDB_FILES"
217 fpats[2]="$HELPVOLUME_FILES_OLD $HELPVOLUME_FILES_NEW $HELPFAMILY_FILES"
218 fpats[3]="$APPMAN_FILES"
223 if [[ $APP_LANG = "" ]] then
224 languages=$(ls -d ${srcs[i]}/COMMENT_STAR 2>/dev/null)
226 for lang in $languages
228 baselang=$(basename $lang)
229 if [[ -d $lang ]] then
230 if [[ $torf = TRUE ]] then
231 if [[ ! -d ${trgs[i]}/$baselang ]] then
232 mkdir -p ${trgs[i]}/$baselang
235 LinkCfgs ${srcs[i]}/$baselang ${trgs[i]}/$baselang $torf ${fpats[i]}
236 if [[ $? != 0 ]] then
243 LinkCfgs ${srcs[i]} ${trgs[i]} $torf ${fpats[i]}
244 if [[ $? != 0 ]] then
252 XCOMM ------------------------------------------------------------------#
255 XCOMM Exit the program. #
258 XCOMM $1 = return code #
260 XCOMM ------------------------------------------------------------------#
264 echo "<<<<<<< END OF APPLICATION INTEGRATION >>>>>>>" >> $LOGFILE
266 echo "See $LOGFILE file for more information"
269 XCOMM ----<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>-----
270 XCOMM ----<<<<<<<<<<<.-------------------------.>>>>>>>>>>>-----
271 XCOMM ----<<<<<<<<<<<| |>>>>>>>>>>>-----
272 XCOMM ----<<<<<<<<<<<| START OF MAIN ROUTINE |>>>>>>>>>>>>-----
273 XCOMM ----<<<<<<<<<<<|_________________________|>>>>>>>>>>>-----
274 XCOMM ----<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>-----
276 XCOMM -------------------------------------------------------------------
277 XCOMM Initialize variables
278 XCOMM -------------------------------------------------------------------
285 APPMANAGER=/appmanager
288 APPCONFIG=/dt/appconfig
289 CONFIG_TOP=CDE_CONFIGURATION_TOP
290 DT=`basename $CONFIG_TOP`
291 APP_TARGET=${CONFIG_TOP%/$DT}$APPCONFIG
295 HELPVOLUME_FILES_OLD=*.hv
296 HELPVOLUME_FILES_NEW=*.sdl
297 HELPFAMILY_FILES=*.hf
299 FRONTPANEL_FILES=*.fp
303 LOGFILE=/tmp/dtappint.log
304 PATH=CDE_INSTALLATION_TOP/bin:/usr/bin
306 XCOMM -------------------------------------------------------------------
307 XCOMM Save application's name in variable.
308 XCOMM -------------------------------------------------------------------
311 XCOMM -------------------------------------------------------------------
312 XCOMM Check if root user. Exit if not.
313 XCOMM -------------------------------------------------------------------
317 if [[ $ID != root ]] then
318 echo "Error: Must be root user to run $0!" >&2
322 XCOMM -------------------------------------------------------------------
323 XCOMM Put prolog into log file.
324 XCOMM -------------------------------------------------------------------
325 echo "<<<<<<< START OF APPLICATION INTEGRATION >>>>>>>" > $LOGFILE
327 XCOMM -------------------------------------------------------------------
328 XCOMM Put the date of application integration into the log file.
329 XCOMM -------------------------------------------------------------------
330 echo $(date) >> $LOGFILE
332 XCOMM -------------------------------------------------------------------
333 XCOMM Put the command line into the log file.
334 XCOMM -------------------------------------------------------------------
335 echo "$SCRIPT_NAME $*" >> $LOGFILE
337 XCOMM -------------------------------------------------------------------
338 XCOMM Check if there are no command line arguments.
339 XCOMM If none, then display the command syntax.
340 XCOMM -------------------------------------------------------------------
346 XCOMM -------------------------------------------------------------------
347 XCOMM Parse the command line into flags and variables.
348 XCOMM -------------------------------------------------------------------
349 while getopts s:t:l:u flag
355 APP_TARGET="$OPTARG";;
365 XCOMM -------------------------------------------------------------------
366 XCOMM Check if application's root was specified and is valid.
367 XCOMM -------------------------------------------------------------------
368 if [[ $sFLAG = 0 ]] then
369 echo "Error: Did not specify -s option!" >&2
372 if [[ ! -d $APP_ROOT ]] then
374 echo "Error: $APP_PATH is not a directory!" >&2
377 if [[ ! -r $APP_ROOT ]] || [[ ! -x $APP_ROOT ]] then
379 echo "Error: Can not read $APP_PATH directory!" >&2
384 if [[ ${APP_ROOT%%/COMMENT_STAR} != "" ]] then
385 APP_ROOT=$(pwd)/$APP_ROOT
388 XCOMM -------------------------------------------------------------------
389 XCOMM If target is specified, do some sanity checks on this path.
390 XCOMM -------------------------------------------------------------------
391 if [[ $tFLAG = 1 ]] then
392 if [[ ! -d $APP_TARGET ]] then
394 echo "Error: $APP_PATH is not a directory!" >&2
397 if [[ ! -r $APP_TARGET ]] || [[ ! -x $APP_TARGET ]] then
399 echo "Error: Can not read $APP_PATH directory!" >&2
403 if [[ ${APP_TARGET%%/COMMENT_STAR} != "" ]] then
404 APP_TARGET=$(pwd)/$APP_TARGET
408 XCOMM -------------------------------------------------------------------
409 XCOMM Set up variables.
410 XCOMM -------------------------------------------------------------------
411 APP_ROOT=$APP_ROOT$APPCONFIG
413 if [[ $APP_LANG != "" ]] then
417 XCOMM -------------------------------------------------------------------
418 XCOMM Unintegrate the application by un-doing the integration steps.
419 XCOMM -------------------------------------------------------------------
420 if [[ $uFLAG = 1 ]] then
421 IntegrateUnintegrate FALSE
423 echo "Unintegration Complete"
425 echo "No files to unintegrate"
430 XCOMM -------------------------------------------------------------------
431 XCOMM See if these directories exist. If they don't, then create them.
432 XCOMM -------------------------------------------------------------------
433 for i in $APP_TARGET$ICONS$APP_LANG $APP_TARGET$TYPES$APP_LANG $APP_TARGET$APPMANAGER$APP_LANG $APP_TARGET$HELP$APP_LANG
435 if [[ ! -d $i ]] then
440 XCOMM -------------------------------------------------------------------
441 XCOMM Determine which awk to use.
442 XCOMM -------------------------------------------------------------------
443 $(type nawk > /dev/null 2>&1)
444 if [[ $? != 0 ]] then
450 XCOMM -------------------------------------------------------------------
451 XCOMM Integrate the application.
452 XCOMM -------------------------------------------------------------------
453 IntegrateUnintegrate TRUE
455 echo "Integration Complete"
457 echo "No files to integrate"
460 XCOMM -------------------------------------------------------------------
462 XCOMM -------------------------------------------------------------------