#! /usr/bin/perl
# 
# $Id$
# Main page of 'My::Project::captive'
# Copyright (C) 2003 Jan Kratochvil <project-www.jankratochvil.net@jankratochvil.net>
# 
# 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; exactly version 2 of June 1991 is required
# 
# 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


package project::captive::Index;
require 5.6.0;	# at least 'use warnings;' but we need some 5.6.0+ modules anyway
our $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
our $CVS_ID=q$Id$;
use strict;
use warnings;

BEGIN{ open F,"Makefile"; our $top_dir=pop @{[split /\s/,(grep /^top_srcdir/,<F>)[0]]}; eval "use lib '$top_dir'"; close F; }
use My::Web;
Wuse 'My::Project';
Wuse 'project::captive::ListItem';


my $W=My::Project->init_project(
		"__PACKAGE__"=>__PACKAGE__,
		"ListItem"=>\@project::captive::ListItem::ListItem,
		"no_project_data"=>1,
		"head_css"=>"
.reqpkg { font-style: italic; }
.stuff  { font-style: italic; font-size: larger; margin-left: 20%; margin-right: 10%; }
.re     { font-style: italic; }
table.mailman > * /* FIXME: What is it? */ > tr > th,
table.mailman > * /* FIXME: What is it? */ > tr > td { padding: 1ex; text-align: center; }
",
		);


print <<"HERE";
<h1>The First free Read/Write NTFS for Free Operating Systems</h1>
<h1>The First Open Source MS-Windows Kernel API for Free OS</h1>
HERE

my @stuff=(
		"A lot of people claim to be Windows Programmers.\n"
				." Now, I can join them at last - I have also written my own Microsoft Windows.",
		"Why do they need ".a_href('http://www.winsupersite.com/reviews/winserver2k3_gold2.asp','5,000 developers')
				." to write Microsoft Windows when it can be just a One Man Show?",
		"My first Microsoft Windows program ever written? Some 'helloworld'?"
				." <span class=\"quote\">hal.dll</span>.",
		);

print rightimg((map("<p class=\"stuff\">$_</p>\n",($stuff[int rand @stuff])))[0],
		'captive-install-acquire-small','[ Captive Microsoft Windows Drivers Acquire Illustration ]',
				"a_href_img"=>'captive-install-acquire');

print <<"HERE";


@{[ vskip "3ex" ]}

<table border="0" width="100%"><tr><td align="center">
	<table border="0" style="margin: 4ex; padding: 2ex; background: #552222;">
		<tr><td style="font-size: larger;">
			Why did I install Microsoft Windows and write such a disgusting piece of code?<br />
			Expecting @{[ a_href $W->{"resume_url"},"yet another challenging task" ]}!
		</td></tr>
	</table>
</table>

@{[ vskip "3ex" ]}


<h2>NEWS</h2>

<dl>
	<dt>captive-1.0.1 (2003-10-28)</dt>
	<dd>
		<ul>
			<li>Fixed (harmless) crash/hang of lufsd during post-unmount cleanup</li>
			<li>Fixed captive-install-acquire Gnome UI responsiveness during network outage</li>
			<li>Support for LUFS options such as uid/gid/fmask/dmask</li>
			<li>Improved performance</li>
		</ul>
	</dd>
</dl>


@{[ vskip "1ex" ]}


<table border="1" align="center" style="text-align: center;" width="100%"><tr><th>Distribution</th>
		<th>Installation Case #1<br />Filesystem and installer<br />(recommended)</th>
		<th>Installation Case #2<br />Manual installation<br />(filesystem, expert user)</th>
		<th>Installation Case #3<br />Command-line client<br />(no filesystem access)</th></tr>
HERE
my %pkg=(
		1=>[qw(captive captive-lufs captive-install lufs gnome-vfs-httpcaptive ntfsprogs ntfsprogs-gnomevfs)],
		2=>[qw(captive captive-lufs                 lufs)],
		3=>[qw(captive)],
		);
