19780544fSAndrew Rist#**************************************************************
29780544fSAndrew Rist#
39780544fSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
49780544fSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
59780544fSAndrew Rist#  distributed with this work for additional information
69780544fSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
79780544fSAndrew Rist#  to you under the Apache License, Version 2.0 (the
89780544fSAndrew Rist#  "License"); you may not use this file except in compliance
99780544fSAndrew Rist#  with the License.  You may obtain a copy of the License at
109780544fSAndrew Rist#
119780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
129780544fSAndrew Rist#
139780544fSAndrew Rist#  Unless required by applicable law or agreed to in writing,
149780544fSAndrew Rist#  software distributed under the License is distributed on an
159780544fSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169780544fSAndrew Rist#  KIND, either express or implied.  See the License for the
179780544fSAndrew Rist#  specific language governing permissions and limitations
189780544fSAndrew Rist#  under the License.
199780544fSAndrew Rist#
209780544fSAndrew Rist#**************************************************************
219780544fSAndrew Rist
229780544fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweirpackage installer::windows::media;
25cdf0e10cSrcweir
26cdf0e10cSrcweiruse installer::exiter;
27cdf0e10cSrcweiruse installer::files;
28cdf0e10cSrcweiruse installer::globals;
29cdf0e10cSrcweiruse installer::windows::idtglobal;
30cdf0e10cSrcweir
31cdf0e10cSrcweir##############################################################
32cdf0e10cSrcweir# Returning the diskid for the media table.
33cdf0e10cSrcweir##############################################################
34cdf0e10cSrcweir
35cdf0e10cSrcweirsub get_media_diskid
36cdf0e10cSrcweir{
37cdf0e10cSrcweir	my ($id) = @_;
38cdf0e10cSrcweir
39cdf0e10cSrcweir	return $id;
40cdf0e10cSrcweir}
41cdf0e10cSrcweir
42cdf0e10cSrcweir##############################################################
43cdf0e10cSrcweir# Returning the lastsequence for the media table.
44cdf0e10cSrcweir##############################################################
45cdf0e10cSrcweir
46cdf0e10cSrcweirsub get_media_lastsequence
47cdf0e10cSrcweir{
48cdf0e10cSrcweir	my ($fileref) = @_;
49cdf0e10cSrcweir
50cdf0e10cSrcweir	return $fileref->{'sequencenumber'};
51cdf0e10cSrcweir}
52cdf0e10cSrcweir
53cdf0e10cSrcweir##############################################################
54cdf0e10cSrcweir# Returning the diskprompt for the media table.
55cdf0e10cSrcweir##############################################################
56cdf0e10cSrcweir
57cdf0e10cSrcweirsub get_media_diskprompt
58cdf0e10cSrcweir{
59cdf0e10cSrcweir	return 1;
60cdf0e10cSrcweir}
61cdf0e10cSrcweir
62cdf0e10cSrcweir##############################################################
63cdf0e10cSrcweir# Returning the cabinet file name for the media table.
64cdf0e10cSrcweir##############################################################
65cdf0e10cSrcweir
66cdf0e10cSrcweirsub get_media_cabinet
67cdf0e10cSrcweir{
68cdf0e10cSrcweir	my ($id) = @_;
69cdf0e10cSrcweir
70cdf0e10cSrcweir	my $number = 1000 + $id;
71cdf0e10cSrcweir	my $filename = "f_" . $number . ".cab";
72cdf0e10cSrcweir
73cdf0e10cSrcweir	if ( $installer::globals::include_cab_in_msi ) { $filename = "\#" . $filename; }
74cdf0e10cSrcweir
75cdf0e10cSrcweir	return $filename;
76cdf0e10cSrcweir}
77cdf0e10cSrcweir
78cdf0e10cSrcweir##############################################################
79cdf0e10cSrcweir# Returning the volumelabel for the media table.
80cdf0e10cSrcweir##############################################################
81cdf0e10cSrcweir
82cdf0e10cSrcweirsub get_media_volumelabel
83cdf0e10cSrcweir{
84cdf0e10cSrcweir	return "DISK1";
85cdf0e10cSrcweir}
86cdf0e10cSrcweir
87cdf0e10cSrcweir##############################################################
88cdf0e10cSrcweir# Returning the source for the media table.
89cdf0e10cSrcweir##############################################################
90cdf0e10cSrcweir
91cdf0e10cSrcweirsub get_media_source
92cdf0e10cSrcweir{
93cdf0e10cSrcweir	return "";
94cdf0e10cSrcweir}
95cdf0e10cSrcweir
96cdf0e10cSrcweir##############################################################
97cdf0e10cSrcweir# Saving the cabinet file name in the files collector.
98cdf0e10cSrcweir# This is useful for making a list to connect the
99cdf0e10cSrcweir# source of each file with the destination cabinet file.
100cdf0e10cSrcweir##############################################################
101cdf0e10cSrcweir
102cdf0e10cSrcweirsub set_cabinetfilename_for_component_in_file_collector
103cdf0e10cSrcweir{
104cdf0e10cSrcweir	my ($cabinetfilename, $filesref, $componentname, $max) = @_;
105cdf0e10cSrcweir
106cdf0e10cSrcweir	for ( my $i = 0; $i <= $max; $i++ )
107cdf0e10cSrcweir	{
108cdf0e10cSrcweir		my $onefile = ${$filesref}[$i];
109cdf0e10cSrcweir		my $component = $onefile->{'componentname'};
110cdf0e10cSrcweir
111cdf0e10cSrcweir		if ( $component eq $componentname )
112cdf0e10cSrcweir		{
113cdf0e10cSrcweir			my $cabinet = "";
114cdf0e10cSrcweir
115cdf0e10cSrcweir			if ( $onefile->{'cabinet'} ) { $cabinet = $onefile->{'cabinet'}; }
116cdf0e10cSrcweir
117cdf0e10cSrcweir			if ( $cabinet eq "" )
118cdf0e10cSrcweir			{
119cdf0e10cSrcweir				$onefile->{'cabinet'} = $cabinetfilename;
120cdf0e10cSrcweir			}
121cdf0e10cSrcweir		}
122cdf0e10cSrcweir	}
123cdf0e10cSrcweir}
124cdf0e10cSrcweir
125cdf0e10cSrcweir#################################################
126cdf0e10cSrcweir# Creating the cab file name dynamically
127cdf0e10cSrcweir#################################################
128cdf0e10cSrcweir
129cdf0e10cSrcweirsub generate_cab_filename_for_some_cabs
130cdf0e10cSrcweir{
131cdf0e10cSrcweir	my ( $allvariables, $id ) = @_;
132cdf0e10cSrcweir
133cdf0e10cSrcweir	my $name = $allvariables->{'PRODUCTNAME'};
134cdf0e10cSrcweir
135cdf0e10cSrcweir	$name = lc($name);
136cdf0e10cSrcweir	$name =~ s/\.//g;
137cdf0e10cSrcweir	$name =~ s/\s//g;
138cdf0e10cSrcweir
139cdf0e10cSrcweir	# possibility to overwrite the name with variable CABFILENAME
140cdf0e10cSrcweir	if ( $allvariables->{'CABFILENAME'} ) { $name = $allvariables->{'CABFILENAME'}; }
141cdf0e10cSrcweir
142cdf0e10cSrcweir	$name = $name . $id . ".cab";
143cdf0e10cSrcweir
144cdf0e10cSrcweir	if ( $installer::globals::include_cab_in_msi ) { $name = "\#" . $name; }
145cdf0e10cSrcweir
146cdf0e10cSrcweir	return $name;
147cdf0e10cSrcweir}
148cdf0e10cSrcweir
149cdf0e10cSrcweir#################################################
150cdf0e10cSrcweir# Creating the cab file name for cab files
151cdf0e10cSrcweir# defined in packages.
152cdf0e10cSrcweir#################################################
153cdf0e10cSrcweir
154cdf0e10cSrcweirsub get_cabfilename
155cdf0e10cSrcweir{
156cdf0e10cSrcweir	my ($name) = @_;
157cdf0e10cSrcweir
158cdf0e10cSrcweir	if ( $installer::globals::include_cab_in_msi ) { $name = "\#" . $name; }
159cdf0e10cSrcweir
160cdf0e10cSrcweir	return $name;
161cdf0e10cSrcweir}
162cdf0e10cSrcweir
163cdf0e10cSrcweir#################################################
164cdf0e10cSrcweir# Creating the cab file name dynamically
165cdf0e10cSrcweir#################################################
166cdf0e10cSrcweir
167cdf0e10cSrcweirsub generate_cab_filename
168cdf0e10cSrcweir{
169cdf0e10cSrcweir	my ( $allvariables ) = @_;
170cdf0e10cSrcweir
171cdf0e10cSrcweir	my $name = $allvariables->{'PRODUCTNAME'};
172cdf0e10cSrcweir
173cdf0e10cSrcweir	$name = lc($name);
174cdf0e10cSrcweir	$name =~ s/\.//g;
175cdf0e10cSrcweir	$name =~ s/\s//g;
176cdf0e10cSrcweir
177cdf0e10cSrcweir	# possibility to overwrite the name with variable CABFILENAME
178cdf0e10cSrcweir	if ( $allvariables->{'CABFILENAME'} ) { $name = $allvariables->{'CABFILENAME'}; }
179cdf0e10cSrcweir
180cdf0e10cSrcweir	$name = $name . ".cab";
181cdf0e10cSrcweir
182cdf0e10cSrcweir	if ( $installer::globals::include_cab_in_msi ) { $name = "\#" . $name; }
183cdf0e10cSrcweir
184cdf0e10cSrcweir	return $name;
185cdf0e10cSrcweir}
186cdf0e10cSrcweir
187cdf0e10cSrcweirsub get_maximum_filenumber
188cdf0e10cSrcweir{
189cdf0e10cSrcweir	my ($allfiles, $maxcabfilenumber) = @_;
190cdf0e10cSrcweir
191cdf0e10cSrcweir	my $maxfile = 0;
192cdf0e10cSrcweir
193cdf0e10cSrcweir	while ( ! ( $allfiles%$maxcabfilenumber == 0 ))
194cdf0e10cSrcweir	{
195cdf0e10cSrcweir		$allfiles++;
196cdf0e10cSrcweir	}
197cdf0e10cSrcweir
198cdf0e10cSrcweir	$maxfile = $allfiles / $maxcabfilenumber;
199cdf0e10cSrcweir
200cdf0e10cSrcweir	$maxfile++;					# for securitry
201cdf0e10cSrcweir
202cdf0e10cSrcweir	return $maxfile;
203cdf0e10cSrcweir}
204cdf0e10cSrcweir
205cdf0e10cSrcweir#################################################################################
206cdf0e10cSrcweir# Setting the last sequence for the cabinet files
207cdf0e10cSrcweir#################################################################################
208cdf0e10cSrcweir
209cdf0e10cSrcweirsub get_last_sequence
210cdf0e10cSrcweir{
211cdf0e10cSrcweir	my ( $cabfilename, $alludpatelastsequences ) = @_;
212cdf0e10cSrcweir
213cdf0e10cSrcweir	my $sequence = 0;
214cdf0e10cSrcweir
215cdf0e10cSrcweir	if (( $installer::globals::updatedatabase ) && ( exists($alludpatelastsequences->{$cabfilename}) ))
216cdf0e10cSrcweir	{
217cdf0e10cSrcweir		$sequence = $alludpatelastsequences->{$cabfilename};
218cdf0e10cSrcweir	}
219cdf0e10cSrcweir	else
220cdf0e10cSrcweir	{
221cdf0e10cSrcweir		$sequence = $installer::globals::lastsequence{$cabfilename};
222cdf0e10cSrcweir	}
223cdf0e10cSrcweir
224cdf0e10cSrcweir	return $sequence;
225cdf0e10cSrcweir}
226cdf0e10cSrcweir
227cdf0e10cSrcweir#################################################################################
228cdf0e10cSrcweir# Creating the file Media.idt dynamically
229cdf0e10cSrcweir# Content:
230cdf0e10cSrcweir# DiskId LastSequence DiskPrompt Cabinet VolumeLabel Source
231cdf0e10cSrcweir# Idea: Every component is packed into each own cab file
232cdf0e10cSrcweir#################################################################################
233cdf0e10cSrcweir
234cdf0e10cSrcweirsub create_media_table
235cdf0e10cSrcweir{
236cdf0e10cSrcweir	my ($filesref, $basedir, $allvariables, $alludpatelastsequences, $allupdatediskids) = @_;
237cdf0e10cSrcweir
238cdf0e10cSrcweir	my @mediatable = ();
239cdf0e10cSrcweir
240cdf0e10cSrcweir	my $diskid = 0;
241cdf0e10cSrcweir
242cdf0e10cSrcweir	installer::windows::idtglobal::write_idt_header(\@mediatable, "media");
243cdf0e10cSrcweir
244cdf0e10cSrcweir	if ( $allvariables->{'INCLUDE_CAB_IN_MSI'} ) { $installer::globals::include_cab_in_msi = 1; }
245cdf0e10cSrcweir
246cdf0e10cSrcweir	if ( $installer::globals::use_packages_for_cabs )
247cdf0e10cSrcweir	{
248cdf0e10cSrcweir		my $cabfile;
249cdf0e10cSrcweir		foreach $cabfile ( sort keys %installer::globals::lastsequence )
250cdf0e10cSrcweir		{
251cdf0e10cSrcweir			my %media = ();
252cdf0e10cSrcweir			$diskid++;
253cdf0e10cSrcweir
254cdf0e10cSrcweir			$media{'DiskId'} = get_media_diskid($diskid);
255cdf0e10cSrcweir			$media{'LastSequence'} = get_last_sequence($cabfile, $alludpatelastsequences);
256cdf0e10cSrcweir			$media{'DiskPrompt'} = get_media_diskprompt();
257cdf0e10cSrcweir			$media{'Cabinet'} = get_cabfilename($cabfile);
258cdf0e10cSrcweir			$media{'VolumeLabel'} = get_media_volumelabel();
259cdf0e10cSrcweir			$media{'Source'} = get_media_source();
260cdf0e10cSrcweir
261cdf0e10cSrcweir			my $oneline = $media{'DiskId'} . "\t" . $media{'LastSequence'} . "\t" . $media{'DiskPrompt'} . "\t"
262cdf0e10cSrcweir						. $media{'Cabinet'} . "\t" . $media{'VolumeLabel'} . "\t" . $media{'Source'} . "\n";
263cdf0e10cSrcweir
264cdf0e10cSrcweir			push(@mediatable, $oneline);
265cdf0e10cSrcweir
266cdf0e10cSrcweir			# Comparing the disk id with the disk id from update database. Both have to be identical. New files have to be added
267cdf0e10cSrcweir			# to the new pff cabinet file. And existing cab files must not be removed.
268cdf0e10cSrcweir			if ( $installer::globals::updatedatabase )
269cdf0e10cSrcweir			{
270cdf0e10cSrcweir				# Comparing lines in new media table with line from media table in udpate database.
271cdf0e10cSrcweir				if ( exists($allupdatediskids->{$media{'Cabinet'}}) )
272cdf0e10cSrcweir				{
273cdf0e10cSrcweir					if ( $media{'DiskId'} != $allupdatediskids->{$media{'Cabinet'}} )
274cdf0e10cSrcweir					{
275cdf0e10cSrcweir						installer::exiter::exit_program("ERROR: Different DiskIDs for cab file \"$media{'Cabinet'}\".\nCurrent installation set: \"$media{'DiskId'}\", but update database used \"$allupdatediskids->{$media{'Cabinet'}}\".\nWere cabinet files removed or added?", "create_media_table");
276cdf0e10cSrcweir					}
277cdf0e10cSrcweir				}
278cdf0e10cSrcweir				else
279cdf0e10cSrcweir				{
280*b274bc22SAndre Fischer                    $installer::logger::Lang->printf(
281*b274bc22SAndre Fischer                        "Warning: Could not find cabinet file \"%s}\" in update database. This seems to be an new cabinet file!?\n",
282*b274bc22SAndre Fischer                        $media{'Cabinet'});
283cdf0e10cSrcweir				}
284cdf0e10cSrcweir			}
285cdf0e10cSrcweir		}
286cdf0e10cSrcweir
287cdf0e10cSrcweir		# one new cabinet file for all files added after the final release
288cdf0e10cSrcweir		if (( $installer::globals::updatedatabase ) && ( $installer::globals::pfffileexists ))
289cdf0e10cSrcweir		{
290cdf0e10cSrcweir			my %media = ();
291cdf0e10cSrcweir			$diskid++;
292cdf0e10cSrcweir
293cdf0e10cSrcweir			$media{'DiskId'} = get_media_diskid($diskid) + $installer::globals::mergemodulenumber;  # Adding mergemodulenumber, because this files are included later
294cdf0e10cSrcweir			$media{'LastSequence'} = $installer::globals::updatesequencecounter;
295cdf0e10cSrcweir			$media{'DiskPrompt'} = get_media_diskprompt();
296cdf0e10cSrcweir			$media{'Cabinet'} = get_cabfilename($installer::globals::pffcabfilename);
297cdf0e10cSrcweir			$media{'VolumeLabel'} = get_media_volumelabel();
298cdf0e10cSrcweir			$media{'Source'} = get_media_source();
299cdf0e10cSrcweir
300cdf0e10cSrcweir			my $oneline = $media{'DiskId'} . "\t" . $media{'LastSequence'} . "\t" . $media{'DiskPrompt'} . "\t"
301cdf0e10cSrcweir						. $media{'Cabinet'} . "\t" . $media{'VolumeLabel'} . "\t" . $media{'Source'} . "\n";
302cdf0e10cSrcweir
303cdf0e10cSrcweir			push(@mediatable, $oneline);
304cdf0e10cSrcweir		}
305cdf0e10cSrcweir
306cdf0e10cSrcweir	}
307cdf0e10cSrcweir	elsif ( $installer::globals::cab_file_per_component )
308cdf0e10cSrcweir	{
309cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$filesref}; $i++ )
310cdf0e10cSrcweir		{
311cdf0e10cSrcweir			my $onefile = ${$filesref}[$i];
312cdf0e10cSrcweir			my $nextfile = ${$filesref}[$i+1];
313cdf0e10cSrcweir
314cdf0e10cSrcweir			my $filecomponent = "";
315cdf0e10cSrcweir			my $nextcomponent = "";
316cdf0e10cSrcweir
317cdf0e10cSrcweir			if ( $onefile->{'componentname'} ) { $filecomponent = $onefile->{'componentname'}; }
318cdf0e10cSrcweir			if ( $nextfile->{'componentname'} ) { $nextcomponent = $nextfile->{'componentname'}; }
319cdf0e10cSrcweir
320cdf0e10cSrcweir			if ( $filecomponent eq $nextcomponent )
321cdf0e10cSrcweir			{
322cdf0e10cSrcweir				next;		# nothing to do, this is not the last file of a component
323cdf0e10cSrcweir			}
324cdf0e10cSrcweir
325cdf0e10cSrcweir			my %media = ();
326cdf0e10cSrcweir			$diskid++;
327cdf0e10cSrcweir
328cdf0e10cSrcweir			$media{'DiskId'} = get_media_diskid($diskid);
329cdf0e10cSrcweir			$media{'LastSequence'} = get_media_lastsequence($onefile);
330cdf0e10cSrcweir			$media{'DiskPrompt'} = get_media_diskprompt();
331cdf0e10cSrcweir			$media{'Cabinet'} = get_media_cabinet($diskid);
332cdf0e10cSrcweir			$media{'VolumeLabel'} = get_media_volumelabel();
333cdf0e10cSrcweir			$media{'Source'} = get_media_source();
334cdf0e10cSrcweir
335cdf0e10cSrcweir			my $oneline = $media{'DiskId'} . "\t" . $media{'LastSequence'} . "\t" . $media{'DiskPrompt'} . "\t"
336cdf0e10cSrcweir					. $media{'Cabinet'} . "\t" . $media{'VolumeLabel'} . "\t" . $media{'Source'} . "\n";
337cdf0e10cSrcweir
338cdf0e10cSrcweir			push(@mediatable, $oneline);
339cdf0e10cSrcweir
340cdf0e10cSrcweir			$media{'Cabinet'} =~ s/^\s*\#//;	# removing leading hash
341cdf0e10cSrcweir			set_cabinetfilename_for_component_in_file_collector($media{'Cabinet'}, $filesref, $filecomponent, $i);
342cdf0e10cSrcweir		}
343cdf0e10cSrcweir	}
344cdf0e10cSrcweir	elsif ( $installer::globals::fix_number_of_cab_files )
345cdf0e10cSrcweir	{
346cdf0e10cSrcweir		# number of cabfiles
347cdf0e10cSrcweir		my $maxcabfilenumber = $installer::globals::number_of_cabfiles;
348cdf0e10cSrcweir		if ( $allvariables->{'CABFILENUMBER'} ) { $maxcabfilenumber = $allvariables->{'CABFILENUMBER'}; }
349cdf0e10cSrcweir		my $allfiles = $#{$filesref} + 1;
350cdf0e10cSrcweir		my $maxfilenumber = get_maximum_filenumber($allfiles, $maxcabfilenumber);
351cdf0e10cSrcweir		# my $maxfilenumber = 1000;	# maximum 1000 files in each cabinet file
352cdf0e10cSrcweir		my $cabfilenumber = 0;
353cdf0e10cSrcweir		my $cabfull = 0;
354cdf0e10cSrcweir		my $counter = 0;
355cdf0e10cSrcweir
356cdf0e10cSrcweir		# Sorting of files collector files required !
357cdf0e10cSrcweir		# Attention: The order in the cab file is not guaranteed (especially in udpate process)
358cdf0e10cSrcweir
359cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$filesref}; $i++ )
360cdf0e10cSrcweir		{
361cdf0e10cSrcweir			if (( $counter >= $maxfilenumber ) || ( $i == $#{$filesref} )) { $cabfull = 1; }
362cdf0e10cSrcweir
363cdf0e10cSrcweir			$counter++; 	 # counting the files in the cab file
364cdf0e10cSrcweir
365cdf0e10cSrcweir			my $onefile = ${$filesref}[$i];
366cdf0e10cSrcweir			my $nextfile = ${$filesref}[$i+1];
367cdf0e10cSrcweir
368cdf0e10cSrcweir			my $filecomponent = "";
369cdf0e10cSrcweir			my $nextcomponent = "";
370cdf0e10cSrcweir
371cdf0e10cSrcweir			if ( $onefile->{'componentname'} ) { $filecomponent = $onefile->{'componentname'}; }
372cdf0e10cSrcweir			if ( $nextfile->{'componentname'} ) { $nextcomponent = $nextfile->{'componentname'}; }
373cdf0e10cSrcweir
374cdf0e10cSrcweir			if ( $filecomponent eq $nextcomponent )	# all files of one component have to be in one cab file
375cdf0e10cSrcweir			{
376cdf0e10cSrcweir				next;		# nothing to do, this is not the last file of a component
377cdf0e10cSrcweir			}
378cdf0e10cSrcweir
379cdf0e10cSrcweir			if ( $cabfull )
380cdf0e10cSrcweir			{
381cdf0e10cSrcweir				my %media = ();
382cdf0e10cSrcweir				$cabfilenumber++;
383cdf0e10cSrcweir
384cdf0e10cSrcweir				$media{'DiskId'} = get_media_diskid($cabfilenumber);
385cdf0e10cSrcweir				# $media{'LastSequence'} = get_media_lastsequence($onefile);
386cdf0e10cSrcweir				$media{'LastSequence'} = $i + 1;	# This should be correct, also for unsorted files collectors
387cdf0e10cSrcweir				$media{'DiskPrompt'} = get_media_diskprompt();
388cdf0e10cSrcweir				$media{'Cabinet'} = generate_cab_filename_for_some_cabs($allvariables, $cabfilenumber);
389cdf0e10cSrcweir				$media{'VolumeLabel'} = get_media_volumelabel();
390cdf0e10cSrcweir				$media{'Source'} = get_media_source();
391cdf0e10cSrcweir
392cdf0e10cSrcweir				my $oneline = $media{'DiskId'} . "\t" . $media{'LastSequence'} . "\t" . $media{'DiskPrompt'} . "\t"
393cdf0e10cSrcweir						. $media{'Cabinet'} . "\t" . $media{'VolumeLabel'} . "\t" . $media{'Source'} . "\n";
394cdf0e10cSrcweir
395cdf0e10cSrcweir				push(@mediatable, $oneline);
396cdf0e10cSrcweir
397cdf0e10cSrcweir				# Saving the cabinet file name in the file collector
398cdf0e10cSrcweir
399cdf0e10cSrcweir				$media{'Cabinet'} =~ s/^\s*\#//;	# removing leading hash
400cdf0e10cSrcweir
401cdf0e10cSrcweir				for ( my $j = 0; $j <= $i; $j++ )
402cdf0e10cSrcweir				{
403cdf0e10cSrcweir					my $onefile = ${$filesref}[$j];
404cdf0e10cSrcweir					if ( ! $onefile->{'cabinet'} ) { $onefile->{'cabinet'} = $media{'Cabinet'}; }
405cdf0e10cSrcweir				}
406cdf0e10cSrcweir
407cdf0e10cSrcweir				$cabfull = 0;
408cdf0e10cSrcweir				$counter = 0;
409cdf0e10cSrcweir			}
410cdf0e10cSrcweir		}
411cdf0e10cSrcweir	}
412cdf0e10cSrcweir	elsif ( $installer::globals::one_cab_file )
413cdf0e10cSrcweir	{
414cdf0e10cSrcweir		my %media = ();
415cdf0e10cSrcweir		$diskid++;
416cdf0e10cSrcweir
417cdf0e10cSrcweir		my $maximumfile = $#{$filesref};
418cdf0e10cSrcweir
419cdf0e10cSrcweir		$media{'DiskId'} = get_media_diskid($diskid);
420cdf0e10cSrcweir		# $media{'LastSequence'} = ${$filesref}[$maximumfile]->{'sequencenumber'};	# sequence number of the last file
421cdf0e10cSrcweir		$media{'LastSequence'} = $maximumfile + 1; # This works also for unsorted file collector
422cdf0e10cSrcweir		$media{'DiskPrompt'} = get_media_diskprompt();
423cdf0e10cSrcweir		$media{'Cabinet'} = generate_cab_filename($allvariables);
424cdf0e10cSrcweir		$media{'VolumeLabel'} = get_media_volumelabel();
425cdf0e10cSrcweir		$media{'Source'} = get_media_source();
426cdf0e10cSrcweir
427cdf0e10cSrcweir		my $oneline = $media{'DiskId'} . "\t" . $media{'LastSequence'} . "\t" . $media{'DiskPrompt'} . "\t"
428cdf0e10cSrcweir					. $media{'Cabinet'} . "\t" . $media{'VolumeLabel'} . "\t" . $media{'Source'} . "\n";
429cdf0e10cSrcweir
430cdf0e10cSrcweir		push(@mediatable, $oneline);
431cdf0e10cSrcweir
432cdf0e10cSrcweir		# Saving the cabinet file name in the file collector
433cdf0e10cSrcweir
434cdf0e10cSrcweir		$media{'Cabinet'} =~ s/^\s*\#//;	# removing leading hash
435cdf0e10cSrcweir
436cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$filesref}; $i++ )
437cdf0e10cSrcweir		{
438cdf0e10cSrcweir			my $onefile = ${$filesref}[$i];
439cdf0e10cSrcweir			$onefile->{'cabinet'} = $media{'Cabinet'};
440cdf0e10cSrcweir		}
441cdf0e10cSrcweir	}
442cdf0e10cSrcweir	else
443cdf0e10cSrcweir	{
444cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: No cab file specification in globals.pm !", "create_media_table");
445cdf0e10cSrcweir	}
446cdf0e10cSrcweir
447cdf0e10cSrcweir	# Saving the file
448cdf0e10cSrcweir
449cdf0e10cSrcweir	my $mediatablename = $basedir . $installer::globals::separator . "Media.idt";
450cdf0e10cSrcweir	installer::files::save_file($mediatablename ,\@mediatable);
451*b274bc22SAndre Fischer    $installer::logger::Lang->printf("Created idt file: %s\n", $mediatablename);
452cdf0e10cSrcweir}
453cdf0e10cSrcweir
454cdf0e10cSrcweir1;
455