Subversion Repositories DevTools

Rev

Rev 4302 | Rev 4636 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4302 Rev 4635
Line 117... Line 117...
117
my $opt_pkgarch;
117
my $opt_pkgarch;
118
 
118
 
119
#
119
#
120
#   Options derived from script directives
120
#   Options derived from script directives
121
#
121
#
122
my $opt_control = '';
-
 
123
my $opt_prerm = '';
-
 
124
my $opt_postrm = '';
-
 
125
my $opt_preinst = '';
-
 
126
my $opt_postinst = '';
-
 
127
my $opt_description;
122
my $opt_description;
128
 
123
 
129
#
124
#
130
#   Globals
125
#   Globals
131
#
126
#
132
my @ResolveFileList;                    # Cached Package File List
127
my @ResolveFileList;                    # Cached Package File List
133
my @ResolveBinFileList;                 # Cached PackageBin File List
128
my @ResolveBinFileList;                 # Cached PackageBin File List
134
my @ResolveLibFileList;                 # Cached PackageLib File List
129
my @ResolveLibFileList;                 # Cached PackageLib File List
-
 
130
my %DebianControlFiles;                 # Control Files
-
 
131
my %DebianControlFileNames;             # Control Files by name
-
 
132
my @DependencyList;                     # Package Dependencies
135
 
133
 
136
#-------------------------------------------------------------------------------
134
#-------------------------------------------------------------------------------
137
# Function        : Main Entry point
135
# Function        : Main Entry point
138
#
136
#
139
# Description     : This function will be called when the package is initialised
137
# Description     : This function will be called when the package is initialised
Line 304... Line 302...
304
# Returns         : Nothing
302
# Returns         : Nothing
305
#
303
#
306
sub BuildDebianPackage
304
sub BuildDebianPackage
307
{
305
{
308
    Error ("BuildDebianPackage: No Control File or Package Description")
306
    Error ("BuildDebianPackage: No Control File or Package Description")
309
        unless ( $opt_control || $opt_description );
307
        unless ( exists($DebianControlFiles{'control'}) || $opt_description );
310
 
308
 
311
    #
309
    #
312
    #   Convert the FileSystem Image into a Debian Package
310
    #   Convert the FileSystem Image into a Debian Package
313
    #       Insert Debian control files
311
    #       Insert Debian control files
314
    #
312
    #
315
    Verbose ("Copy in the Debian Control Files");
313
    Verbose ("Copy in the Debian Control Files");
316
    mkdir ( "$DebianWorkDir/DEBIAN" );
314
    mkdir ( "$DebianWorkDir/DEBIAN" );
317
 
315
 
-
 
316
    #
318
    CopyFile ( $opt_prerm,    "/DEBIAN", "prerm" )    if $opt_prerm;
317
    #   Copy in all the named Debian Control files
319
    CopyFile ( $opt_postrm,   "/DEBIAN", "postrm" )   if $opt_postrm;
318
    #       Ignore any control file. It will be done next
-
 
319
    #
-
 
320
    foreach my $key ( keys %DebianControlFiles )
-
 
321
    {
-
 
322
        next if ($key eq 'control');
320
    CopyFile ( $opt_preinst,  "/DEBIAN", "preinst" )  if $opt_preinst;
323
        CopyFile ( $DebianControlFiles{$key},    "/DEBIAN", $key );
-
 
324
    }
-
 
325
    
-
 
326
    #
-
 
327
    #   Massage the 'control' file
-
 
328
    #
321
    CopyFile ( $opt_postinst, "/DEBIAN", "postinst" ) if $opt_postinst;
329
    UpdateControlFile ($DebianControlFiles{'control'} );
322
 
330
 
-
 
331
    #
323
    UpdateControlFile ($opt_control );
332
    #   Mark all files in the debian folder as read-execute
-
 
333
    #
324
    System ( 'chmod', '-R', 'a+rx', "$DebianWorkDir/DEBIAN" );
334
    System ( 'chmod', '-R', 'a+rx', "$DebianWorkDir/DEBIAN" );
325
    System ( 'build_dpkg.sh', '-b', $DebianWorkDir);
335
    System ( 'build_dpkg.sh', '-b', $DebianWorkDir);
326
    System ( 'mv', '-f', "$DebianWorkDir.deb", $opt_output );
336
    System ( 'mv', '-f', "$DebianWorkDir.deb", $opt_output );
327
 
337
 
328
    System ("build_dpkg.sh", '-I', $opt_output) if (IsVerbose(1));
338
    System ("build_dpkg.sh", '-I', $opt_output) if (IsVerbose(1));
Line 355... Line 365...
355
    {
365
    {
356
        CreateControlFile();
366
        CreateControlFile();
357
        return;
367
        return;
358
    }
368
    }
359
 
369
 
-
 
370
    #
-
 
371
    #   User has provided a control file
-
 
372
    #       Tweak the internals
-
 
373
    #
360
    Verbose ("UpdateControlFile: $dst" );
374
    Verbose ("UpdateControlFile: $dst" );
361
    $src = ResolveFile( 0, $src );
375
    $src = ResolveFile( 0, $src );
362
 
376
 
-
 
377
    #   Calc depends line
-
 
378
    my $depData = join (',', @DependencyList );
-
 
379
 
363
    open (SF, '<', $src) || Error ("UpdateControlFile: Cannot open $src");
380
    open (SF, '<', $src) || Error ("UpdateControlFile: Cannot open:$src, $!");
364
    open (DF, '>', $dst) || Error ("UpdateControlFile: Cannot create:$dst");
381
    open (DF, '>', $dst) || Error ("UpdateControlFile: Cannot create:$dst, $!");
365
    while ( <SF> )
382
    while ( <SF> )
366
    {
383
    {
367
        s~\s*$~~;
384
        s~\s*$~~;
368
        if ( m~^Package:~ ) {
385
        if ( m~^Package:~ ) {
369
            $_ = "Package: $opt_name";
386
            $_ = "Package: $opt_name";
Line 374... Line 391...
374
        } elsif ( m~^Architecture:~ ) {
391
        } elsif ( m~^Architecture:~ ) {
375
            $_ = "Architecture: $opt_pkgarch";
392
            $_ = "Architecture: $opt_pkgarch";
376
 
393
 
377
        } elsif ( $opt_description && m~^Description:~ ) {
394
        } elsif ( $opt_description && m~^Description:~ ) {
378
            $_ = "Description: $opt_description";
395
            $_ = "Description: $opt_description";
-
 
396
 
-
 
397
        } elsif ( m~^Depends:~ ) {
-
 
398
            $_ = "Depends: $depData";
-
 
399
            $depData = '';
379
        }
400
        }
380
        print DF $_ , "\n";
401
        print DF $_ , "\n";
381
    }
402
    }
-
 
403
 
382
    close (SF);
404
    close (SF);
383
    close (DF);
405
    close (DF);
-
 
406
 
-
 
407
    #
-
 
408
    #   Warn if Depends section is needed
-
 
409
    #
-
 
410
    Error ("No Depends section seen in user control file") 
-
 
411
        if ($depData);
384
}
412
}
385
 