my %reqpkg=(
		1 =>[qw(glib2 gnome-vfs2 ORBit2 libxml2 openssl popt readline libgnomeui)],
		23=>[qw(glib2 gnome-vfs2 ORBit2 libxml2 openssl popt readline)],
		);
my %version=(
		map(($_=>["1.0.1","0"]),qw(captive captive-lufs captive-install)),
		"lufs"=>["0.9.6","1captive6"],
		"gnome-vfs-httpcaptive"=>["2.3.8captive2","0"],
		"ntfsprogs"=>["200309071734","1captive1"],
		"ntfsprogs-gnomevfs"=>["1.0.2","0"],
		);
my %has_rh8=(map(($_=>1),qw(
		gnome-vfs-httpcaptive
		captive
		captive-lufs
		captive-install
		)));
my %has_mdk91=(map(($_=>1),qw(
		gnome-vfs-httpcaptive
		lufs
		captive
		captive-lufs
		captive-install
		)));
my %has_devel=(map(($_=>1),qw(
		ntfsprogs
		)));
my %pkg_nosrc=(map(($_=>1),qw(
		captive-lufs
		captive-install
		)));

my $case;
my $a_href_arch=sub ($$%)
{
my($file_base,$text,%args)=@_;

	$text=~s/[._]\D.*$// if $case!=1 && $text!~/^[.]/;
	return a_href $file_base,$text,"size"=>($case==1),%args;
};

my @libxml2_rh8_pkgs=qw(libxml2-2.5.4-1.i386.rpm libxml2-python-2.5.4-1.i386.rpm libxml2-devel-2.5.4-1.i386.rpm);

my $ntfsprogs_after=sub ($) {
	my($format)=@_;
		return () if $case!=1;
		return '<hr width="80%" />requirement: '
				.a_href('http://linux-ntfs.sourceforge.net/downloads.html#downloads','ntfsprogs')
				.' '.$format.' &ge; 1.8.0';
	};

my @dist=(
		{
			"name"=>"Red Hat 9<br />Shrike i386",
			"out"=>sub {
				my($pkg,$version_base,$version_ext)=@_;
					return () if $pkg eq "ntfsprogs";
					my $file="$pkg-$version_base-$version_ext.i386.rpm";
					my $r=&$a_href_arch("dist/$file",$file);
					(my $filedev=$file)=~s/^\Q$pkg\E-/${pkg}-devel-/;
					$r.="<br />".&$a_href_arch("dist/$filedev",$filedev) if $has_devel{$pkg};
					return $r;
				},
			"after"=>sub { return &{$ntfsprogs_after}(".i386.rpm"); },
			},
		{
			"name"=>"Red Hat 8<br />Psyche i386<br />"
					."(".a_href("#libxml2_rh8","libxml2 upgrade note").")",
			"out"=>sub {
				my($pkg,$version_base,$version_ext)=@_;
					return () if $pkg eq "ntfsprogs";
					my $file="$pkg-$version_base-$version_ext".(!$has_rh8{$pkg} ? "" : "rh8").".i386.rpm";
					my $r=&$a_href_arch("dist/$file",$file);
					(my $filedev=$file)=~s/^\Q$pkg\E-/${pkg}-devel-/;
					$r.="<br />".&$a_href_arch("dist/$filedev",$filedev) if $has_devel{$pkg};
					if ($pkg eq "captive-install") {
						for (@libxml2_rh8_pkgs) {
							$r.="<br />".&$a_href_arch('ftp://ftp.redhat.com/pub/redhat/linux/9/en/os/i386/RedHat/RPMS/'.$_,$_)." of Red Hat 9";
							}
						}
					return $r;
				},
			"after"=>sub { return &{$ntfsprogs_after}(".i386.rpm"); },
			},
		{
			"name"=>"Mandrake 9.1<br />Bamboo i586",
			"out"=>sub {
				my($pkg,$version_base,$version_ext)=@_;
					return () if $pkg eq "ntfsprogs";
					my $file="$pkg-$version_base-$version_ext".(!$has_mdk91{$pkg} ? ".i386.rpm" : "mdk91.i586.rpm");
					my $r=&$a_href_arch("dist/$file",$file);
					(my $filedev=$file)=~s/^\Q$pkg\E-/${pkg}-devel-/;
					$r.="<br />".&$a_href_arch("dist/$filedev",$filedev) if $has_devel{$pkg};
					return $r;
				},
			"after"=>sub { return &{$ntfsprogs_after}(".i386.rpm"); },
			},
		{
			"name"=>"Debian GNU/Linux<br />'unstable' i386",
			"out"=>sub {
				my($pkg,$version_base,$version_ext)=@_;
					$version_ext=~s/^\d+//;
					my $file="${pkg}_$version_base".($version_ext=~/^\d+$/ ? "" : $version_ext)."_i386.deb";
					my $r=&$a_href_arch("dist/$file",$file);
					(my $filedev=$file)=~s/^\Q$pkg\E_/${pkg}-dev_/;
					$r.="<br />".&$a_href_arch("dist/$filedev",$filedev) if $has_devel{$pkg};
					return $r;
				},
			},
		{
			"name"=>"Sources (.tar.gz)",
			"out"=>sub {
				my($pkg,$version_base,$version_ext)=@_;
					return () if $pkg_nosrc{$pkg};
					$version_ext=~s/^\d+//;
					my $file="$pkg-$version_base".($version_ext=~/^\d+$/ ? "" : $version_ext).".tar.gz";
					return $file,$file;
				},
			"after"=>sub { return &{$ntfsprogs_after}(".tar.gz"); },
			},
		{
			"name"=>"Sources (.src.rpm)<br />(Red Hat 9 - Shrike)",
			"out"=>sub {
				my($pkg,$version_base,$version_ext)=@_;
					return () if $pkg eq "ntfsprogs";
					return () if $pkg_nosrc{$pkg};
					my $file="$pkg-$version_base-$version_ext.src.rpm";
					return $file,$file;
				},
			"after"=>sub { return &{$ntfsprogs_after}(".i386.rpm (incl. -devel)"); },
			},
		);

