1 | #!/bin/sh |
---|
2 | |
---|
3 | # Directories |
---|
4 | prefix=@prefix@ |
---|
5 | datarootdir=@datarootdir@ |
---|
6 | datadir=@datadir@ |
---|
7 | templatedir=@datadir@/vine-manual-skel/template |
---|
8 | CWD=$PWD |
---|
9 | |
---|
10 | # My name |
---|
11 | MYNAME=`basename $0` |
---|
12 | |
---|
13 | # print usage |
---|
14 | print_usage() |
---|
15 | { |
---|
16 | cat << EOM |
---|
17 | ${MYNAME} Initialize package of manual for Vine Linux. |
---|
18 | |
---|
19 | Usage: ${MYNAME} [OPTION]... PACAGE-NAME |
---|
20 | |
---|
21 | -d, --docdir install directory name (base name) [PACKAGE-NAME] |
---|
22 | -v version of new manual [1.0] |
---|
23 | --help display help and exit |
---|
24 | --version output version information and exit |
---|
25 | EOM |
---|
26 | } |
---|
27 | |
---|
28 | # print version |
---|
29 | print_version() |
---|
30 | { |
---|
31 | cat << EOM |
---|
32 | ${MYNAME} @VERSION@ |
---|
33 | |
---|
34 | Copyright (C) 2011 Project Vine. |
---|
35 | This is free software; see the source for copying conditions. There is NO |
---|
36 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
---|
37 | |
---|
38 | Written by Yasumichi Akahoshi <yasumichi@vinelinux.org> |
---|
39 | EOM |
---|
40 | } |
---|
41 | |
---|
42 | # |
---|
43 | # parse arguments. |
---|
44 | # |
---|
45 | if [ -z "$*" ]; then |
---|
46 | print_usage |
---|
47 | exit 1 |
---|
48 | fi |
---|
49 | |
---|
50 | while [ ! -z "$*" ]; do |
---|
51 | case $1 in |
---|
52 | -d|--docdirbase) |
---|
53 | DOCDIR=$2 |
---|
54 | shift |
---|
55 | ;; |
---|
56 | -v) |
---|
57 | DVERSION=$2 |
---|
58 | shift |
---|
59 | ;; |
---|
60 | --help) |
---|
61 | print_usage |
---|
62 | exit |
---|
63 | ;; |
---|
64 | --version) |
---|
65 | print_version |
---|
66 | exit |
---|
67 | ;; |
---|
68 | *) |
---|
69 | if [ -z "${TARGET}" ]; then |
---|
70 | TARGET=$1 |
---|
71 | else |
---|
72 | echo "Too many targets." >&2 |
---|
73 | echo >&2 |
---|
74 | print_usage |
---|
75 | exit 1 |
---|
76 | fi |
---|
77 | ;; |
---|
78 | esac |
---|
79 | shift |
---|
80 | done |
---|
81 | |
---|
82 | # |
---|
83 | # main |
---|
84 | # |
---|
85 | |
---|
86 | TARGETDIR=${CWD}/${TARGET} |
---|
87 | YEAR=`date +%Y` |
---|
88 | SERIESID=`scrollkeeper-gen-seriesid` |
---|
89 | if [ -z "${DOCDIR}" ];then |
---|
90 | DOCDIR=${TARGET} |
---|
91 | fi |
---|
92 | if [ -z "${DVERSION}" ];then |
---|
93 | DVERSION=1.0 |
---|
94 | fi |
---|
95 | |
---|
96 | # make new package disrectory |
---|
97 | if [ -d ${TARGETDIR} -o -f ${TARGETDIR} ];then |
---|
98 | echo "Error: ${TARGETDIR} is already exists." >&2 |
---|
99 | exit 1 |
---|
100 | fi |
---|
101 | mkdir ${TARGETDIR} |
---|
102 | |
---|
103 | # copy files from template |
---|
104 | for file in `find ${templatedir} | sed -e "s|${templatedir}||"` |
---|
105 | do |
---|
106 | if [ -d ${templatedir}${file} ];then |
---|
107 | mkdir ${TARGETDIR}${file} |
---|
108 | elif [ "${file##*.}" = "skel" ];then |
---|
109 | DESTFILE=`dirname ${file}`/`basename ${file} .skel | sed -e "s/package/${TARGET}/"` |
---|
110 | sed -e "s|\@PACKAGE\@|${TARGET}|g" -e "s|\@PACKAGEDIR\@|${DOCDIR}|g" \ |
---|
111 | -e "s|\@DVERSION\@|${DVERSION}|g" -e "s|\@YEAR\@|${YEAR}|g" \ |
---|
112 | -e "s|\@SERIESID\@|${SERIESID}|g" \ |
---|
113 | ${templatedir}${file} > ${TARGETDIR}/${DESTFILE} |
---|
114 | else |
---|
115 | DESTFILE=`echo ${file} | sed -e "s/package/${TARGET}/"` |
---|
116 | cp ${templatedir}${file} ${TARGETDIR}${file} |
---|
117 | fi |
---|
118 | done |
---|
119 | |
---|
120 | # autotoolize |
---|
121 | cd ${TARGETDIR} |
---|
122 | aclocal |
---|
123 | automake -c -a |
---|
124 | autoconf |
---|
125 | |
---|
126 | rm -rf ${TARGETDIR}/autom4te.cache |
---|
127 | |
---|