Radix cross Linux Build System

Cross-platform build system is designed to build distributions of different operating systems for a set of target devices

39 Commits   2 Branches   2 Tags
     5         kx #!/bin/env perl
     5         kx 
     5         kx use FindBin;
     5         kx use lib $FindBin::Bin;
     5         kx 
     5         kx use strict;
     5         kx use warnings FATAL => 'all';
     5         kx 
     5         kx use IO::Handle;
     5         kx use File::Basename;
     5         kx use File::Temp;
     5         kx 
     5         kx use _kxLab;
     5         kx 
     5         kx #
     5         kx # Generate $(HARDWARE).pkglist file for current directory
     5         kx #
     5         kx # usage:
     5         kx #   $0 topdir toolchain hardware
     5         kx #
     5         kx # where:
     5         kx #      'topdir' - is a absolute path to the top directory of checked out branch
     5         kx #   'toolchain' - is a TOOLCHAIN name
     5         kx #    'hardware' - is a HARDWARE variant
     5         kx #
     5         kx 
     5         kx # global variables
     5         kx my ($build_system);
     5         kx my ($topdir, $toolchain, $hardware, $flavour);
     5         kx my ($target_build_dir, $requires_file);
     5         kx my ($pkglist_file);
     5         kx my ($system_version, $distro_name, $distro_version, $url);
     5         kx my $tarball_suffix = "txz";
     5         kx 
     5         kx my %sub_trees;
     5         kx my %tree;
     5         kx 
     5         kx 
     5         kx sub usage
     5         kx {
     5         kx   print <<EOF;
     5         kx 
     5         kx Usage: $0 topdir toolchain hardware
     5         kx Where:
     5         kx           topdir - is a absolute path to the top of checked out branch;
     5         kx        toolchain - is a TOOLCHAIN name;
     5         kx         hardware - is a HARDWARE variant.
     5         kx 
     5         kx EOF
     5         kx   exit;
     5         kx }
     5         kx 
     5         kx #
     5         kx # Getting information from build-system/constants.mk
     5         kx #
     5         kx sub system_version
     5         kx {
     5         kx   my $build_system = shift;
     5         kx   my $version;
     5         kx 
     5         kx   open( FILE, "< $build_system/constants.mk" );
     5         kx 
     5         kx   while( <FILE> )
     5         kx   {
     5         kx     if( /^SYSTEM_VERSION(.+= +)(.+)/ )
     5         kx     {
     5         kx       $version = $2;
     5         kx     }
     5         kx   }
     5         kx   close( FILE );
     5         kx 
     5         kx   return $version;
     5         kx }
     5         kx 
     5         kx sub distro_name
     5         kx {
     5         kx   my $build_system = shift;
     5         kx   my $name;
     5         kx 
     5         kx   open( FILE, "< $build_system/constants.mk" );
     5         kx 
     5         kx   while( <FILE> )
     5         kx   {
     5         kx     if( /^DISTRO_NAME(.+= +)(.+)/ )
     5         kx     {
     5         kx       $name = $2;
     5         kx     }
     5         kx   }
     5         kx   close( FILE );
     5         kx 
     5         kx   return $name;
     5         kx }
     5         kx 
     5         kx sub distro_version
     5         kx {
     5         kx   my $build_system = shift;
     5         kx   my $name;
     5         kx 
     5         kx   open( FILE, "< $build_system/constants.mk" );
     5         kx 
     5         kx   while( <FILE> )
     5         kx   {
     5         kx     if( /^DISTRO_VERSION(.+= +)(.+)/ )
     5         kx     {
     5         kx       $name = $2;
     5         kx     }
     5         kx   }
     5         kx   close( FILE );
     5         kx 
     5         kx   return $name;
     5         kx }
     5         kx 
     5         kx sub bug_url
     5         kx {
     5         kx   my $build_system = shift;
     5         kx   my $url;
     5         kx 
     5         kx   open( FILE, "< $build_system/constants.mk" );
     5         kx 
     5         kx   while( <FILE> )
     5         kx   {
     5         kx     if( /^BUG_URL(.+= +)(.+)/ )
     5         kx     {
     5         kx       $url = $2;
     5         kx     }
     5         kx   }
     5         kx   close( FILE );
     5         kx 
     5         kx   return $url;
     5         kx }
     5         kx 
     5         kx #
     5         kx # value_from_makefile( $makefile, $variable_name, $stop_line ):
     5         kx # ------------------------------------------------------------
     5         kx #   This function returns the value of variable defined in the
     5         kx #   Makefile on global level before od REQUIRES declaration.
     5         kx #
     5         kx #   The optional $stop_line argument presents the start of the
     5         kx #   line which terminates the analized part of Makefile.
     5         kx #
     5         kx sub value_from_makefile
     5         kx {
     5         kx   my $makefile  = shift;
     5         kx   my $vname     = shift;
     5         kx   my $stop_line = shift;
     5         kx   my $value     = "";
     5         kx 
     5         kx   if( !defined $stop_line || $stop_line eq '' )
     5         kx   {
     5         kx     $stop_line = "__END_OF_REQUIRES__";
     5         kx   }
     5         kx   else
     5         kx   {
     5         kx     $stop_line = "^" . $stop_line;
     5         kx   }
     5         kx 
     5         kx   my $cdir = dirname( $makefile );
     5         kx 
     5         kx   my $shell_output = <<`SHELL`;
     5         kx cd $cdir
     5         kx head -n `cat Makefile | grep -n "$stop_line" | cut -f 1 -d ':'` Makefile | \
     5         kx   make TOOLCHAIN=$toolchain HARDWARE=$hardware FLAVOUR=$flavour -f - -p __build_requires__ 2>/dev/null | grep "$vname"
     5         kx exit 0
     5         kx SHELL
     5         kx 
     5         kx   if( $shell_output =~ m/^$vname(.+= +)(.+)/gm )
     5         kx   {
     5         kx     $value = $2;
     5         kx   }
     5         kx 
     5         kx   return $value;
     5         kx }
     5         kx 
     5         kx #
     5         kx # Getting information from Makefile
     5         kx #
     5         kx sub pkg_rootfs_target
     5         kx {
     5         kx   my $makefile = shift;
     5         kx   my $install = "";
     5         kx 
     5         kx   open( FILE, "< $makefile" );
     5         kx 
     5         kx   while( <FILE> )
     5         kx   {
     5         kx     if( /^ROOTFS_TARGETS(.+= +)(.+)/ )
     5         kx     {
     5         kx       if( $2 ne "" ) { $install = "install"; }
     5         kx     }
     5         kx     elsif( /^ROOTFS_UPDATE_TARGETS(.+= +)(.+)/ )
     5         kx     {
     5         kx       if( $2 ne "" ) { $install = "update"; }
     5         kx     }
     5         kx   }
     5         kx   close( FILE );
     5         kx 
     5         kx   if( $install eq "" ) { $install = "no";  }
     5         kx 
     5         kx   return $install;
     5         kx }
     5         kx 
     5         kx sub pkg_group
     5         kx {
     5         kx   my $makefile = shift;
     5         kx   my $group;
     5         kx 
     5         kx   open( FILE, "< $makefile" );
     5         kx 
     5         kx   while( <FILE> )
     5         kx   {
     5         kx     if( /^PKG_GROUP(.+= +)(.+)/ )
     5         kx     {
     5         kx       $group = $2;
     5         kx     }
     5         kx   }
     5         kx   close( FILE );
     5         kx 
     5         kx   return $group;
     5         kx }
     5         kx 
     5         kx sub pkg_name
     5         kx {
     5         kx   my $makefile = shift;
     5         kx   my $name = "";
     5         kx 
     5         kx   open( FILE, "< $makefile" );
     5         kx 
     5         kx   while( <FILE> )
     5         kx   {
     5         kx     if( /^[A-Z_0-9]*_PKG_NAME(.+= +)(.+)/ )
     5         kx     {
     5         kx       $name = $2;
     5         kx     }
     5         kx   }
     5         kx   close( FILE );
     5         kx 
     5         kx   return $name;
     5         kx }
     5         kx 
     5         kx sub pkg_version
     5         kx {
     5         kx   my $makefile = shift;
     5         kx   my $version;
     5         kx 
     5         kx   my $stop_line;
     5         kx 
     5         kx   open( FILE, "< $makefile" );
     5         kx 
     5         kx   while( <FILE> )
     5         kx   {
     5         kx     if( /^([A-Z_0-9]*_PKG_VERSION)(.+= +)(.+)/ )
     5         kx     {
     5         kx       $stop_line  = $1;
     5         kx       $version    = $3;
     5         kx     }
     5         kx   }
     5         kx   close( FILE );
     5         kx 
     5         kx   # check if version is present as a reference to some variable:
     5         kx   if( $version =~ m/^\$\((.+)\)/ )
     5         kx   {
     5         kx     my $vname = $1;
     5         kx 
     5         kx     # get value of referenced variable
     5         kx     $version = value_from_makefile( $makefile, $vname, $stop_line );
     5         kx   }
     5         kx 
     5         kx   return $version;
     5         kx }
     5         kx 
     5         kx sub pkg_license
     5         kx {
     5         kx   my $makefile = shift;
     5         kx   my $license;
     5         kx 
     5         kx   open( FILE, "< $makefile" );
     5         kx 
     5         kx   while( <FILE> )
     5         kx   {
     5         kx     if( /^[A-Z_0-9]*_PKG_LICENSE(.+= +)(.+)/ )
     5         kx     {
     5         kx       $license = $2;
     5         kx     }
     5         kx   }
     5         kx   close( FILE );
     5         kx 
     5         kx   return $license;
     5         kx }
     5         kx 
     5         kx sub pkg_short_description
     5         kx {
     5         kx   my $makefile = shift;
     5         kx   my $description;
     5         kx 
     5         kx   open( FILE, "< $makefile" );
     5         kx 
     5         kx   while( <FILE> )
     5         kx   {
     5         kx     if( /^[A-Z_0-9]*_PKG_SHORT_DESCRIPTION(.+= +)(.+)/ )
     5         kx     {
     5         kx       $description = $2;
     5         kx     }
     5         kx   }
     5         kx   close( FILE );
     5         kx 
     5         kx   #
     5         kx   # In Makefiles we have to mask characters '\', '&', '*', '(', ')' inside
     5         kx   # the new value in the assignment operator with backslash. So, for axample,
     5         kx   # the value "name & \ * ( ) end" we have to assign as follow
     5         kx   #
     5         kx   # ..._SHORT_DESCRIPTION = name \& \\ \* \( \) end
     5         kx   #
     5         kx   # Here we have to remove backslashes and fill escaped symbols as is:
     5         kx   #
     5         kx   $description =~ s/\\(.?)/$1/g;
     5         kx 
     5         kx   return $description;
     5         kx }
     5         kx 
     5         kx 
     5         kx sub get_treedirs
     5         kx {
     5         kx   my @list;
     5         kx 
     5         kx   seek( REQUIRES_FILE, 0, SEEK_SET );
     5         kx 
     5         kx   while( <REQUIRES_FILE> )
     5         kx   {
     5         kx     if( /^TREEDIRS(.+= +)(.+)/ )
     5         kx     {
     5         kx       @list = split( ' ', $2 );
     5         kx     }
     5         kx   }
     5         kx 
     5         kx   return @list;
     5         kx }
     5         kx 
     5         kx sub get_root
     5         kx {
     5         kx   my $root;
     5         kx 
     5         kx   seek( REQUIRES_FILE, 0, SEEK_SET );
     5         kx 
     5         kx   while( <REQUIRES_FILE> )
     5         kx   {
     5         kx     if( /^# ROOT(=)(.+)/ )
     5         kx     {
     5         kx       $root = $2;
     5         kx     }
     5         kx   }
     5         kx 
     5         kx   return $root;
     5         kx }
     5         kx 
     5         kx sub get_deps
     5         kx {
     5         kx   my %deps;
     5         kx 
     5         kx   seek( REQUIRES_FILE, 0, SEEK_SET );
     5         kx 
     5         kx   while( <REQUIRES_FILE> )
     5         kx   {
     5         kx     if( /(.+)(: +)(.+)/ )
     5         kx     {
     5         kx       $deps{$1} = $3;
     5         kx     }
     5         kx   }
     5         kx   return %deps;
     5         kx }
     5         kx 
     5         kx my $root_node = 1;
     5         kx 
     5         kx #
     5         kx # PACKAGE HASH:
     5         kx # ============
     5         kx #
     5         kx #   name              => $(PKG_NAME)       from Makefile
     5         kx #   version           => $(PKG_VERSION)    from Makefile
     5         kx #   group             => $(PKG_GROUP)      from Makefile {app,base,dev,libs,net,...}
     5         kx #
     5         kx #   arch              => $toolchain        from comandline args
     5         kx #   hardware          => $hardware         from comandline args
     5         kx #   flavour           => $flavour          from comandline args for ROOT pkg, from REQUIRES for dependencies
     5         kx #   tarball           => "$name-$version-$arch-$distro_name-$distro_version.$tarball_suffix"
     5         kx #
     5         kx #   distro_name       => $(DISTRO_NAME)    from build-system/constants.mk
     5         kx #   distro_version    => $(DISTRO_VERSION) from build-system/constants.mk
     5         kx #   url               => $(BUG_URL)        from build-system/constants.mk
     5         kx #   license           =>                   from Makefile
     5         kx #   short_description =>                   from Makefile
     5         kx #   description       =>    first line     from .DESCRIPTION
     5         kx #   uncompressed_size =>                   from .PKGINFO
     5         kx #   total_files       =>                   from .PKGINFO
     5         kx #
     5         kx #   dir               => path to Makefile  from .$(HW)_requires
     5         kx #   children          =>
     5         kx #
     5         kx sub fill_package_info
     5         kx {
     5         kx   my $base_dir = shift;
     5         kx   my $makefile = shift;
     5         kx   my $flavour  = shift;
     5         kx   my ( $product_path, $tarball_file );
     5         kx   my %pkg;
     5         kx 
     5         kx   $pkg{'dir'}     = $base_dir;
     5         kx   $pkg{'install'} = pkg_rootfs_target( $makefile );
     5         kx 
     5         kx   $pkg{'name'} = pkg_name( $makefile );
     5         kx   if( $pkg{'name'} eq "" )
     5         kx   {
     5         kx     # There is no package for this Makefile
     5         kx     $pkg{'name'} = $pkg{'dir'};
     5         kx     return %pkg;
     5         kx   }
     5         kx 
     5         kx   $pkg{'version'}           = pkg_version( $makefile );
     5         kx   $pkg{'arch'}              = $toolchain;
     5         kx   $pkg{'hardware'}          = $hardware;
     5         kx   $pkg{'flavour'}           = $flavour;
     5         kx   $pkg{'group'}             = pkg_group( $makefile );
     5         kx   $pkg{'distro_name'}       = $distro_name;
     5         kx   $pkg{'distro_version'}    = $distro_version;
     5         kx   $pkg{'url'}               = $url;
     5         kx   $pkg{'license'}           = pkg_license( $makefile );
     5         kx   $pkg{'short_description'} = pkg_short_description( $makefile );
     5         kx 
     5         kx   $pkg{'tarball'} = $pkg{'name'}    . "-" . 
     5         kx                     $pkg{'version'} . "-" . 
     5         kx                     $pkg{'arch'}    . "-" . 
     5         kx                     $distro_name    . "-" . 
     5         kx                     $distro_version . "." . 
     5         kx                     $tarball_suffix;
     5         kx 
     5         kx   return %pkg;
     5         kx }
     5         kx 
     5         kx 
     5         kx 
     5         kx #
     5         kx # Parse the command line options
     5         kx #
     5         kx 
     5         kx # Get the rest arguments of the command line
     5         kx $topdir    = shift;
     5         kx $toolchain = shift;
     5         kx $hardware  = shift;
     5         kx $flavour   = shift;
     5         kx 
     5         kx my $makefile = "Makefile";
     5         kx 
     5         kx if( ! defined $topdir    or $topdir eq "" )    { usage; }
     5         kx if( ! defined $toolchain or $toolchain eq "" ) { usage; }
     5         kx if( ! defined $hardware  or $hardware eq "" )  { usage; }
     5         kx if( ! defined $flavour   or $flavour eq "" )   { $flavour = ""; }
     5         kx 
     5         kx _kxLab::error( "$0: $topdir is not a directory" ) if( ! -d $topdir );
     5         kx _kxLab::error( "$0: Makefile missing: $makefile" ) if ( ! -f $makefile );
     5         kx 
     5         kx $build_system = $topdir . "/build-system";
     5         kx 
     5         kx $system_version = system_version( $build_system );
     5         kx $distro_name    = distro_name( $build_system );
     5         kx $distro_version = distro_version( $build_system );
     5         kx $url            = bug_url( $build_system );
     5         kx 
     5         kx 
     5         kx if( $flavour eq "" )
     5         kx {
     5         kx   $target_build_dir  = "." . $toolchain . "/" . $hardware;
     5         kx }
     5         kx else
     5         kx {
     5         kx   $target_build_dir  = "." . $toolchain . "/" . $hardware . "/" . $flavour;
     5         kx }
     5         kx 
     5         kx $requires_file  = $target_build_dir . "/.requires";
     5         kx 
     5         kx if( $flavour eq "" )
     5         kx {
     5         kx   $pkglist_file   = $target_build_dir . "/" . $hardware . ".pkglist";
     5         kx }
     5         kx else
     5         kx {
     5         kx   $pkglist_file   = $target_build_dir . "/" . $hardware . "-" . $flavour . ".pkglist";
     5         kx }
     5         kx 
     5         kx 
     5         kx # open the intput file
     5         kx open(REQUIRES_FILE, "< $requires_file") or
     5         kx   _kxLab::error( "$0: Could not open $requires_file file: $!" );
     5         kx # open the output files
     5         kx open(PKGLIST_FILE, "> $pkglist_file") or
     5         kx   _kxLab::error( "$0: Could not open $pkglist_file file: $!" );
     5         kx 
     5         kx 
     5         kx my $root     = get_root();
     5         kx my @treedirs = get_treedirs();
     5         kx my %deps     = get_deps();
     5         kx 
     5         kx #
     5         kx # This is the root package
     5         kx #
     5         kx %tree = fill_package_info( $root, $makefile, $flavour );
     5         kx 
     5         kx my %sequence;
     5         kx my $order = 0;
     5         kx 
     5         kx #################################################################
     5         kx # if( there is any dependencies )
     5         kx #
     5         kx if( %deps )
     5         kx {
     5         kx   my @dep_keys = keys %deps;
     5         kx 
     5         kx   my $count = scalar( keys %deps );
     5         kx 
     5         kx   foreach my $dir ( @treedirs )
     5         kx   {
     5         kx     if( ! grep { $_ eq $dir } @dep_keys )
     5         kx     {
     5         kx       my $key = $dir;
     5         kx       $sequence{$key} = ++$order;
     5         kx       @treedirs = grep { $_ ne $key } @treedirs;
     5         kx 
     5         kx       # Split dir^flavour:
     5         kx       my ($d, $f);
     5         kx       $d = `echo $dir | cut -f 1 -d '^'`;
     5         kx       $d =~ s/^\s+|\s+$//;
     5         kx       if( $dir =~ m/\^/ )
     5         kx       {
     5         kx         $f = `echo $dir | cut -f 2 -d '^'`;
     5         kx         $f =~ s/^\s+|\s+$//;
     5         kx       }
     5         kx       else
     5         kx       {
     5         kx         $f = "";
     5         kx       }
     5         kx 
     5         kx       # Insert into sub_trees:
     5         kx       my %pkg = fill_package_info( $d, $topdir . "/" . $d . "/Makefile", $f );
     5         kx       $sub_trees{$dir} = \%pkg;
     5         kx 
     5         kx       delete $deps{$dir};
     5         kx     }
     5         kx   }
     5         kx 
     5         kx 
     5         kx   for( my $i = 0; $i < $count; ++$i )
     5         kx   {
     5         kx     my @installed = keys %sequence;
     5         kx 
     5         kx     foreach my $key (sort keys %deps)
     5         kx     {
     5         kx       my $ok = 1;
     5         kx       my @dirs = split( ' ', $deps{$key} );
     5         kx 
     5         kx       if( $key ne "all" )
     5         kx       {
     5         kx         foreach my $dir ( @dirs )
     5         kx         {
     5         kx           if( ! grep { $_ eq $dir } @installed )
     5         kx           {
     5         kx             $ok = 0;
     5         kx           }
     5         kx         }
     5         kx 
     5         kx         if( $ok == 1 )
     5         kx         {
     5         kx           $sequence{$key} = ++$order;
     5         kx 
     5         kx           # Split dir^flavour:
     5         kx           my ($d, $f);
     5         kx           $d = `echo $key | cut -f 1 -d '^'`;
     5         kx           $d =~ s/^\s+|\s+$//;
     5         kx           if( $key =~ m/\^/ )
     5         kx           {
     5         kx             $f = `echo $key | cut -f 2 -d '^'`;
     5         kx             $f =~ s/^\s+|\s+$//;
     5         kx           }
     5         kx           else
     5         kx           {
     5         kx             $f = "";
     5         kx           }
     5         kx 
     5         kx           # create package node:
     5         kx           my %pkg = fill_package_info( $d, $topdir . "/" . $d . "/Makefile", $f );
     5         kx           # add children:
     5         kx           foreach my $dir ( @dirs )
     5         kx           {
     5         kx             my $child = $sub_trees{$dir};
     5         kx             push( @{$pkg{'children'}}, $child );
     5         kx           }
     5         kx 
     5         kx           # insert new sub tree into $sub_tree:
     5         kx           $sub_trees{$key} = \%pkg;
     5         kx 
     5         kx           delete $deps{$key};
     5         kx         }
     5         kx       }
     5         kx     }
     5         kx   }
     5         kx 
     5         kx   #
     5         kx   # The root node children
     5         kx   #
     5         kx   my @dirs = split( ' ', $deps{'all'} );
     5         kx   foreach my $dir ( @dirs )
     5         kx   {
     5         kx     my $child = $sub_trees{$dir};
     5         kx     push( @{$tree{'children'}}, $child );
     5         kx   }
     5         kx 
     5         kx }
     5         kx else
     5         kx {
     5         kx   my %pkg;
     5         kx 
     5         kx   $pkg{'dir'}  = "void";
     5         kx   $pkg{'name'} = "void";
     5         kx 
     5         kx   push( @{$tree{'children'}}, \%pkg );
     5         kx }
     5         kx #
     5         kx # End if( there is any dependencies )
     5         kx #################################################################
     5         kx 
     5         kx 
     5         kx #################################################################
     5         kx # Building Required Packages List:
     5         kx #
     5         kx sub compare_order
     5         kx {
     5         kx   $sequence{$a} <=> $sequence{$b};
     5         kx }
     5         kx 
     5         kx print PKGLIST_FILE "#\n";
     5         kx print PKGLIST_FILE "# file format:\n";
     5         kx print PKGLIST_FILE "# ===========\n";
     5         kx print PKGLIST_FILE "#\n";
     5         kx print PKGLIST_FILE "# Each line contains six fields separated by colon symbol ':' like following.\n";
     5         kx print PKGLIST_FILE "#\n";
     5         kx print PKGLIST_FILE "# pkgname:version:description:tarball:procedure:priority\n";
     5         kx print PKGLIST_FILE "#\n";
     5         kx print PKGLIST_FILE "# where:\n";
     5         kx print PKGLIST_FILE "#\n";
     5         kx print PKGLIST_FILE "#   pkgname     - should be the same as the value of pkgname  in the '.DESCRIPTION' file;\n";
     5         kx print PKGLIST_FILE "#   version     - package version for showing in check list  dialog box  if this file is\n";
     5         kx print PKGLIST_FILE "#                 used to complete common check dialog for installing group  of packages;\n";
     5         kx print PKGLIST_FILE "#   description - short description for showing in check list dialog box if this file is\n";
     5         kx print PKGLIST_FILE "#                 used to complete common check dialog for installing  group of packages;\n";
     5         kx print PKGLIST_FILE "#   tarball     - should end in '." . $tarball_suffix . "';\n";
     5         kx print PKGLIST_FILE "#   procedure   - installation procedure {install | update}:\n";
     5         kx print PKGLIST_FILE "#                  * 'install' - if package requires normal installation,\n";
     5         kx print PKGLIST_FILE "#                  * 'update'  - if already installed package should be updated by this\n";
     5         kx print PKGLIST_FILE "#                                package archive;\n";
     5         kx print PKGLIST_FILE "#   priority    - { REQUIRED|RECOMMENDED|OPTIONAL|SKIP }\n";
     5         kx print PKGLIST_FILE "#                  synonims:\n";
     5         kx print PKGLIST_FILE "#                    { REQUIRED    | required    | REQ | req }\n";
     5         kx print PKGLIST_FILE "#                    { RECOMMENDED | recommended | REC | rec }\n";
     5         kx print PKGLIST_FILE "#                    { OPTIONAL    | optional    | OPT | opt }\n";
     5         kx print PKGLIST_FILE "#                    { SKIP        | skip        | SKP | skp }\n";
     5         kx print PKGLIST_FILE "#\n";
     5         kx 
     5         kx 
     5         kx my $packages_done = 0;
     5         kx 
     5         kx sub print_result
     5         kx {
     5         kx   my $out_string = sprintf( "####### Packages Install List (done: %4d packages)\n", $packages_done );
     5         kx 
     5         kx   print $out_string;
     5         kx }
     5         kx 
     5         kx print "#######\n";
     5         kx 
     5         kx foreach my $dir (sort compare_order( (keys %sequence) ))
     5         kx {
     5         kx   my $package;
     5         kx 
     5         kx   if( $dir ne "all" )
     5         kx   {
     5         kx     $package = $sub_trees{$dir};
     5         kx     #
     5         kx     # Currently gcc-runtime has not ROOTFS_TARGET and not all packages requires GCC.
     5         kx     # We will not add GCC in this procedure forcibly. But developers have to care about
     5         kx     # competing packages GCC and gcc-runtime.
     5         kx     #
     5         kx     if( $package->{'install'} ne "no" )
     5         kx     {
     5         kx       if( $package->{'flavour'} eq "" )
     5         kx       {
     5         kx         print PKGLIST_FILE $package->{'name'}              . ":" .
     5         kx                            $package->{'version'}           . ":" .
     5         kx                            $package->{'short_description'} . ":" .
     5         kx                            $package->{'group'}             . "/" .
     5         kx                            $package->{'tarball'}           . ":" .
     5         kx                            $package->{'install'}           . ":REQUIRED\n";
     5         kx       }
     5         kx       else
     5         kx       {
     5         kx         print PKGLIST_FILE $package->{'name'}              . ":" .
     5         kx                            $package->{'version'}           . ":" .
     5         kx                            $package->{'short_description'} . ":" .
     5         kx                            $package->{'group'}             . "/" .
     5         kx                            $package->{'flavour'}           . "/" .
     5         kx                            $package->{'tarball'}           . ":" .
     5         kx                            $package->{'install'}           .  ":REQUIRED\n";
     5         kx       }
     5         kx       ++$packages_done;
     5         kx     }
     5         kx   }
     5         kx }
     5         kx 
     5         kx if( $tree{'install'} ne "no" )
     5         kx {
     5         kx   if( $tree{'flavour'} eq "" )
     5         kx   {
     5         kx     print PKGLIST_FILE $tree{'name'}              . ":" .
     5         kx                        $tree{'version'}           . ":" .
     5         kx                        $tree{'short_description'} . ":" .
     5         kx                        $tree{'group'}             . "/" .
     5         kx                        $tree{'tarball'}           . ":" .
     5         kx                        $tree{'install'}           . ":REQUIRED\n";
     5         kx   }
     5         kx   else
     5         kx   {
     5         kx     print PKGLIST_FILE $tree{'name'}              . ":" .
     5         kx                        $tree{'version'}           . ":" .
     5         kx                        $tree{'short_description'} . ":" .
     5         kx                        $tree{'group'}             . "/" .
     5         kx                        $tree{'flavour'}           . "/" .
     5         kx                        $tree{'tarball'}           . ":" .
     5         kx                        $tree{'install'}           .  ":REQUIRED\n";
     5         kx   }
     5         kx   ++$packages_done;
     5         kx }
     5         kx 
     5         kx print_result();
     5         kx print "#######\n";
     5         kx #
     5         kx # End of Building Required Packages List.
     5         kx #################################################################
     5         kx 
     5         kx # close input files
     5         kx close REQUIRES_FILE;
     5         kx # close output files
     5         kx close PKGLIST_FILE;