for my $dist (@dist) {
	print "<tr>";
		print "<td>".$dist->{"name"}."</td>";
		for my $casel (1,2,3) {
			$case=$casel;
			print "<td>";
			print join("<br />",map({ my $pkg=$_;
				my($file,$text)=&{$dist->{"out"}}($pkg,@{$version{$pkg}});
				(!defined $text ? ($file) || () : (&$a_href_arch("dist/$file",$text)));
				} @{$pkg{$case}}),map({ (!$_ ? () : (&{$_}())); } $dist->{"after"}));
			print "</td>";
			}
	print "</tr>\n";
	}
print "<tr style=\"height: 2ex;\"></tr>\n";
print "<tr>";
	print "<td>Package Requirements</td>";
	for my $case (1,23) {
		print "<td".($case==23 ? ' colspan="2"' : '').">";
		print join(", ",map("<span class=\"reqpkg\">$_</span>",@{$reqpkg{$case}}));
		print "</td>";
		}
print "</tr>\n";
print <<"HERE";
</table>

<blockquote>
	<p><a name="libxml2_rh8"><b><i>Red Hat 8 Psyche</i> upgrade of <i>libxml2</i> package:</b></a>
	Upgrade only the packages already installed on your system to prevent
	many dependency requirements - do not use &quot;<code>rpm -U</code>&quot;,
	use &quot;<code>rpm -F</code>&quot; instead:</p>
	<blockquote><p class="quote">
		<code>rpm -F @{[ join(" ",@libxml2_rh8_pkgs) ]}</code>
	</p></blockquote>
</blockquote>

@{[ vskip "3ex" ]}


<h1>Installation Notes</h1>

<p>You should first run <b>captive-install-acquire</b> command to check your
available Microsoft Windows drivers versions. Now you can execute:</p>

<blockquote>
	<p class="quote">
		# mkdir /mnt/dosc<br />
		# mount -t captive-ntfs /dev/hda1 /mnt/dosc
	</p>
</blockquote>


<h2>Overview</h2>

