[mingw-nsiswrapper: 2/20] Initial import.
Kalev Lember
kalev at fedoraproject.org
Wed Mar 7 16:08:12 UTC 2012
commit 72610be1c8542a7dc756ebae42419021817b184d
Author: Richard W.M. Jones <rjones at fedoraproject.org>
Date: Sat Feb 21 17:16:19 2009 +0000
Initial import.
COPYING | 339 ++++++++++++++++++
README | 52 +++
import.log | 1 +
mingw32-nsiswrapper.spec | 72 ++++
nsiswrapper.pl | 853 ++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 1317 insertions(+), 0 deletions(-)
---
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..e77696a
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/README b/README
new file mode 100644
index 0000000..c3d3e21
--- /dev/null
+++ b/README
@@ -0,0 +1,52 @@
+NSISWrapper is a helper program for making Windows installers,
+particularly when you are cross-compiling from Unix.
+
+NSIS (a separate package) is a program for building Windows
+installers. This wrapper simply makes it easier to generate the
+installer script that NSIS needs.
+
+You can get NSIS itself from http://nsis.sourceforge.net/ but
+generally speaking this wrapper is only useful when cross-compiling
+(run from a Linux machine) in which case you should use the Fedora or
+Debian version of NSIS from:
+
+ Fedora: http://fedoraproject.org/wiki/MinGW
+ Debian: http://packages.debian.org/unstable/devel/nsis
+
+----------------------------------------------------------------------
+
+NSISWrapper requires a reasonably recent version of Perl. You will
+also need to install the MinGW cross-compiler binutils
+(mingw32-binutils package).
+
+----------------------------------------------------------------------
+
+For usage instructions, please refer to the manual page nsiswrapper(1).
+If for some reason the manual page isn't installed then you can do
+this instead:
+
+ nsiswrapper --man
+
+For help with NSIS itself, please refer to the NSIS website.
+
+You can also get quick command line help by doing:
+
+ nsiswrapper --help
+
+----------------------------------------------------------------------
+
+Copyright (C) 2008 Red Hat Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/import.log b/import.log
new file mode 100644
index 0000000..f8c24ab
--- /dev/null
+++ b/import.log
@@ -0,0 +1 @@
+mingw32-nsiswrapper-3-3_fc11:HEAD:mingw32-nsiswrapper-3-3.fc11.src.rpm:1235236490
diff --git a/mingw32-nsiswrapper.spec b/mingw32-nsiswrapper.spec
new file mode 100644
index 0000000..3d9d514
--- /dev/null
+++ b/mingw32-nsiswrapper.spec
@@ -0,0 +1,72 @@
+Name: mingw32-nsiswrapper
+Version: 3
+Release: 3%{?dist}
+Summary: Helper program for making NSIS Windows installers
+
+License: GPLv2+
+Group: Development/Libraries
+URL: http://fedoraproject.org/wiki/MinGW
+Source0: nsiswrapper.pl
+Source1: README
+Source2: COPYING
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildArch: noarch
+
+BuildRequires: perl
+
+Requires: mingw32-nsis
+
+
+%description
+NSISWrapper is a helper program for making Windows installers,
+particularly when you are cross-compiling from Unix.
+
+NSIS (a separate package) is a program for building Windows
+installers. This wrapper simply makes it easier to generate the
+installer script that NSIS needs.
+
+
+%prep
+# empty
+
+
+%build
+# empty
+
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+mkdir -p $RPM_BUILD_ROOT%{_bindir}
+install -m 0755 %{SOURCE0} $RPM_BUILD_ROOT%{_bindir}/nsiswrapper
+
+# Install documentation (manually).
+mkdir -p $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
+install -m 0644 %{SOURCE1} %{SOURCE2} \
+ $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
+
+# Build the manpage from the source.
+mkdir -p $RPM_BUILD_ROOT%{_mandir}/man1
+pod2man -c "NSIS" -r "%{name}-%{version}" %{SOURCE0} \
+ > $RPM_BUILD_ROOT%{_mandir}/man1/nsiswrapper.1
+
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+
+%files
+%defattr(-,root,root)
+%doc %{_docdir}/%{name}-%{version}/COPYING
+%doc %{_docdir}/%{name}-%{version}/README
+%{_bindir}/nsiswrapper
+%{_mandir}/man1/nsiswrapper.1*
+
+
+%changelog
+* Fri Feb 20 2009 Richard W.M. Jones <rjones at redhat.com> - 3-3
+- Rebuild for mingw32-gcc 4.4
+
+* Thu Oct 16 2008 Richard W.M. Jones <rjones at redhat.com> - 3-2
+- Initial RPM release.
diff --git a/nsiswrapper.pl b/nsiswrapper.pl
new file mode 100755
index 0000000..af466a8
--- /dev/null
+++ b/nsiswrapper.pl
@@ -0,0 +1,853 @@
+#!/usr/bin/perl -w
+#
+# NSISWrapper - a helper program for making Windows installers.
+# Copyright (C) 2008 Red Hat Inc.
+# Written by Richard W.M. Jones <rjones at redhat.com>,
+# http://fedoraproject.org/wiki/MinGW
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or (at
+# your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+use strict;
+use Getopt::Long;
+use Pod::Usage;
+use File::Temp qw/tempfile/;
+#use Data::Dumper;
+
+=pod
+
+=head1 NAME
+
+nsiswrapper - Helper program for making NSIS Windows installers
+
+=head1 SYNOPSIS
+
+ nsiswrapper [options] [roots...]
+
+ nsiswrapper myprogram.exe anotherprog.exe docs/ > script.nsis
+
+ nsiswrapper --run myprogram.exe anotherprog.exe docs/
+
+=head1 DESCRIPTION
+
+nsiswrapper is a helper program for making it easier to create Windows
+installers in a cross-compiler environment. It still requires NSIS (a
+Windows installer generator) but cuts out the tedium of writing the
+NSIS command script, and can even invoke NSIS automatically to
+generate a final Windows executable.
+
+The general way to use it is to list out some files that you want
+packaged. For example:
+
+ nsiswrapper myprogram.exe
+
+This will search for C<myprogram.exe> and any libraries (C<*.dll>)
+that it depends upon, and then it will print out an NSIS script.
+
+If you want to have it run C<makensis> as well (to automatically
+create a Windows installer) then do:
+
+ nsiswrapper --run myprogram.exe
+
+which will generate C<installer.exe> output file that contains
+C<myprogram.exe> plus any dependencies.
+
+You can list other files and directories that you want to have
+contained in your installer. For example:
+
+ nsiswrapper myprogram.exe anotherprog.exe docs/*.html
+
+There are many other command line options which control aspects of the
+NSIS command script (and hence, the final installer), such as:
+
+=over 4
+
+=item *
+
+The name of the final installer.
+
+=item *
+
+Desktop shortcuts and menu items.
+
+=item *
+
+License files.
+
+=back
+
+It's a good idea to examine the NSIS command script, to check that
+nsiswrapper is including all the right dependencies.
+
+=head1 ROOTS (FILES AND DIRECTORIES)
+
+Each parameter should refer to a file or directory which is to be
+included in the installer.
+
+These are known as "roots" because we also automatically add any
+dependencies to the list of files. Thus if a Windows executable
+requires any DLLs, those are added automatically. DLLs are searched
+for on the current C<$PATH> (environment variable).
+
+We choose the install location by removing any common prefix from the
+names of roots, which generally ensures that the original directory
+structure is preserved. Thus for example if the original roots (and
+any dependencies) are:
+
+ /usr/i686-pc-mingw32/sys-root/mingw/bin/program.exe
+ /usr/i686-pc-mingw32/sys-root/mingw/bin/library.dll
+ /usr/i686-pc-mingw32/sys-root/mingw/etc/config
+
+then the install directory will look like this:
+
+ $INSTDIR/bin/program.exe
+ $INSTDIR/bin/library.dll
+ $INSTDIR/etc/config
+
+(C<$INSTDIR> is the installation directory chosen by the user at
+install time).
+
+You can also specify the install location (relative to C<$INSTDIR>) by
+adding roots of the form:
+
+ source=destination
+
+for example:
+
+ /usr/i686-pc-mingw32/sys-root/mingw/bin/program.exe=program.exe
+ /usr/i686-pc-mingw32/sys-root/mingw/bin/library.dll=library.dll
+ /usr/i686-pc-mingw32/sys-root/mingw/etc/config=conf/config
+
+which results in:
+
+ $INSTDIR/program.exe
+ $INSTDIR/library.dll
+ $INSTDIR/conf/config
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<--help>
+
+Print brief help message and exit.
+
+=item B<--man>
+
+Print the full manual page for the command and exit.
+
+=item B<--verbose>
+
+Print verbose messages while running. If this is not given then we
+try to operate quietly.
+
+=item B<--run>
+
+Normally this program just prints out the NSIS installer command
+script. However if you supply this option, then we run C<makensis>
+and attempt to generate an actual Windows installer.
+
+=item B<--with-gtk>
+
+GTK programs should normally supply this option. It ensures that the
+correct files are copied and/or created by the installer for GTK
+programs to work.
+
+=item B<--name "Name">
+
+Set the long name of the installer.
+
+If not set, the script tries to invent a suitable name based on the
+first root file given on the command line.
+
+See also B<--outfile>.
+
+=item B<--outfile myinstaller.exe>
+
+Set the output filename for the installer.
+
+If not set, this defaults to C<installer.exe>.
+
+This is the same as the C<OutFile> option to NSIS.
+
+=item B<--installdir 'C:\foo'>
+
+Set the default Windows installation directory. If not set, this
+program will choose a suitable default based on the name.
+
+In any case, the end user can override this when they run the
+installer.
+
+Note that since this string will contain backslashes, you should
+single-quote it to protect it from the shell.
+
+This is the same as the C<InstallDir> option to NSIS.
+
+=item B<--installdirregkey 'HKLM SOFTWARE\FOO'>
+
+Set the name of the registry key used to save the installation
+directory. This has two purposes: Firstly it is used to automagically
+remember the installation directory between installs. Secondly your
+program can use this as one method to find its own installation
+directory (there are other ways to do this).
+
+The default is C<HKLM SOFTWARE\Name> where C<Name> is derived from the
+name of the installer.
+
+Note that since this string will contain backslashes and spaces, you
+should single-quote it to protect it from the shell.
+
+This is the same as the C<InstallDirRegKey> option to NSIS.
+
+=back
+
+=cut
+
+my $objdump;
+my %files;
+
+my $help = '';
+my $man = '';
+my $verbose = '';
+my $run = '';
+my $with_gtk = '';
+my $name = '';
+my $outfile = 'installer.exe';
+my $installdir = '';
+my $installdirregkey = '';
+
+# XXX Should make these configurable.
+my $mingw32_prefix = '/usr/i686-pc-mingw32/sys-root/mingw';
+my $mingw32_bindir = $mingw32_prefix . '/bin';
+my $mingw32_libdir = $mingw32_prefix . '/lib';
+my $mingw32_sysconfdir = $mingw32_prefix . '/etc';
+
+sub get_options
+{
+ my $result = GetOptions (
+ "help|?" => \$help,
+ "man" => \$man,
+ "verbose" => \$verbose,
+ "run" => \$run,
+ "with-gtk" => \$with_gtk,
+ "name=s" => \$name,
+ "outfile=s" => \$outfile,
+ "installdir=s" => \$installdir,
+ "installdirregkey=s" => \$installdirregkey,
+ );
+ die "nsiswrapper: use --help for information about command line options\n"
+ unless $result;
+
+ pod2usage(1) if $help;
+ pod2usage(-exitstatus => 0, -verbose => 2) if $man;
+
+ # Add the roots to the list of files.
+ die "nsiswrapper: no roots specified: use --help for more help\n"
+ if @ARGV == 0;
+ foreach my $file (@ARGV) {
+ my ($dir, $exec) = (0, 0);
+
+ # Is it source=destination?
+ my ($source, $dest);
+ if ($file =~ /^(.*)=(.*)$/) {
+ $source = $1;
+ $dest = $2;
+ } else {
+ $source = $file;
+ }
+
+ die "$source: not a file or directory\n"
+ unless -f $source || -d $source;
+
+ $exec = 1 if $source =~ m/\.exe$/i;
+ $dir = 1 if -d $source;
+
+ $files{$source} = {
+ name => $source,
+ root => 1,
+ dir => $dir,
+ exec => $exec,
+ };
+
+ # Deal with explicit destination.
+ if (defined $dest) {
+ my ($install_dir, $install_name);
+
+ if ($dest =~ m{(.*)/(.*)}) {
+ $install_dir = $1;
+ $install_name = $2;
+ } else {
+ $install_dir = ".";
+ $install_name = $dest;
+ }
+
+ # Convert / in install_dir into backslashes.
+ $install_dir =~ s{/}{\\}g;
+
+ $files{$source}->{install_dir} = $install_dir;
+ $files{$source}->{install_name} = $install_name;
+ }
+ }
+
+ # Name not set?
+ if (!$name) {
+ # Massage the first root into a suitable package name.
+ $_ = $ARGV[0];
+ s{.*/}{};
+ s{=.*$}{};
+ s{\.\w\w\w\w?$}{};
+ $_ = ucfirst;
+ $name = $_;
+ }
+
+ # InstallDir not set?
+ if (!$installdir) {
+ $_ = $name;
+ s/\W/-/g;
+ $installdir = "c:\\$_"
+ }
+
+ # InstallDirRegKey not set?
+ if (!$installdirregkey) {
+ $_ = $name;
+ s/\W/-/g;
+ $installdirregkey = "HKLM SOFTWARE\\$_"
+ }
+}
+
+# Check prerequisites.
+
+sub check_prereqs
+{
+ my @paths = split (/:/, $ENV{PATH});
+
+ if (! $objdump) {
+ $objdump = check_path ("i686-pc-mingw32-objdump", @paths);
+ if (! $objdump || ! -x $objdump) {
+ die "i686-pc-mingw32-objdump: program not found on \$PATH\n"
+ }
+ }
+}
+
+# Check for the existance of a file at the given paths (not
+# necessarily executable). Returns the pathname of the file or
+# undefined if not found.
+
+sub check_path
+{
+ local $_ = shift;
+ my @paths = @_;
+
+ my $found;
+ foreach my $dir (@paths) {
+ my $file = $dir . "/" . $_;
+ if (-f $file) {
+ $found = $file;
+ last;
+ }
+ }
+ $found
+}
+
+# Print configuration.
+
+sub print_config
+{
+ print "Configuration:\n";
+ print "\t\$PATH = $ENV{PATH}\n";
+ print "\t\$objdump = $objdump\n";
+ print "\t\$verbose = $verbose\n";
+ print "\t\$name = \"$name\"\n";
+ print "\t\$outfile = \"$outfile\"\n";
+ print "\t\$installdir = \"$installdir\"\n";
+ print "\t\$installdirregkey = \"$installdirregkey\"\n";
+ my @roots = keys %files;
+ print "\t\@roots = (", join (", ", @roots), ")\n";
+ print "End of configuration.\n";
+}
+
+# Starting at the roots, get the dependencies.
+
+my $missing_deps = 0;
+
+sub do_dependencies
+{
+ my $deps_added = 1;
+
+ while ($deps_added > 0) {
+ $deps_added = 0;
+
+ foreach (keys %files) {
+ my @deps = get_deps_for_file ($_);
+
+ # Add the deps as separate files.
+ foreach (@deps) {
+ $deps_added += add_file_unless_exists (
+ $_,
+ root => 0,
+ dir => 0,
+ exec => 0
+ );
+ }
+ }
+ }
+
+ die "please correct missing dependencies shown above\n"
+ if $missing_deps > 0;
+}
+
+sub add_file_unless_exists
+{
+ my $name = shift;
+ my %details = @_;
+
+ unless (exists $files{$name}) {
+ die "$name: not a file or directory\n" unless -f $name || -d $name;
+
+ $details{name} = $name;
+ $files{$name} = \%details;
+
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+my $path_warning = 0;
+
+sub get_deps_for_file
+{
+ my $file = shift;
+ my @paths = split (/:/, $ENV{PATH});
+
+ # If we already fetched the dependencies for this file, just
+ # return that list now.
+ if (exists $files{$file}->{deps}) {
+ return @{$files{$file}->{deps}}
+ }
+
+ my @deps = ();
+
+ # We only know how to do this for *.exe and *.dll files.
+ if (m/\.exe$/i || m/\.dll$/i) {
+ my $cmd = "$objdump -p '$file' |
+ grep 'DLL Name:' |
+ grep -Eo '[-._[:alnum:]]+\.dll' |
+ sort -u"; # XXX quoting
+ open DEPS, "$cmd |" or die "$cmd: $!";
+ foreach (<DEPS>) {
+ chomp; $_ = lc;
+
+ # Ignore Windows system DLL deps.
+ next if is_windows_system_dll ($_);
+
+ # Does the file exist on the path?
+ my $found = check_path ($_, @paths);
+ if ($found) {
+ push @deps, $found;
+ } else {
+ warn "MISSING DEPENDENCY: $_ (for $file)\n";
+ $missing_deps++;
+ unless ($path_warning) {
+ warn "You may need to add the directory containing this file to your \$PATH\n";
+ $path_warning = 1;
+ }
+ }
+ }
+ close DEPS;
+
+ if ($verbose) {
+ if (@deps > 0) {
+ print "dependencies found for binary $file:\n\t",
+ join ("\n\t", @deps), "\n";
+ } else {
+ print "no dependencies found for $file\n"
+ }
+ }
+
+ }
+
+ # Cache the list of dependencies so we can just return it
+ # immediately next time.
+ $files{$file}->{deps} = \@deps;
+ return @deps;
+}
+
+sub is_windows_system_dll
+{
+ local $_ = shift;
+
+ $_ eq 'gdi32.dll' ||
+ $_ eq 'kernel32.dll' ||
+ $_ eq 'ole32.dll' ||
+ $_ eq 'mscoree.dll' ||
+ $_ eq 'msvcrt.dll' ||
+ $_ eq 'user32.dll'
+}
+
+# Add Gtk dependencies, if --with-gtk.
+
+sub do_gtk
+{
+ add_file_unless_exists (
+ "$mingw32_libdir/gtk-2.0",
+ root => 0,
+ dir => 1,
+ exec => 0,
+ install_dir => "lib",
+ install_name => "gtk-2.0"
+ );
+
+ add_file_unless_exists (
+ "$mingw32_libdir/pango",
+ root => 0,
+ dir => 1,
+ exec => 0,
+ install_dir => "lib",
+ install_name => "pango"
+ );
+
+ add_file_unless_exists (
+ "$mingw32_sysconfdir/fonts",
+ root => 0,
+ dir => 1,
+ exec => 0,
+ install_dir => "etc",
+ install_name => "fonts"
+ );
+
+ add_file_unless_exists (
+ "$mingw32_sysconfdir/gtk-2.0",
+ root => 0,
+ dir => 1,
+ exec => 0,
+ install_dir => "etc",
+ install_name => "gtk-2.0"
+ );
+
+ add_file_unless_exists (
+ "$mingw32_sysconfdir/pango",
+ root => 0,
+ dir => 1,
+ only_mkdir => 1,
+ exec => 0,
+ install_dir => "etc",
+ install_name => "pango"
+ );
+
+ # We need to run pango-querymodules after installation to
+ # rebuild etc\pango\pango.modules.
+ add_file_unless_exists (
+ "$mingw32_bindir/pango-querymodules.exe",
+ root => 0,
+ dir => 0,
+ exec => 0
+ );
+}
+
+# Decide how we will name the output files. This removes the
+# common prefix from filenames, if it can determine one.
+
+sub install_names
+{
+ my @names = keys %files;
+
+ # Don't care about files that already have an install
+ # directory/name defined, ie. they were specified as source=dest
+ # on the command line.
+ @names = grep { ! exists $files{$_}->{install_name} } @names;
+
+ # Determine if all the names share a common prefix.
+ my @namelens = map { length } @names;
+ my $shortest = min (@namelens);
+
+ my $prefixlen;
+ for ($prefixlen = $shortest; $prefixlen >= 0; --$prefixlen) {
+ my @ns = map { substr $_, 0, $prefixlen } @names;
+ last if same (@ns);
+ }
+
+ if ($verbose) { print "prefix length = $prefixlen\n" }
+
+ # Remove the prefix from each name and save the install directory
+ # and install filename separately.
+ foreach my $name (@names) {
+ my $install_as = substr $name, $prefixlen;
+
+ my ($install_dir, $install_name);
+
+ if ($install_as =~ m{(.*)/(.*)}) {
+ $install_dir = $1;
+ $install_name = $2;
+ } else {
+ $install_dir = ".";
+ $install_name = $install_as;
+ }
+
+ # Convert / in install_dir into backslashes.
+ $install_dir =~ s{/}{\\}g;
+
+ $files{$name}->{install_dir} = $install_dir;
+ $files{$name}->{install_name} = $install_name;
+ }
+}
+
+sub max
+{
+ my $max = $_[0];
+ for (@_[1..$#_]) {
+ $max = $_ if $_ > $max;
+ }
+ $max
+}
+
+sub min
+{
+ my $min = $_[0];
+ for (@_[1..$#_]) {
+ $min = $_ if $_ < $min;
+ }
+ $min
+}
+
+sub same
+{
+ my $s = $_[0];
+ for (@_[1..$#_]) {
+ return 0 if $_ ne $s;
+ }
+ 1;
+}
+
+# Print the list of files.
+
+sub print_files
+{
+ print "Files:\n";
+ foreach (sort keys %files) {
+ print "\t$_";
+ if ($files{$_}->{root}) {
+ print " [root]";
+ }
+ if ($files{$_}->{dir}) {
+ print " [dir]";
+ }
+ print STDOUT ("\n\t => ",
+ $files{$_}->{install_dir}, " \\ ", $files{$_}->{install_name},
+ "\n");
+ }
+ print "End of files.\n";
+}
+
+# Write the NSIS script.
+
+sub write_script
+{
+ my $io = shift;
+
+ print $io <<EOT;
+#!Nsis Installer Command Script
+#
+# This is an NSIS Installer Command Script generated automatically
+# by the Fedora nsiswrapper program. For more information see:
+#
+# http://fedoraproject.org/wiki/MinGW
+#
+# To build an installer from the script you would normally do:
+#
+# makensis this_script
+#
+# which will generate the output file '$outfile' which is a Windows
+# installer containing your program.
+
+Name "$name"
+OutFile "$outfile"
+InstallDir "$installdir"
+InstallDirRegKey $installdirregkey "Install_Dir"
+
+ShowInstDetails hide
+ShowUninstDetails hide
+
+# Uncomment this to enable BZip2 compression, which results in
+# slightly smaller files but uses more memory at install time.
+#SetCompressor bzip2
+
+XPStyle on
+
+Page components
+Page directory
+Page instfiles
+
+ComponentText "Select which optional components you want to install."
+
+DirText "Please select the installation folder."
+
+Section "$name"
+ SectionIn RO
+EOT
+
+ # Set the output files.
+ my $olddir;
+ foreach (sort keys %files) {
+ if (!$olddir || $files{$_}->{install_dir} ne $olddir) {
+ # Moved into a new install directory.
+ my $dir = $files{$_}->{install_dir};
+ print $io "\n SetOutPath \"\$INSTDIR\\$dir\"\n";
+ $olddir = $dir;
+ }
+
+ # If it's a directory, we copy it recursively, otherwise
+ # just copy the single file.
+ if ($files{$_}->{dir}) {
+ if ($files{$_}->{only_mkdir}) {
+ # This is a hack to allow us to create empty directories.
+ my $install_dir = $files{$_}->{install_dir};
+ my $install_name = $files{$_}->{install_name};
+ print $io " CreateDirectory \"\$INSTDIR\\$install_dir\\$install_name\"\n";
+ } else {
+ print $io " File /r \"$_\"\n";
+ }
+ } else {
+ print $io " File \"$_\"\n";
+ }
+ }
+
+ # GTK?
+ if ($with_gtk) {
+ my $install_dir = $files{"$mingw32_bindir/pango-querymodules.exe"}->{install_dir};
+ my $install_name = $files{"$mingw32_bindir/pango-querymodules.exe"}->{install_name};
+
+ # This particular piece of Windows stupidity is documented here:
+ # http://forums.winamp.com/showthread.php?postid=438771#post438771
+ # http://forums.winamp.com/printthread.php?s=53c76b4ae4221ff1d9dc361fc5bf7ea2&threadid=231797
+ print $io "\n";
+ print $io " ReadEnvStr \$0 COMSPEC\n";
+ print $io " SetOutPath \"\$INSTDIR\"\n";
+ print $io " nsExec::ExecToLog '\$0 /C $install_dir\\$install_name > etc\\pango\\pango.modules'\n"
+ }
+
+ print $io <<EOT;
+SectionEnd
+
+Section "Start Menu Shortcuts"
+ CreateDirectory "\$SMPROGRAMS\\$name"
+ CreateShortCut "\$SMPROGRAMS\\$name\\Uninstall $name.lnk" "\$INSTDIR\\Uninstall $name.exe" "" "\$INSTDIR\\Uninstall $name.exe" 0
+EOT
+
+ # Start menu entries for each executable.
+ foreach (sort keys %files) {
+ if ($files{$_}->{exec}) {
+ my $install_dir = $files{$_}->{install_dir};
+ my $install_name = $files{$_}->{install_name};
+ print $io " CreateShortCut \"\$SMPROGRAMS\\$name\\$install_name.lnk\" \"\$INSTDIR\\$install_dir\\$install_name\" \"\" \"\$INSTDIR\\$install_dir\\$install_name\" 0\n";
+ }
+ }
+
+ print $io <<EOT;
+SectionEnd
+
+Section "Desktop Icons"
+EOT
+
+ # Desktop icons for each executable.
+ foreach (sort keys %files) {
+ if ($files{$_}->{exec}) {
+ my $install_dir = $files{$_}->{install_dir};
+ my $install_name = $files{$_}->{install_name};
+ print $io " CreateShortCut \"\$DESKTOP\\$install_name.lnk\" \"\$INSTDIR\\$install_dir\\$install_name\" \"\" \"\$INSTDIR\\$install_dir\\$install_name\" 0\n";
+ }
+ }
+
+ print $io <<EOT;
+SectionEnd
+
+Section "Uninstall"
+EOT
+
+ # Remove desktop icons and menu shortcuts.
+ foreach (reverse sort keys %files) {
+ if ($files{$_}->{exec}) {
+ my $install_name = $files{$_}->{install_name};
+ print $io " Delete /rebootok \"\$DESKTOP\\$install_name.lnk\"\n";
+ print $io " Delete /rebootok \"\$SMPROGRAMS\\$name\\$install_name.lnk\"\n";
+ }
+ }
+ print $io " Delete /rebootok \"\$SMPROGRAMS\\$name\\Uninstall $name.lnk\"\n";
+ print $io " RMDir \"\$SMPROGRAMS\\$name\"\n\n";
+
+ # Remove remaining files.
+ $olddir = '';
+ foreach (reverse sort keys %files) {
+ if (!$olddir || $files{$_}->{install_dir} ne $olddir) {
+ # Moved into a new install directory, so delete the previous one.
+ print $io " RMDir \"\$INSTDIR\\$olddir\"\n\n"
+ if $olddir;
+ $olddir = $files{$_}->{install_dir};
+ }
+
+ # If it's a directory, we delete it recursively, otherwise
+ # just delete the single file.
+ my $install_dir = $files{$_}->{install_dir};
+ my $install_name = $files{$_}->{install_name};
+ if ($files{$_}->{dir}) {
+ print $io " RMDir /r \"\$INSTDIR\\$install_dir\\$install_name\"\n\n";
+ $olddir = ''; # Don't double-delete directory.
+ } else {
+ print $io " Delete /rebootok \"\$INSTDIR\\$install_dir\\$install_name\"\n";
+ }
+ }
+
+ print $io " RMDir \"\$INSTDIR\\$olddir\"\n" if $olddir;
+
+ print $io <<EOT;
+ RMDir "\$INSTDIR"
+SectionEnd
+
+Section -post
+ WriteUninstaller "\$INSTDIR\\Uninstall $name.exe"
+SectionEnd
+EOT
+}
+
+# Run makensis on the named file.
+
+sub run_makensis
+{
+ my $filename = shift;
+
+ system ("makensis", $filename) == 0 or die "makensis: $?"
+}
+
+# Main program.
+
+sub main
+{
+ get_options ();
+ check_prereqs ();
+ print_config () if $verbose;
+ do_gtk () if $with_gtk;
+ do_dependencies ();
+ install_names ();
+ print_files () if $verbose;
+ if ($run) {
+ my ($io, $filename) = tempfile ("nswXXXXXX", UNLINK => 1);
+ write_script ($io);
+ close $io;
+ run_makensis ($filename);
+ } else {
+ write_script (\*STDOUT);
+ }
+}
+
+main ()
More information about the scm-commits
mailing list