413
 
386
#-------------------------------------------------------------------------------
414
#-------------------------------------------------------------------------------
387
# Function        : CreateControlFile
415
# Function        : CreateControlFile
388
#
416
#
Line 396... Line 424...
396
{
424
{
397
    my $dst = "$DebianWorkDir/DEBIAN/control";
425
    my $dst = "$DebianWorkDir/DEBIAN/control";
398
 
426
 
399
    Verbose ("CreateControlFile: $dst" );
427
    Verbose ("CreateControlFile: $dst" );
400
 
428
 
-
 
429
    my $depData = join (',', @DependencyList );
-
 
430
 
401
    open (DF, '>', $dst) || Error ("CreateControlFile: Cannot create:$dst");
431
    open (DF, '>', $dst) || Error ("CreateControlFile: Cannot create:$dst");
402
    print DF "Package: $opt_name\n";
432
    print DF "Package: $opt_name\n";
403
    print DF "Version: $opt_buildversion\n";
433
    print DF "Version: $opt_buildversion\n";
404
    print DF "Section: main\n";
434
    print DF "Section: main\n";
405
    print DF "Priority: standard\n";
435
    print DF "Priority: standard\n";
406
    print DF "Architecture: $opt_pkgarch\n";
436
    print DF "Architecture: $opt_pkgarch\n";
407
    print DF "Essential: No\n";
437
    print DF "Essential: No\n";
408
    print DF "Maintainer: Vix Technology\n";
438
    print DF "Maintainer: Vix Technology\n";
409
    print DF "Description: $opt_description\n";
439
    print DF "Description: $opt_description\n";
-
 
440
    print DF "Depends: $depData\n" if ($depData);
-
 
441
 
410
    close (DF);
442
    close (DF);
411
}
443
}
412
 
444
 
413
#-------------------------------------------------------------------------------
445
#-------------------------------------------------------------------------------
414
# Function        : SetVerbose
446
# Function        : SetVerbose
Line 442... Line 474...
442
#                       --Control=file
474
#                       --Control=file
443
#                       --PreRm=file
475
#                       --PreRm=file
444
#                       --PostRm=file
476
#                       --PostRm=file
445
#                       --PreInst=file
477
#                       --PreInst=file
446
#                       --PostInst=file
478
#                       --PostInst=file
-
 