<p>'<b>captive</b>' is the base package. It contains debugging '<b>captive-cmdline</b>' client.<br />
'<b>captive-lufs</b>' permits mounting NTFS as regular filesystem. It needs '<b>lufs</b>'.<br />
'<b>lufs</b>' is a daemon to enable userland process to provide filesystem functions.</p>

<p>Any errors from '<b>captive-lufs</b>' are written to '<b>/var/log/messages</b>'.</p>

<p>Needed drivers (at least ntoskrnl.exe+ntfs.sys) must be in '<b>/var/lib/captive</b>'.</p>

<p>'<b>captive</b>' package creates '<b>captive</b>' user and '<b>captive</b>' group on your system.</p>


<h2>Package Version Conflicts</h2>

<dl>

<dt>@{[ a_href 'http://lufs.sourceforge.net/lufs/','lufs' ]}</dt>
<dd><p><b>'captive' version required</b>: Although you may already have the
original package installed you must replace it by the local 'captive'-marked
version containing some 'captive'-essential fixes and extensions.</p></dd>

</dl>


<h2>LUFS Kernel Driver Module</h2>

<p>@{[ a_href 'http://lufs.sourceforge.net/lufs/','LUFS' ]} (Linux Userland File
System) needs Linux kernel module driver (<i>lufs.o</i>) compatible with your
running Linux kernel. The binary driver is supplied already precompiled for many
Linux kernel versions in the binary packages above (<b>.i386.rpm</b> and
<b>_i386.deb</b> archives).</p>

<p>If you cannot <b>mount</b>(8) your NTFS filesystem you should run <span
class="quote">/usr/share/lufs/prepmod</span> to see the reasons. It is always
recommended to upgrade to the latest stable kernel supplied by your GNU/Linux
distribution vendor. You may need to install package
<b>kernel-source</b> (Red Hat) or <b>kernel-headers</b> (Debian) matching your
Linux kernel version (<b>rpm&nbsp;-q&nbsp;kernel</b>) and re-run <span
class="quote">/usr/share/lufs/prepmod</span>.</p>

<p><b>WARNING:</b> This 'captive' package may modify your Linux kernel
sources matching your currently running kernel version. These minor
modifications may include a dependencies rebuild, compiling build tools, fixes of
several include files, etc. All the modifications are done at the mount(8) time
by the automatically executed <span class="quote">/usr/share/lufs/prepmod</span> script.
This behavior was not present in the original
@{[ a_href 'http://lufs.sourceforge.net/lufs/','LUFS' ]} distribution
by @{[ a_href 'http://www.malinux.net/main/','Florin Malita' ]}.</p>


HERE


print rightimg <<"HERE",'reactos','ReactOS',"a_href"=>'http://www.reactos.com/';
	<h2>The First Open Source MS-Windows Kernel API for Free OS</h2>

	<p>Compatibility with the existing binary Microsoft Windows file system drivers has been
	reached. Microsoft Windows kernel system components required by these drivers
	were analyzed and successfully emulated in the GNU/Linux operating system.
	The project brings the Microsoft Windows kernel emulation framework to support even
	other types of Microsoft Windows drivers in the future.
	The <span class="productname">@{[ a_href 'http://www.reactos.com/','ReactOS' ]}</span>
	code base proved to be a big asset for this functionality.</p>
HERE


my @lists=qw(captive-announce-list captive-list captive-devel-list);

print <<"HERE";

<a name="lists"><h2>Mailing Lists</h2></a>

<form action="@{[ top_dir("/Mailman.pl") ]}" method="post">
	<table border="1" class="mailman" style="border-collapse: collapse; border-style: solid; border-width: 1px;">
		<tr>@{[ map('<th>'.$_.'@jankratochvil.net</th>',@lists) ]}</tr>
		<tr><td>New version announcements<br />
		        (low traffic, recommended)</td>
				<td>User support,<br />bug reports</td>
				<td>Development</td>
				</tr>
		<tr>@{[ map({ "<td>".a_href(&{$W->{"mailman_url_sub"}}()."/listinfo/$_",'Mailman Infopage')."</td>"; } @lists) ]}</tr>
		<tr>@{[ map({ "<td>".a_href(&{$W->{"pipermail_url_sub"}}()."/$_",'Archive')."</td>"; } @lists) ]}</tr>
		<tr>@{[
			map(('<td><input type="checkbox" name="list" value="'.$_.'"'
					.($_ ne "captive-announce-list" ? '' : ' checked="checked"')
					.' /> Subscribe?</td>'),@lists)
			]}</tr>
		<tr><td colspan="3">
			<table border="0" style="text-align: left;">
				<tr><td>Email address:            </td><td><input type="text"     name="email"   size="30" /></td></tr>
				<tr><td>Your new Mailman password:</td><td><input type="password" name="pw"      size="15" /></td></tr>
				<tr><td>Reenter your password:    </td><td><input type="password" name="pw-conf" size="15" /></td></tr>
			</table>
			<p><input type="submit" name="email-button" value="Subscribe me" /></p>
		</td></tr>
	</table>
<input type="hidden" name="back" value="/project/captive/#lists" />
</form>


@{[ vskip "3ex" ]}

<h1>See Also</h1>
<ul>
	<li>@{[ a_href 'Preview.html.pl','<span style="font-size: larger;">Technology Preview</span>' ]}</li>
	<li>@{[ a_href 'CVS.html.pl','CVS Repository' ]}</li>
	<li>@{[ a_href 'doc/','Developer Documentation' ]}; highlights:<ul>
		<li>@{[ a_href 'doc/About.html.pl#versions','Microsoft Windows Versions Compatibility' ]}</li>
		<li>@{[ a_href 'doc/Architecture.html.pl#law','Laws and Licensing Conditions' ]}</li>
		<li>@{[ a_href 'doc/Details.html.pl#sandbox','Sandboxing of W32 Filesystem' ]}</li>
		<li>@{[ a_href 'doc/TODO.html.pl#todo_fsck','TODO: Fsck of NTFS' ]}</li>
		<li>@{[ a_href 'doc/TODO.html.pl#todo_surprise','TODO: NTFS Support for Partition Surprise' ]}</li>
		<li>@{[ a_href 'doc/Related.html.pl#LinuxNTFScompet','Related Projects - Linux NTFS' ]}</li>
		<li>@{[ a_href 'doc/Related.html.pl#vmware','Related Projects - VMware Workstation' ]}</li>
		<li>@{[ a_href 'doc/LinuxNTFS.html.pl',"Re: 7.7 Can't we write a wrapper for Windows' driver?" ]}</li>
		</ul></li>
	<li>@{[ a_href 'http://cvs.jankratochvil.net/viewcvs/*checkout*/captive/TODO?rev=HEAD','Known Bugs' ]}</li>
	<li>Man Pages<ul>
		@{[
			do {
				my @mans=(
						'captive'=>[7,'Microsoft Windows NT kernel emulation for NTFS disk access'],
						'mount.captive'=>[8,'mount(8) interface for NTFS disk access'],
						'lufs-captivefs'=>[7,'Linux Userland File System module for NTFS as filesystem'],
						'captive-cmdline'=>[1,'Command-line client for captive(7) NTFS disk access'],
###						'captive-sandbox-server'=>[1,'Security+safety wrapper for NTFS disk access'],
						'captive-install-acquire'=>[1,'Find MS Windows XP driver files for NTFS'],
###						'captive-install-fstab'=>[1,'Manage captive-ntfs /etc/fstab entries'],
						);
				my @r;
				while (@mans) {
					my $file=shift @mans;
					my($section,$name)=@{shift @mans};
					push @r,"<li>".a_href("man/$file.pod.html",$file)."($section) - $name</li>\n";
					}
				@r;
				}
			]}
		</ul></li>
	<li>@{[ a_href 'Resources.html.pl','Related Pages' ]}</li>
	<li>@{[ a_href 'Thanks.html.pl','Thanks' ]}</li>
</ul>
HERE


My::Web->footer();
