Packaging for LyX 1.3.6 on Windows.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_3_X@10001 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2005-06-06 12:59:55 +00:00
parent 51c86b27c0
commit 552efbcd59
3 changed files with 327 additions and 0 deletions

View File

@ -0,0 +1,116 @@
Packaging LyX 1.3.6 for Windows
===============================
Preparing the way
=================
The very first thing to do on the way to creating a LyX/Win package is
to build the sources and install them somewhere accessible. (I've been
using PREFIX='/J/Programs/LyX'.)
Thereafter, the contents of this tree must be manipulated a
little. I've written a little script, package_lyxwin.sh, to automate
the process:
* Copy the DLLs qt-mt3.dll, libiconv-2.dll, mingwm10.dll to the
$PREFIX/bin/ directory. These are needed by the LyX executable.
* Strip the binaries in $PREFIX/bin/ of all debugging info.
* Copy dt2dv.exe and dv2dt.exe to $PREFIX/bin/ and clean_dvi.py to
$PREFIX/Resources/lyx/scripts/ These are needed to enable dvips, yap
et al. to cope with "file names with spaces".
* Add formats and converters to the $PREFIX/Resources/lyx/configure
script so that users can use the clean_dvi script transparently.
* Remove all stuff generated by running configure. It makes sense on
your machine only, not for whoever is installing LyX. Specifically
xfonts/fonts.dir, xfonts/fonts.scale, doc/LaTeXConfig.lyx,
lyxrc.defaults, packages.lst and textclass.lst
should all be removed.
Creating the LyX icons
======================
All icons are to be found in sub-directory icons/.
The LyX icons, lyx_32x32.ico and lyx_doc_32x32.ico, are based on .svg
files written and realease into the public domain by Andy Fitzsimon:
http://openclipart.org/clipart/computer/icons/etiquette-theme/aps/LyX.svg
http://openclipart.org/clipart/computer/icons/etiquette-theme/mimetype.svg
lyx.svg is Andy's original.
lyx_doc.svg is a merger of LyX.svg with mimetype.svg
Working on a linux box, I used sodipodi (http://www.sodipodi.com/) to
create the .svg file and to export these vector graphics images to
32x32 pixel bitmaps (.png format). Thereafter I used gimp
(http://www.gimp.org/) to generate reduced color depth versions (16,
256 colors).
Finally, on a WindowsXP machine, I used IconXP
(http://www.aha-soft.com/iconxp/) to build the .ico files from these
.png files at differing resolutions.
Adding the LyX icons to lyx.exe
===============================
********************************************************************
NOTE: Run 'strip' on lyx.exe before adding any images to it. 'strip'
will not work after images have been added.
$ strip lyx.exe
j:\mingw\bin\strip.exe: lyx.exe: File in wrong format
********************************************************************
Windows executables can store various "resources", including images. I
used ResourceHacker (http://rpi.net.au/~ajohnson/resourcehacker) to
add the LyX icons to the .exe file.
Fire up ResHacker.exe and load lyx.exe
File>Open... lyx.exe
Action>Add a new Resource...
Open file with resource ... lyx_32x32.ico
Resource Type will be set to "ICONGROUP"
Set Resource Name to "1". (No inverted commas.)
Add Resource
The icon will be shown in the main Resource Hacker window under
Icon Group>1>0 and as Icon>5[0-3].
Repeat for lyx_doc_32x32.ico, setting the Resource Name to "2".
Save the modified lyx.exe. Resource Hacker will copy the original to
lyx_original.exe. Remove it.
Building the LyX installer
==========================
At this point my J:\Programs\LyX tree now contains everything that is
to be released as a LyX/Win package. All that remains to do is to
generate a Windows installer for it. I've written a script for NSIS
(http://nsis.sourceforge.net/) to compile into an installer.
You'll need to compile and install lyx_path_prefix.dll. From the
comments in lyx_path_prefix.C:
/* Compile the code with
*
* g++ -I/c/Program\ Files/NSIS/Contrib -Wall -shared \
* lyx_path_prefix.c -o lyx_path_prefix.dll
*
* Move resulting .dll to /c/Program\ Files/NSIS/Plugins
*/
Thereafter, you'll be able to build the installer itself:
$ <PATH to>/makensis lyx_installer.nsi
creating lyx_setup_136.exe ready to ship.
END README

View File

@ -0,0 +1,100 @@
#! /usr/bin/env python
'''
file clean_dvi.py
This file is part of LyX, the document processor.
Licence details can be found in the file COPYING
or at http://www.lyx.org/about/licence.php3
author Angus Leeming
Full author contact details are available in the file CREDITS
or at http://www.lyx.org/about/credits.php
Usage:
python clean_dvi.py infile.dvi outfile.dvi
clean_dvi modifies the input .dvi file so that
dvips and yap (a dvi viewer on Windows) can find
any embedded PostScript files whose names are protected
with "-quotes.
It works by:
1 translating the machine readable .dvi file to human
readable .dtl form,
2 manipulating any references to external files
3 translating the .dtl file back to .dvi format.
It requires dv2dt and dt2dv from the DTL dviware package
http://www.ctan.org/tex-archive/dviware/dtl/
'''
import os, re, sys
def usage(prog_name):
return 'Usage: %s in.dvi out.dvi\n' \
% os.path.basename(prog_name)
def warning(message):
sys.stderr.write(message + '\n')
def error(message):
sys.stderr.write(message + '\n')
sys.exit(1)
def manipulated_dtl(data):
psfile_re = re.compile(r'(.*PSfile=")(.*)(" llx=.*)')
lines = data.split('\n')
for i in range(len(lines)):
line = lines[i]
match = psfile_re.search(line)
if match != None:
file = match.group(2).replace('"', '')
lines[i] = '%s%s%s' \
% ( match.group(1), file, match.group(3) )
return '\n'.join(lines)
def main(argv):
# First establish that the expected information has
# been input on the command line and whether the
# required executables exist.
if len(argv) != 3:
error(usage(argv[0]))
infile = argv[1]
outfile = argv[2]
if not os.path.exists(infile):
error('Unable to read "%s"\n' % infile)
# Convert the input .dvi file to .dtl format.
dv2dt_call = 'dv2dt "%s"' % infile
dv2dt_stdin, dv2dt_stdout, dv2dt_stderr = \
os.popen3(dv2dt_call, 't')
dv2dt_stdin.close()
dv2dt_data = dv2dt_stdout.read()
dv2dt_status = dv2dt_stdout.close()
if dv2dt_status != None or len(dv2dt_data) == 0:
dv2dt_err = dv2dt_stderr.read()
error("Failed: %s\n%s\n" % ( dv2dt_call, dv2dt_err) )
# Manipulate the .dtl file.
dtl_data = manipulated_dtl(dv2dt_data)
if dtl_data == None:
error("Failed to manipulate the dtl file")
# Convert this .dtl file back to .dvi format.
dt2dv_call = 'dt2dv -si "%s"' % outfile
dt2dv_stdin = os.popen(dt2dv_call, 'w')
dt2dv_stdin.write(dtl_data)
if __name__ == "__main__":
main(sys.argv)

View File

@ -0,0 +1,111 @@
#! /bin/sh
# This script aims to do averything necessary to automate the packaging
# of LyX/Win ready for an Windows Installer to be built.
# It copies these files into the appropriate places in the LyX tree.
# qt-mt3.dll
# libiconv-2.dll
# mingw10.dll
# clean_dvi.py
# dv2dt.exe
# dt2dv.exe
# It strips the executables.
# It adds formats and converters to the Resources/lyx/configure script to
# ensure that the generated .dvi file is usable.
# It removes all stuff generated by running configure:
# xfonts/
# doc/LaTeXConfig.lyx
# lyxrc.defaults
# packages.lst
# textclass.lst
# The installee should regenerate them by running configure on his machine.
QT_DLL="$HOME/qt3/bin/qt-mt3.dll"
LIBICONV_DLL="/j/MinGW/bin/libiconv-2.dll"
MINGW_DLL="/j/MinGW/bin/mingwm10.dll"
CLEAN_DVI_PY="clean_dvi.py"
DTL_DIR=dtl
DT2DV="$DTL_DIR/dt2dv.exe"
DV2DT="$DTL_DIR/dv2dt.exe"
LYX_INSTALL_DIR="/j/Programs/LyX"
# Change this to 'mv -f' when you are confident that
# the various sed scripts are working correctly.
MV='mv -f'
windows_packaging()
{
# Install the necessary .dlls and clean_dvi stuff.
for file in "${QT_DLL}" "${LIBICONV_DLL}" "${MINGW_DLL}" "${DT2DV}" "${DV2DT}"
do
cp "${file}" "$LYX_INSTALL_DIR"/bin/. || {
echo "Failed to copy ${file} to the LyX package" >&2
exit 1
}
done
cp "${CLEAN_DVI_PY}" "$LYX_INSTALL_DIR"/Resources/lyx/scripts/. || {
echo "Failed to copy ${CLEAN_DVI_PY} to the LyX package" >&2
exit 1
}
# Strip the executables
(
cd "${LYX_INSTALL_DIR}/bin"
for file in *.exe
do
strip $file
done
)
# Modify the configure script,
# * add a dvi2 format
# * change the latex->dvi converter to latex->dvi2
# * add a dvi2->dvi converter
# * fix the generated chkconfig.sed so that it works with versions of
# sed that get confused by sed scripts with DOS line endings.
TMP=tmp.$$
CONFIGURE="${LYX_INSTALL_DIR}"/Resources/lyx/configure
# Do this to make it easy to compare the before and after files.
dos2unix "${CONFIGURE}"
sed '
# (Note that this sed script contains TAB characters.)
# Append the dvi2 format after the dvi format.
/^ *\\\\Format[ ]\{1,\}dvi[ ]\{1,\}/a\
\\\\Format dvi2 dvi DirtyDVI ""
# Change the latex->dvi converter to latex->dvi2
# and append the dvi2->dvi converter
/^ *\\\\converter[ ]\{1,\}latex[ ]\{1,\}dvi[ ]\{1,\}/{
s/dvi/dvi2/
a\
\\\\converter dvi2 dvi "python \\\$\\\$s/scripts/clean_dvi.py \\\$\\\$i \\\$\\\$o" ""
}
' "${CONFIGURE}" > "${TMP}"
cmp -s "${CONFIGURE}" "${TMP}" || {
diff -u "${CONFIGURE}" "${TMP}"
${MV} "${TMP}" "${CONFIGURE}"
}
rm -f "${TMP}"
# Strip the executables
(
cd "${LYX_INSTALL_DIR}/Resources/lyx"
rm -rf xfonts
for file in doc/LaTeXConfig.lyx lyxrc.defaults packages.lst textclass.lst
do
rm -f $file
done
)
}
windows_packaging || exit 1
# The end