[patch] Client-only installation on Windows

Started by MauMauabout 12 years ago8 messages
#1MauMau
maumau307@gmail.com
1 attachment(s)

Hello,

According to this page,

http://www.postgresql.org/docs/current/static/install-procedure.html

client-only installation is possible on UNIX/Linux like this:

gmake -C src/bin install
gmake -C src/include install
gmake -C src/interfaces install
gmake -C doc install

With the attached patch, you can do client-only installation on Windows like
this:

install.bat <install_dir> client

This installs:

* client applications (both core and contrib)
* DLLs for libpq and ECPG
* header files
* import libraries
* pg_service.conf.sample and psqlrc.sample
* symbol files (*.pdb) for the above modules

If the second argument is given as "client" or omitted, all files are
installed. With 9.4, the whole installation takes up about 80 MB, and the
client-only installation takes up only 24 MB.

Any comments would be appreciated.

Regards
MauMau

Attachments:

client_only_install_win.patchapplication/octet-stream; name=client_only_install_win.patchDownload
diff -rpcd a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm
*** a/src/tools/msvc/Install.pm	2013-12-02 09:17:05.000000000 +0900
--- b/src/tools/msvc/Install.pm	2013-12-06 15:56:45.000000000 +0900
*************** our (@ISA, @EXPORT_OK);
*** 17,22 ****
--- 17,35 ----
  @ISA       = qw(Exporter);
  @EXPORT_OK = qw(Install);
  
