#!/usr/bin/perl -w
eval 'LANG=C exec perl -w -S $0 ${1+"$@"}'
    if $running_under_some_shell;
$running_under_some_shell = 0;

######################################################################
#
# Copyright  Freescale Semiconductor, Inc. 2007. All rights reserved.
#
# Stuart Hughes, stuarth@freescale.com, June 2007
#
# This file is part of LTIB.
#
# LTIB 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; either version 2 of the License, or
# (at your option) any later version.
#
# LTIB 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 LTIB; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
#
# Output just the package information section of an LTIB .config
# file to stdout
#
# Example usage:
# spit_profile config/platform/mpc8349itx-gp/.config > config/profiles/new_prof.config
#
######################################################################

$con = shift;
die "spit_profile <.config> \n" unless $con;

open(CON, $con) or die "open $con : $!\n";
$st = 0;
while(<CON>) {
    if($st == 0) {
        $st = 1 if m,^# Package list$,;
        next;
    }
    if($st == 1) {
        last if m,^# Target System Configuration$,;
        next if m,^#?\s*$,;
        print;
    }
}
close CON;
