File: jh_installjavadoc

package info (click to toggle)
javatools 0.48%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 416 kB
  • ctags: 72
  • sloc: sh: 1,515; perl: 930; makefile: 35
file content (121 lines) | stat: -rwxr-xr-x 2,982 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash --

set -e

. /usr/share/javahelper/jh_lib.sh

syntax()
{
   echo -e "Usage: jh_installjavadoc [options] [src] [target]"
   echo -e "Options:"
   echo -e "\t-h --help: show this text"
   echo -e "\t-V --version: show the version"
   echo -e "\t-i --indep: act on all Arch: all packages"
   echo -e "\t-a --arch: act on all Arch-specific packages"
   echo -e "\t-s --same-arch: alias of --arch for compatibility with debhelper"
   echo -e "\t-p<package> --package=<package>: package to act on (default=all)"  
   echo -e "\t-P<packagedir> --tmpdir=<package>: package directory (default=\$CWD/debian/package)"  
   echo -e "\t-v --verbose: show more information while running"
   echo -e "\t-n --no-act: don't actually do anything, just print the results"
   echo -e "\t-A<author> --author=<author>: Author of the javadoc"  
   exit 1
}

ARGS="A author i indep a arch s same-arch p package P tmpdir v verbose n no-act" parseargs "$@"

dh_testdir

VERBOSE="`getarg v verbose`"
AUTHOR="`getarg A author`"

function installjavadoc() 
{

	package="$1"
	src="$2"
	target="$3"

	if [ -z "$AUTHOR" ]; then
		AUTHOR="The authors of $package"
	fi
	if [ -z "$src" ]; then
		echo "Error: trying to install from empty source"
		exit 1
	fi
	if [ ! -d "$src" ]; then
		echo "Javadoc source $src does not exist or is not a directory, skipping"
		return
	fi

	if [ -z "$target" ]; then
		target="debian/$package/usr/share/doc/$package/api"
		docbasepath="/usr/share/doc/$package/api"
	else
		docbasepath="/$target"
		target="debian/$package/$target"
	fi

	if [ -n "$VERBOSE" ]; then
		echo "Installing javadoc from $src into package $package"
	fi

	if [ -n "`getarg n no-act`" ]; then
		echo mkdir -p "`dirname "$target"`"
		echo cp -r "$src" "$target"
		echo cat \> debian/$package.doc-base.javadoc
	else
		cat > debian/$package.doc-base.javadoc <<END
Document: $package
Title: API JavaDoc for $package
Author: $AUTHOR
Abstract: This is the API JavaDoc for $package
Section: Programming/Java

Format: HTML
Index: $docbasepath
Files: $docbasepath/*.html
END
	echo "debian/$package.doc-base.javadoc" >> debian/.javahelper_clean

		mkdir -p "`dirname "$target"`"
		cp -r "$src" "$target"
	fi
}


if [ "$ARGC" != "0" ] ; then
   
   p="`firstpackage`"    
	installjavadoc "$p" "${ARGV[0]}" "${ARGV[1]}"
   exit 0
fi

for p in `findpackages`; do

   PACKAGEDIR="`getarg P tmpdir`"
   if [ -z "$PACKAGEDIR" ]; then
      PACKAGEDIR="`pwd`/debian/$p"
   else
      PACKAGEDIR=`readlink -f $PACKAGEDIR`
   fi

   DIR=
   if [ -f debian/$p.javadoc ]; then
      DIR="`awk '{print $1}' debian/$p.javadoc`"
      TARGET="`awk '{print $2}' debian/$p.javadoc`"
   elif [ -f debian/javadoc ]; then
      DIR="`awk '{print $1}' debian/javadoc`"
      TARGET="`awk '{print $2}' debian/javadoc`"
	else
      continue
   fi

	if [ "$DIR" = "internal" ] && [ -d debian/_jh_build.javadoc/api ]; then
		DIR=debian/_jh_build.javadoc/api
	fi

   installjavadoc "$p" "$DIR" "$TARGET"
   unset PACKAGEDIR

done