479
#                         
447
#
480
#
448
# Returns         : Nothing
481
# Returns         : Nothing
449
#
482
#
450
sub DebianFiles
483
sub DebianFiles
451
{
484
{
452
    #
485
    #
453
    #   Exctact names
486
    #   Extract names
454
    #
487
    #
455
    Verbose ("Specify Debian Control Files and Scripts");
488
    Verbose ("Specify Debian Control Files and Scripts");
456
    foreach  ( @_ )
489
    foreach  ( @_ )
457
    {
490
    {
458
        if ( m/^--Control=(.+)/ ) {
491
        if ( m/^--Control=(.+)/i ) {
459
            $opt_control = $1;
492
            DebianControlFile('control',$1)
460
 
493
 
461
        } elsif ( m/^--PreRm=(.+)/ ) {
494
        } elsif ( m/^--PreRm=(.+)/i ) {
462
            $opt_prerm = $1;
495
            DebianControlFile('prerm',$1)
463
 
496
 
464
        } elsif ( m/^--PostRm=(.+)/ ) {
497
        } elsif ( m/^--PostRm=(.+)/i ) {
465
            $opt_postrm = $1;
498
            DebianControlFile('postrm',$1)
466
 
499
 
467
        } elsif ( m/^--PreInst=(.+)/ ) {
500
        } elsif ( m/^--PreInst=(.+)/i ) {
468
            $opt_preinst  = $1;
501
            DebianControlFile('preinst',$1)
469
 
502
 
470
        } elsif ( m/^--PostInst=(.+)/ ) {
503
        } elsif ( m/^--PostInst=(.+)/i ) {
471
            $opt_postinst = $1;
504
            DebianControlFile('postinst',$1)
472
 
505
 
473
        } else {
506
        } else {
474
            Error ("DebianFiles: Unknown option: $_");
507
            Error ("DebianFiles: Unknown option: $_");
475
        }
508
        }
476
    }
509
    }
477
}
510
}
478
 
511
 
479
#-------------------------------------------------------------------------------
512
#-------------------------------------------------------------------------------
-
 
513
# Function        : DebianControlFile 
-
 
514
#
-
 
515
# Description     : Add special control files to the Debian Installer 
-
 
516
#                   Not useful for embedded installers
-
 
517
#
-
 
518
#                   More general than DebianFiles()
-
 
519
#
-
 
520
# Inputs          : name            - Target Name
-
 
521
#                                     If the name starts with 'package.' then it will be replaced
-
 
522
#                                     with the name of the current package
-
 
523
#                   file            - Source File Name
-
 
524
#
-
 
525
# Returns         : 
-
 
526
#
-
 
527
sub DebianControlFile
-
 
528
{
-
 
529
    my ($name, $file, $misc) = @_;
-
 
530
    Error ("DebianControlFile: Unknown argument: $misc") if defined $misc;
-
 
531
 
-
 
532
    #
-
 
533
    #   Some control files need to have the package name prepended
-
 
534
    #
-
 
535
    $name =~ s~^package\.~$opt_name.~;
-
 
536
 
-
 
537
    #
-
 
538
    #   Only allow one file of each type
-
 
539
    #       Try to protect the user by testing for names by lowercase
-
 
540
    #
-
 
541
    my $simpleName = lc($name);
-
 
542
    Error("DebianControlFile: Multiple definitions for '$name' not allowed")
-
 
543
        if (exists $DebianControlFileNames{$simpleName});
-
 
544
 
-
 
545
    Error("DebianControlFile: $name. File not found", "Control target: $name", "File not found: $file")
-
 
546
        unless (-f $file);
-
 
547
 
-
 
548
    #
-
 
549
    #   Add info to data structures
-
 
550
    #
-
 
551
    $DebianControlFiles{$name} = $file;
-
 
552
    $DebianControlFileNames{$simpleName} = $name;
-
 
553
}
-
 
554
 
-
 
555
#-------------------------------------------------------------------------------
-
 
556
# Function        : DebianDepends 
-
 
557
#
-
 
558
# Description     : This directive allows simple dependency information to be  
-
 
559
#                   inserted into the control file
-
 
560
#
-
 
561
#                   Note useful in embedded system
-
 
562
#
-
 
563
# Inputs          : Entry             - A dependency entry
-
 
564
#                   ...               - More entries
-
 
565
#                   
-
 
566
#
-
 
567
# Returns         : Nothing
-
 
568
#
-
 
569
sub DebianDepends
-
 
570
{
-
 
571
    push @DependencyList, @_;
-
 
572
}
-
 
573
 
-
 
574
 
-
 
575
#-------------------------------------------------------------------------------
480
# Function        : PackageDescription
576
# Function        : PackageDescription
481
#
577
#
482
# Description     : Specify the Package Description
578
# Description     : Specify the Package Description
483
#                   Keep it short
579
#                   Keep it short
484
#
580
#