+ my $insttype;
+ my @client_contribs = (
+ 	'oid2name', 'pgbench', 'vacuumlo'
+ );
+ my @client_program_files = (
+ 	'clusterdb', 'createdb', 'createlang', 'createuser', 'dropdb',
+ 	'droplang', 'dropuser', 'ecpg', 'libecpg', 'libecpg_compat',
+ 	'libpgtypes', 'libpq', 'pg_basebackup', 'pg_config', 'pg_dump',
+ 	'pg_dumpall', 'pg_isready', 'pg_receivexlog', 'pg_restore',
+ 	'pgbench', 'psql', 'reindexdb', 'vacuumdb',
+ 	@client_contribs
+ );
+ 
  sub lcopy
  {
  	my $src    = shift;
*************** sub Install
*** 37,42 ****
--- 50,57 ----
  	$| = 1;
  
  	my $target = shift;
+ 	$insttype = shift;
+ 	$insttype = "all" unless ($insttype);
  
  	# if called from vcregress, the config will be passed to us
  	# so no need to re-include these
*************** sub Install
*** 65,88 ****
  	my $majorver = DetermineMajorVersion();
  	print "Installing version $majorver for $conf in $target\n";
  
! 	EnsureDirectories(
! 		$target,              'bin',
! 		'lib',                'share',
! 		'share/timezonesets', 'share/extension',
! 		'share/contrib',      'doc',
! 		'doc/extension',      'doc/contrib',
! 		'symbols',            'share/tsearch_data');
  
  	CopySolutionOutput($conf, $target);
  	lcopy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll');
  	my $sample_files = [];
  	File::Find::find(
  		{   wanted => sub {
  				/^.*\.sample\z/s
  				  && push(@$sample_files, $File::Find::name);
  			  }
  		},
! 		"src");
  	CopySetOfFiles('config files', $sample_files, $target . '/share/');
  	CopyFiles(
  		'Import libraries',
--- 80,112 ----
  	my $majorver = DetermineMajorVersion();
  	print "Installing version $majorver for $conf in $target\n";
  
! 	my @client_dirs = ('bin', 'lib', 'share', 'symbols');
! 	my @all_dirs = (@client_dirs,
! 		'doc', 'doc/contrib', 'doc/extension',
! 		'share/contrib', 'share/extension', 'share/timezonesets',
! 		'share/tsearch_data'
! 	);
! 	if ($insttype eq "client")
! 	{
! 		EnsureDirectories($target, @client_dirs);
! 	}
! 	else
! 	{
! 		EnsureDirectories($target, @all_dirs);
! 	}
  
  	CopySolutionOutput($conf, $target);
  	lcopy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll');
  	my $sample_files = [];
+ 	my @top_dir = ("src");
+ 	@top_dir = ("src\\bin", "src\\interfaces") if ($insttype eq "client");
  	File::Find::find(
  		{   wanted => sub {
  				/^.*\.sample\z/s
  				  && push(@$sample_files, $File::Find::name);
  			  }
  		},
! 		@top_dir);
  	CopySetOfFiles('config files', $sample_files, $target . '/share/');
  	CopyFiles(
  		'Import libraries',
*************** sub Install
*** 95,100 ****
--- 119,129 ----
  		"libpgport\\libpgport.lib",
  		"libpgtypes\\libpgtypes.lib",
  		"libecpg_compat\\libecpg_compat.lib");
+ 	CopyContribFiles($config, $target);
+ 	CopyIncludeFiles($target);
+ 
+ 	if ($insttype ne "client")
+ 	{
  	CopySetOfFiles(
  		'timezone names',
  		[ glob('src\timezone\tznames\*.txt') ],
*************** sub Install
*** 125,132 ****
  		'Dictionaries sample files',
  		[ glob("src\\backend\\tsearch\\*_sample.*") ],
  		$target . '/share/tsearch_data/');
- 	CopyContribFiles($config, $target);
- 	CopyIncludeFiles($target);
  
  	my $pl_extension_files = [];
  	my @pldirs             = ('src/pl/plpgsql/src');
--- 154,159 ----
*************** sub Install
*** 142,147 ****
--- 169,175 ----
  		@pldirs);
  	CopySetOfFiles('PL Extension files',
  		$pl_extension_files, $target . '/share/extension/');
+ 	}
  
  	GenerateNLSFiles($target, $config->{nls}, $majorver) if ($config->{nls});
  
*************** sub CopySolutionOutput
*** 218,223 ****
--- 246,253 ----
  
  		$sln =~ s/$rem//;
  
+ 		next if ($insttype eq "client" && !grep { $_ eq $pf } @client_program_files);
+ 
  		my $proj = read_file("$pf.$vcproj")
  		  || croak "Could not open $pf.$vcproj\n";
  		if ($vcproj eq 'vcproj' && $proj =~ qr{ConfigurationType="([^"]+)"})
*************** sub CopyContribFiles
*** 378,383 ****
--- 408,415 ----
  	{
  		next if ($d =~ /^\./);
  		next unless (-f "contrib/$d/Makefile");
+ 		next if ($insttype eq "client" && !grep { $_ eq $d } @client_contribs);
+ 
  		next if ($d eq "uuid-ossp" && !defined($config->{uuid}));
  		next if ($d eq "sslinfo"   && !defined($config->{openssl}));
  		next if ($d eq "xml2"      && !defined($config->{xml}));
diff -rpcd a/src/tools/msvc/install.bat b/src/tools/msvc/install.bat
*** a/src/tools/msvc/install.bat	2013-12-02 09:17:05.000000000 +0900
--- b/src/tools/msvc/install.bat	2013-12-06 15:56:45.000000000 +0900
*************** CALL bldenv.bat
*** 20,26 ****
  del bldenv.bat
  :nobuildenv
  
! perl install.pl "%1"
  
  REM exit fix for pre-2003 shell especially if used on buildfarm
  if "%XP_EXIT_FIX%" == "yes" exit %ERRORLEVEL%
--- 20,26 ----
  del bldenv.bat
  :nobuildenv
  
! perl install.pl "%1" %2
  
  REM exit fix for pre-2003 shell especially if used on buildfarm
  if "%XP_EXIT_FIX%" == "yes" exit %ERRORLEVEL%
diff -rpcd a/src/tools/msvc/install.pl b/src/tools/msvc/install.pl
*** a/src/tools/msvc/install.pl	2013-12-02 09:17:05.000000000 +0900
--- b/src/tools/msvc/install.pl	2013-12-06 15:56:45.000000000 +0900
*************** use warnings;
*** 9,15 ****
  use Install qw(Install);
  
  my $target = shift || Usage();
! Install($target);
  
  sub Usage
  {
--- 9,16 ----
  use Install qw(Install);
  
  my $target = shift || Usage();
! my $insttype = shift;
! Install($target, $insttype);
  
  sub Usage
  {
diff -rpcd a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
*** a/src/tools/msvc/vcregress.pl	2013-12-02 09:17:05.000000000 +0900
--- b/src/tools/msvc/vcregress.pl	2013-12-06 15:56:45.000000000 +0900
*************** sub upgradecheck
*** 252,258 ****
  	(mkdir $tmp_root || die $!) unless -d $tmp_root;
  	my $tmp_install = "$tmp_root/install";
  	print "Setting up temp install\n\n";
! 	Install($tmp_install, $config);
  
  	# Install does a chdir, so change back after that
  	chdir $cwd;
--- 252,258 ----
  	(mkdir $tmp_root || die $!) unless -d $tmp_root;
  	my $tmp_install = "$tmp_root/install";
  	print "Setting up temp install\n\n";
! 	Install($tmp_install, "all", $config);
  
  	# Install does a chdir, so change back after that
  	chdir $cwd;
#2Andrew Dunstan
andrew@dunslane.net
In reply to: MauMau (#1)
Re: [patch] Client-only installation on Windows

On 12/06/2013 09:16 AM, MauMau wrote:

Hello,

According to this page,

http://www.postgresql.org/docs/current/static/install-procedure.html

client-only installation is possible on UNIX/Linux like this:

gmake -C src/bin install
gmake -C src/include install
gmake -C src/interfaces install
gmake -C doc install

With the attached patch, you can do client-only installation on
Windows like this:

install.bat <install_dir> client

This installs:

* client applications (both core and contrib)
* DLLs for libpq and ECPG
* header files
* import libraries
* pg_service.conf.sample and psqlrc.sample
* symbol files (*.pdb) for the above modules

If the second argument is given as "client" or omitted, all files are
installed. With 9.4, the whole installation takes up about 80 MB, and
the client-only installation takes up only 24 MB.

Any comments would be appreciated

This looks OK, and I'll commit it after I have a chance to give it a
quick test (probably at the same time as I test the VS2013 patch)..

Is there any reason why pgbench is listed in @client_program_files as
well as @client_contribs? AFAICT it should only be in the latter.

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3MauMau
maumau307@gmail.com
In reply to: Andrew Dunstan (#2)
1 attachment(s)
Re: [patch] Client-only installation on Windows

From: "Andrew Dunstan" <andrew@dunslane.net>

Is there any reason why pgbench is listed in @client_program_files as
well as @client_contribs? AFAICT it should only be in the latter.

Thank you for reviewing the patch. Yes, you are right. I removed pgbench
from @client_program_files. In addition, I added some documentation, as
well as modifying the usage at the end of install.pl.

I'll update the CommitFest entry shortly.

Regards
MauMau

Attachments:

client_only_install_win_v2.patchapplication/octet-stream; name=client_only_install_win_v2.patchDownload
diff -rpcd a/doc/src/sgml/install-windows.sgml b/doc/src/sgml/install-windows.sgml
*** a/doc/src/sgml/install-windows.sgml	2014-01-22 13:17:06.000000000 +0900
--- b/doc/src/sgml/install-windows.sgml	2014-01-24 15:31:05.000000000 +0900
*************** $ENV{CONFIG}="Debug";
*** 410,415 ****
--- 410,423 ----
  <userinput>install c:\destination\directory</userinput>
  </screen>
    </para>
+ 
+   <para>
+    If you want to install only the client applications and
+    interface libraries, then you can use these commands:
+ <screen>
+ <userinput>install c:\destination\directory client</userinput>
+ </screen>
+   </para>
   </sect2>
  
   <sect2>
diff -rpcd a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm
*** a/src/tools/msvc/Install.pm	2014-01-22 13:17:06.000000000 +0900
--- b/src/tools/msvc/Install.pm	2014-01-24 15:10:36.000000000 +0900
*************** our (@ISA, @EXPORT_OK);
*** 17,22 ****
--- 17,35 ----
  @ISA       = qw(Exporter);
  @EXPORT_OK = qw(Install);
  
+ my $insttype;
+ my @client_contribs = (
+ 	'oid2name', 'pgbench', 'vacuumlo'
+ );
+ my @client_program_files = (
+ 	'clusterdb', 'createdb', 'createlang', 'createuser', 'dropdb',
+ 	'droplang', 'dropuser', 'ecpg', 'libecpg', 'libecpg_compat',
+ 	'libpgtypes', 'libpq', 'pg_basebackup', 'pg_config', 'pg_dump',
+ 	'pg_dumpall', 'pg_isready', 'pg_receivexlog', 'pg_restore',
+ 	'psql', 'reindexdb', 'vacuumdb',
+ 	@client_contribs
+ );
+ 
  sub lcopy
  {
  	my $src    = shift;
*************** sub Install
*** 37,42 ****
--- 50,57 ----
  	$| = 1;
  
  	my $target = shift;
+ 	$insttype = shift;
+ 	$insttype = "all" unless ($insttype);
  
  	# if called from vcregress, the config will be passed to us
  	# so no need to re-include these
*************** sub Install
*** 65,88 ****
  	my $majorver = DetermineMajorVersion();
  	print "Installing version $majorver for $conf in $target\n";
  
! 	EnsureDirectories(
! 		$target,              'bin',
! 		'lib',                'share',
! 		'share/timezonesets', 'share/extension',
! 		'share/contrib',      'doc',
! 		'doc/extension',      'doc/contrib',
! 		'symbols',            'share/tsearch_data');
  
  	CopySolutionOutput($conf, $target);
  	lcopy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll');
  	my $sample_files = [];
  	File::Find::find(
  		{   wanted => sub {
  				/^.*\.sample\z/s
  				  && push(@$sample_files, $File::Find::name);
  			  }
  		},
! 		"src");
  	CopySetOfFiles('config files', $sample_files, $target . '/share/');
  	CopyFiles(
  		'Import libraries',
--- 80,112 ----
  	my $majorver = DetermineMajorVersion();
  	print "Installing version $majorver for $conf in $target\n";
  
! 	my @client_dirs = ('bin', 'lib', 'share', 'symbols');
! 	my @all_dirs = (@client_dirs,
! 		'doc', 'doc/contrib', 'doc/extension',
! 		'share/contrib', 'share/extension', 'share/timezonesets',
! 		'share/tsearch_data'
! 	);
! 	if ($insttype eq "client")
! 	{
! 		EnsureDirectories($target, @client_dirs);
! 	}
! 	else
! 	{
! 		EnsureDirectories($target, @all_dirs);
! 	}
  
  	CopySolutionOutput($conf, $target);
  	lcopy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll');
  	my $sample_files = [];
+ 	my @top_dir = ("src");
+ 	@top_dir = ("src\\bin", "src\\interfaces") if ($insttype eq "client");
  	File::Find::find(
  		{   wanted => sub {
  				/^.*\.sample\z/s
  				  && push(@$sample_files, $File::Find::name);
  			  }
  		},
! 		@top_dir);
  	CopySetOfFiles('config files', $sample_files, $target . '/share/');
  	CopyFiles(
  		'Import libraries',
*************** sub Install
*** 95,100 ****
--- 119,129 ----
  		"libpgport\\libpgport.lib",
  		"libpgtypes\\libpgtypes.lib",
  		"libecpg_compat\\libecpg_compat.lib");
+ 	CopyContribFiles($config, $target);
+ 	CopyIncludeFiles($target);
+ 
+ 	if ($insttype ne "client")
+ 	{
  	CopySetOfFiles(
  		'timezone names',
  		[ glob('src\timezone\tznames\*.txt') ],
*************** sub Install
*** 125,132 ****
  		'Dictionaries sample files',
  		[ glob("src\\backend\\tsearch\\*_sample.*") ],
  		$target . '/share/tsearch_data/');
- 	CopyContribFiles($config, $target);
- 	CopyIncludeFiles($target);
  
  	my $pl_extension_files = [];
  	my @pldirs             = ('src/pl/plpgsql/src');
--- 154,159 ----
*************** sub Install
*** 142,147 ****
--- 169,175 ----
  		@pldirs);
  	CopySetOfFiles('PL Extension files',
  		$pl_extension_files, $target . '/share/extension/');
+ 	}
  
  	GenerateNLSFiles($target, $config->{nls}, $majorver) if ($config->{nls});
  
*************** sub CopySolutionOutput
*** 218,223 ****
--- 246,253 ----
  
  		$sln =~ s/$rem//;
  
+ 		next if ($insttype eq "client" && !grep { $_ eq $pf } @client_program_files);
+ 
  		my $proj = read_file("$pf.$vcproj")
  		  || croak "Could not open $pf.$vcproj\n";
  		if ($vcproj eq 'vcproj' && $proj =~ qr{ConfigurationType="([^"]+)"})
*************** sub CopyContribFiles
*** 378,383 ****
--- 408,415 ----
  	{
  		next if ($d =~ /^\./);
  		next unless (-f "contrib/$d/Makefile");
+ 		next if ($insttype eq "client" && !grep { $_ eq $d } @client_contribs);
+ 
  		next if ($d eq "uuid-ossp" && !defined($config->{uuid}));
  		next if ($d eq "sslinfo"   && !defined($config->{openssl}));
  		next if ($d eq "xml2"      && !defined($config->{xml}));
diff -rpcd a/src/tools/msvc/install.bat b/src/tools/msvc/install.bat
*** a/src/tools/msvc/install.bat	2014-01-22 13:17:06.000000000 +0900
--- b/src/tools/msvc/install.bat	2014-01-24 15:08:47.000000000 +0900
*************** CALL bldenv.bat
*** 20,26 ****
  del bldenv.bat
  :nobuildenv
  
! perl install.pl "%1"
  
  REM exit fix for pre-2003 shell especially if used on buildfarm
  if "%XP_EXIT_FIX%" == "yes" exit %ERRORLEVEL%
--- 20,26 ----
  del bldenv.bat
  :nobuildenv
  
! perl install.pl "%1" %2
  
  REM exit fix for pre-2003 shell especially if used on buildfarm
  if "%XP_EXIT_FIX%" == "yes" exit %ERRORLEVEL%
diff -rpcd a/src/tools/msvc/install.pl b/src/tools/msvc/install.pl
*** a/src/tools/msvc/install.pl	2014-01-22 13:17:06.000000000 +0900
--- b/src/tools/msvc/install.pl	2014-01-24 15:20:23.000000000 +0900
*************** use warnings;
*** 9,18 ****
  use Install qw(Install);
  
  my $target = shift || Usage();
! Install($target);
  
  sub Usage
  {
! 	print "Usage: install.pl <targetdir>\n";
  	exit(1);
  }
--- 9,20 ----
  use Install qw(Install);
  
  my $target = shift || Usage();
! my $insttype = shift;
! Install($target, $insttype);
  
  sub Usage
  {
! 	print "Usage: install.pl <targetdir> [installtype]\n";
! 	print "installtype: client\n";
  	exit(1);
  }
diff -rpcd a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
*** a/src/tools/msvc/vcregress.pl	2014-01-22 13:17:06.000000000 +0900
--- b/src/tools/msvc/vcregress.pl	2014-01-24 15:08:47.000000000 +0900
*************** sub upgradecheck
*** 252,258 ****
  	(mkdir $tmp_root || die $!) unless -d $tmp_root;
  	my $tmp_install = "$tmp_root/install";
  	print "Setting up temp install\n\n";
! 	Install($tmp_install, $config);
  
  	# Install does a chdir, so change back after that
  	chdir $cwd;
--- 252,258 ----
  	(mkdir $tmp_root || die $!) unless -d $tmp_root;
  	my $tmp_install = "$tmp_root/install";
  	print "Setting up temp install\n\n";
! 	Install($tmp_install, "all", $config);
  
  	# Install does a chdir, so change back after that
  	chdir $cwd;
#4Andrew Dunstan
andrew@dunslane.net
In reply to: MauMau (#3)
Re: [patch] Client-only installation on Windows

On 01/24/2014 05:36 AM, MauMau wrote:

From: "Andrew Dunstan" <andrew@dunslane.net>

Is there any reason why pgbench is listed in @client_program_files as
well as @client_contribs? AFAICT it should only be in the latter.

Thank you for reviewing the patch. Yes, you are right. I removed
pgbench from @client_program_files. In addition, I added some
documentation, as well as modifying the usage at the end of install.pl.

I'll update the CommitFest entry shortly.

Committed, with a little help from perltidy.

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#4)
Re: [patch] Client-only installation on Windows

Andrew Dunstan <andrew@dunslane.net> writes:

Committed, with a little help from perltidy.

I think you forgot to push to master? The only recent commit I see from
you is the Visual Studio 2013 fixes.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#6Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#5)
Re: [patch] Client-only installation on Windows

On 01/26/2014 03:14 PM, Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

Committed, with a little help from perltidy.

I think you forgot to push to master? The only recent commit I see from
you is the Visual Studio 2013 fixes.

Oh, hell and damnation. That's going to make my life VERY difficult.
Thanks for letting me know.

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#7Andres Freund
andres@anarazel.de
In reply to: Andrew Dunstan (#6)
Re: [patch] Client-only installation on Windows

Andrew Dunstan <andrew@dunslane.net> schrieb:

On 01/26/2014 03:14 PM, Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

Committed, with a little help from perltidy.

I think you forgot to push to master? The only recent commit I see

from

you is the Visual Studio 2013 fixes.

Oh, hell and damnation. That's going to make my life VERY difficult.
Thanks for letting me know.

Why would it make things difficult? git fetch; git rebase origin/master; git push. That should be it.

--- 
Please excuse brevity and formatting - I am writing this on my mobile phone.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#8Andrew Dunstan
andrew@dunslane.net
In reply to: Andres Freund (#7)
Re: [patch] Client-only installation on Windows

On 01/26/2014 05:04 PM, Andres Freund wrote:

Andrew Dunstan <andrew@dunslane.net> schrieb:

On 01/26/2014 03:14 PM, Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

Committed, with a little help from perltidy.

I think you forgot to push to master? The only recent commit I see

from

you is the Visual Studio 2013 fixes.

Oh, hell and damnation. That's going to make my life VERY difficult.
Thanks for letting me know.

Why would it make things difficult? git fetch; git rebase origin/master; git push. That should be it.

Maybe if I had more facility with git I'd know more what to do. But I'd
merged it into another branch and then after I wound this back, rolled
forward and recommitted (and this time pushed) the patch I'm not sure
not how to fix that branch. I'll manage it somehow I guess.

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers