VirtualBox

source: vbox/trunk/doc/manual/dita-ot-copy-exec.sh@ 99044

Last change on this file since 99044 was 99044, checked in by vboxsync, 21 months ago

manual/Makefile.kmk: Copy the dita-ot for each invocation (using new script dita-ot-copy-exec.sh), but try to hardlink the files where possible. Also added a hack to prevent hhc.exe from being searched for and ran during the htmlhelp/qhelp processing. [fix] bugref:10302

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1#!/usr/bin/env kmk_ash
2# $Id: dita-ot-copy-exec.sh 99044 2023-03-19 02:51:49Z vboxsync $
3## @file
4# Helper Script for copying the DITA-OT toolkit from $1 to $2,
5# run the following command line, nuke $2.
6#
7# DITA-OT-1.8.5 updates around 40 files everytime it is started in an manner
8# that will cause race conditions when starting multiple dost.jar instances
9# concurrently. So, we work around that by running each job of a unqiue and
10# temporary copy. Extra effort is taken to using hardlinking when possible
11# and to reduce the number of files and directory we copy.
12#
13
14#
15# Copyright (C) 2023 Oracle and/or its affiliates.
16#
17# This file is part of VirtualBox base platform packages, as
18# available from https://www.virtualbox.org.
19#
20# This program is free software; you can redistribute it and/or
21# modify it under the terms of the GNU General Public License
22# as published by the Free Software Foundation, in version 3 of the
23# License.
24#
25# This program is distributed in the hope that it will be useful, but
26# WITHOUT ANY WARRANTY; without even the implied warranty of
27# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28# General Public License for more details.
29#
30# You should have received a copy of the GNU General Public License
31# along with this program; if not, see <https://www.gnu.org/licenses>.
32#
33# SPDX-License-Identifier: GPL-3.0-only
34#
35
36#
37# Some constants.
38#
39MY_INSTALL="kmk_install"
40MY_MKDIR="kmk_mkdir"
41MY_RM="kmk_rm"
42MY_SED="kmk_sed"
43MY_CP="kmk_cp"
44
45# Debug
46MY_DEBUG_INSTALL="-v"
47MY_DEBUG_INSTALL=""
48
49MY_DEBUG_MKDIR="-v"
50MY_DEBUG_MKDIR=""
51
52MY_DEBUG_RM="-v"
53MY_DEBUG_RM=""
54
55#
56# Pop off the source and target directories from the input arguments.
57# We're not trying to be very userfriendly here, just reasonably safe.
58#
59if test $# -lt 5; then
60 echo "syntax error: too few arguments" 1>&2;
61 exit 2;
62fi
63MY_SRCDIR="$1"
64MY_DSTDIR="$2"
65if test "$3" != "--"; then
66 echo "syntax error: Expected '--' as the 3rd parameter, got: $3" 1>&2;
67 exit 2;
68fi
69shift 3
70if ! test -d "${MY_SRCDIR}"; then
71 echo "error: Source directory does not exists or is not a directory: ${MY_SRCDIR}" 1>&2;
72 exit 1;
73fi
74if test -e "${MY_DSTDIR}"; then
75 echo "error: Destination directory already exists: ${MY_DSTDIR}" 1>&2;
76 exit 1;
77fi
78
79#
80# Helper.
81#
82CopyTree()
83{
84 MY_SRCTREE="$1"
85 MY_DSTTREE="$2"
86
87 # Gather files and directories.
88 cd "${MY_SRCTREE}"
89 MY_DIRS=""
90 MY_DIRS_PAIRS=""
91 MY_FILES=""
92 for MY_FILE in *;
93 do
94 if test -d "${MY_SRCTREE}/${MY_FILE}"; then
95 case "${MY_SRCTREE}/${MY_FILE}" in
96 *\ *)
97 echo "Unexpected space in dir/subdir: ${MY_SRCTREE}/${MY_FILE}" 1>&2;
98 exit 1
99 ;;
100 esac
101 MY_DIRS="${MY_DIRS} ${MY_FILE}"
102 MY_DIRS_PAIRS="${MY_DIRS_PAIRS} ${MY_SRCTREE}/${MY_FILE} ${MY_DSTTREE}/${MY_FILE}"
103 elif test -f "${MY_SRCTREE}/${MY_FILE}"; then
104 case "${MY_SRCTREE}/${MY_FILE}" in
105 *\ *)
106 echo "Unexpected space in dir/filename: ${MY_SRCTREE}/${MY_FILE}" 1>&2;
107 exit 1
108 ;;
109
110 *org.dita.dost.platform/plugin.properties)
111 ;;
112 *_template.xml)
113 MY_FILES="${MY_FILES} ${MY_FILE}"
114 MY_TEMPLATED_FILES="${MY_TEMPLATED_FILES} ${MY_DSTTREE}/${MY_FILE%_template.xml}.xml"
115 ;;
116 *_template.xsl)
117 MY_FILES="${MY_FILES} ${MY_FILE}"
118 MY_TEMPLATED_FILES="${MY_TEMPLATED_FILES} ${MY_DSTTREE}/${MY_FILE%_template.xsl}.xsl"
119 ;;
120 *)
121 MY_FILES="${MY_FILES} ${MY_FILE}"
122 ;;
123 esac
124 else
125 echo "Unexpected file type: ${MY_SRCTREE}/${MY_FILE}" 1>&2;
126 exit 1
127 fi
128 done
129
130 # Install all the files in one go.
131 if test -n "${MY_FILES}"; then
132 "${MY_INSTALL}" ${MY_DEBUG_INSTALL} --hard-link-files-when-possible -m644 -- ${MY_FILES} "${MY_DSTTREE}/"
133 fi
134
135 # Create all subdirs and recurse into each.
136 if test -n "${MY_DIRS}"; then
137 cd "${MY_DSTTREE}"
138 "${MY_MKDIR}" -p ${MY_DEBUG_MKDIR} -- ${MY_DIRS}
139
140 # Now transfer MY_DIRS_PAIRS to the argument list, so they're preseved across recursive calls.
141 # (the local command/keyword is busted in current binaries, though fixed in kBuild svn.)
142 set -- ${MY_DIRS_PAIRS};
143 while test "$#" -ge 2;
144 do
145 CopyTree "${1}" "${2}"
146 shift 2
147 done
148 fi
149}
150
151#
152# Copy the files over.
153#
154set -e
155MY_SAVED_CWD=`pwd`
156"${MY_MKDIR}" -p ${MY_DEBUG_MKDIR} -- "${MY_DSTDIR}"
157
158# Selected root files.
159"${MY_INSTALL}" ${MY_DEBUG_INSTALL} --hard-link-files-when-possible -m644 -- \
160 "${MY_SRCDIR}/build_template.xml" \
161 "${MY_SRCDIR}/catalog-dita.txt" \
162 "${MY_SRCDIR}/catalog-dita_template.xml" \
163 "${MY_SRCDIR}/integrator.properties" \
164 "${MY_SRCDIR}/integrator.xml" \
165 "${MY_DSTDIR}/"
166
167# Selected directory trees.
168MY_TEMPLATED_FILES=""
169for MY_SUBDIR in css dtd lib plugins resource schema tools xsl;
170do
171 "${MY_MKDIR}" -p ${MY_DEBUG_MKDIR} -- "${MY_DSTDIR}/${MY_SUBDIR}"
172 CopyTree "${MY_SRCDIR}/${MY_SUBDIR}" "${MY_DSTDIR}/${MY_SUBDIR}"
173done
174
175# Now remove all files that has a _template.xml/xsl variant, just to ensure
176# that if hardlinked the copy in the tree won't be modified.
177if test -n "${MY_TEMPLATED_FILES}"; then
178 "${MY_RM}" -f ${MY_DEBUG_RM} -- ${MY_TEMPLATED_FILES}
179fi
180
181cd "${MY_SAVED_CWD}"
182set +e
183
184#
185# Execute the command.
186#
187"$@"
188MY_EXITCODE=$?
189
190#
191# Cleanup and exit.
192#
193#"${MY_RM}" -Rf ${MY_DEBUG_RM} -- "${MY_DSTDIR}"
194exit ${MY_EXITCODE}
195
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette