#!/usr/bin/perl use rpmtools; sub chop_version($) { ($_[0] =~ /(.*)-[^-]+-[^-]+/)[0] || $_[0]; } sub read_compsslist { my ($file) = @_; my %compsslist; local *F; open F, $file or die "closurepkgs: unable to open compsslist file $file\n"; foreach () { my ($name, $level) = /^\s*(\S+)\s+(\d+)/; $compsslist{$name} = $level; } close F; \%compsslist; } sub main { my ($dir, $lang) = @_; #- compute depslist on line directly. my $params = new rpmtools; foreach (glob("$dir/*.cz*")) { $params->read_hdlists($_) } $params->keep_only_cleaned_provides_files(); foreach (glob("$dir/*.cz*")) { $params->read_hdlists($_) } $params->compute_depslist(); my $compsslist = read_compsslist("$dir/compssList"); #- DO NOT FORGET TO UPDATE HERE ACCORDING TO gi/perl-install/install_any.pm my @pkgs = qw(XFree86 XFree86-glide-module Device3Dfx Glide_V3-DRI Glide_V5 Mesa dhcpcd pump dhcpxd dhcp-client isdn4net isdn4k-utils dev pptp-adsl-fr rp-pppoe ppp ypbind rhs-printfilters lpr cups cups-drivers samba ncpfs ghostscript-utils kernel-pcmcia-cs apmd cdrecord ); push @pkgs, "XFree86-$_" foreach qw(3DLabs 3dfx 8514 AGX FBDev I128 Mach8 Mach32 Mach64 Mono P9000 Rage128 S3 S3V SVGA VGA16 W32); #- closure the list of package to be kept for oem. my %closure; foreach (@pkgs) { $closure{$_} = 1; map { $closure{chop_version($_->{name})} = 1 } map { $params->{depslist}[$_] } map { split /\|/ } split ' ', $params->{info}{$_}{deps}; } #- only if dependancy is ok. $closure{$_} = 1 foreach qw(xpp kups kisdn); #- closure the list of package to always install for oem. (level >= 50)... my %install; my @force_install; if ($params->{info}{"locales-$lang"}) { foreach (keys %{$params->{info}}) { push @force_install, $_ if grep { $_ == $params->{info}{"locales-$lang"}{id} } split ' ', $params->{info}{$_}{deps}; } } else { foreach (keys %{$params->{info}}) { push @force_install, $_ if grep { $params->{depslist}[$_]{name} =~ /locales-/ } split ' ', $params->{info}{$_}{deps}; } } push @force_install, qw(cups cups-drivers drakprofile draksync irda-utils numlock raidtools reiserfs-utils Mesa Mesa-demos alsa alsa-utils); foreach (qw( Aurora xawtv kwintv xscreensaver-gl Mesa-demos xmms-mesa bzflag csmash gltron spacecup chromium tuxracer ), @force_install, grep { $compsslist->{$_} >= 50 } keys %{$params->{info}}) { $install{$_} = 1; map { $install{chop_version($_->{name})} = 1 } map { $params->{depslist}[$_] } map { split /\|/ } split ' ', $params->{info}{$_}{deps}; } #- remove base packages, which have to be installed, according to basesystem. delete $closure{'basesystem'}; $install{'basesystem'} = 1; map { delete $closure{chop_version($_->{name})}; $install{chop_version($_->{name})} = 1 } map { $params->{depslist}[$_] } map { split /\|/ } split ' ', $params->{info}{'basesystem'}{deps}; #- special packages that are to be move to closure always ... foreach (qw(kernel-smp kernel-linus kernel-secure hackkernel-smp hackkernel-linus hackkernel-secure Aurora xawtv kwintv xscreensaver-gl xmms-mesa bzflag csmash gltron spacecup chromium tuxracer )) { $params->{info}{$_} or next; $closure{$_} = 1; delete $install{$_}; } #- dump out the list of package according to the 2 lists defined above. my $total_install = 0; my $total_closure = 0; foreach (@{$params->{depslist}}) { my $tiny_name = chop_version($_->{name}); if (exists $install{$tiny_name}) { my $p = $params->{info}{$tiny_name}; $total_install += $p->{size}; print "I:$p->{name}-$p->{version}-$p->{release}\n"; } elsif (exists $closure{$tiny_name}) { my $p = $params->{info}{$tiny_name}; $total_closure += $p->{size}; print "C:$p->{name}-$p->{version}-$p->{release}\n"; } } print "\n\ntotal_install=$total_install\n"; print "total_closure=$total_closure\n"; } main(@ARGV); value='user/erwan/bug-13680'>user/erwan/bug-13680 Mageia Installer and base platform for many utilitiesThierry Vignaud [tv]
summaryrefslogtreecommitdiffstats
path: root/perl-install/interactive_http.pm
blob: 18bff77fe5f88388a46cb32755b714e3a09a205e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package interactive_http; # $Id$

use diagnostics;
use strict;
use vars qw(@ISA);

@ISA = qw(interactive);

use CGI;
use interactive;
use common;
use log;

my $script_name = $ENV{INTERACTIVE_HTTP};
my $no_header;
my $uid;
my $pipe_r = "/tmp/interactive_http_r";
my $pipe_w = "/tmp/interactive_http_w";

sub open_stdout {
    open STDOUT, ">$pipe_w" or die;
    $| = 1;
    print CGI::header();
    $no_header = 1;    
}

# cont_stdout must be called after open_stdout and before the first print
sub cont_stdout {
    my ($title) = @_;
    print CGI::start_html(-title => $title) if $no_header;
    $no_header = 0;
}

sub new_uid {
    my ($s, $ms) = gettimeofday();
    $s * 256 + $ms % 256;
}

sub new() {
    open_stdout();
    bless {}, $_[0];
}

sub end() { 
    -e $pipe_r or return; # don't run this twice
    my $q = CGI->new;
    cont_stdout("Exit");
    print "It's done, thanks for playing", $q->end_html;
    close STDOUT;
    unlink $pipe_r, $pipe_w;
}
sub exit() { end; exit($_[1]) }
END { end() }

sub ask_fromW {
    my ($o, $common, $l, $l2) = @_;

  redisplay:
    my $uid = new_uid();
    my $q = CGI->new;
    $q->param(state => 'next_step');
    $q->param(uid => $uid);
    cont_stdout($common->{title});

#    print $q->img({ -src => "/icons/$o->{icon}" }) if $o->{icon};
    print @{$common->{messages}};
    print $q->start_form(-name => 'form', -action => $script_name, -method => 'post');

    print "<table>\n";

    map_index {
	my $e = $_;

	print "<tr><td>$e->{label}</td><td>\n";

	$e->{type} = 'list' if $e->{type} =~ /(icon|tree)list/;

	#- combo doesn't exist, fallback to a sensible default
	$e->{type} = $e->{not_edit} ? 'list' : 'entry' if $e->{type} eq 'combo';

	if ($e->{type} eq 'bool') {
	    print $q->checkbox(-name => "w$::i", -checked => ${$e->{val}} && 'on', -label => $e->{text} || " ");
	} elsif ($e->{type} eq 'button') {
	    print "nobuttonyet";
	} elsif ($e->{type} =~ /list/) {
	    my %t; 
	    $t{$_} = may_apply($e->{format}, $_) foreach @{$e->{list}};

	    print $q->scrolling_list(-name => "w$::i",
				     -values => $e->{list},
				     -default => [ ${$e->{val}} ],
				     -size => 5, -multiple => '', -labels => \%t);
	} else {
	    print $e->{hidden} ?
	      $q->password_field(-name => "w$::i", -default => ${$e->{val}}) :
	      $q->textfield     (-name => "w$::i", -default => ${$e->{val}});
	}

	print "</td></tr>\n";
    } @$l;

    print "</table>\n";
    print $q->p();
    print $q->submit(-name => 'ok_submit', -value => $common->{ok} || _("Ok"));
    print $q->submit(-name => 'cancel_submit', -value => $common->{cancel}) if $common->{cancel};
    print $q->hidden('state'), $q->hidden('uid');
    print $q->end_form, $q->end_html;

    close STDOUT; # page terminated

    while (1) {	
	local *F;
	open F, "<$pipe_r" or die;
	$q = CGI->new(\*F);
	$q->param('force_exit_dead_prog') and $o->exit;
	last if $q->param('uid') == $uid;

	open_stdout(); # re-open for writing
	cont_stdout(_("Error"));
	print $q->h1(_("Error")), $q->p("Sorry, you can't go back");
	goto redisplay;
    }
    map_index {
	my $e = $_;
	my $v = $q->param("w$::i");
	if ($e->{type} eq 'bool') {
	    $v = $v eq 'on';
	}
	${$e->{val}} = $v;
    } @$l;

    open_stdout(); # re-open for writing
    $q->param('ok_submit');
}

sub p {
    print "\n" . CGI::br($_) foreach @_;
}

sub wait_messageW {
    my ($o, $title, $messages) = @_;
    cont_stdout();
    print "\n" . CGI::p();
    p(@$messages);
}

sub wait_message_nextW {
    my ($o, $messages, $w) = @_;
    p(@$messages);
}
sub wait_message_endW {
    my ($o, $w) = @_;
    p(_("Done"));
    print "\n" . CGI::p();
}



1;