view release on metacpan or search on metacpan
__END__
=head1 NAME
Embedix::ECD - Embedix Component Descriptions as objects
=head1 SYNOPSIS
instantiate from a file
my $ecd = Embedix::ECD->newFromFile('busybox.ecd');
my $other_ecd = Embedix::ECD->newFromFile('tinylogin.ecd');
access nodes
my $busybox = $ecd->System->Utilities->busybox;
build from scratch
my $server = Embedix::ECD::Group->new(name => 'Server');
my $www = Embedix::ECD::Group->new(name => 'WWW');
my $apache = Embedix::ECD::Component->new (
name => 'apache',
srpm => 'apache',
prompt => 'Include apache web server?',
help => 'The most popular http server on the internet',
);
$ecd->addChild($server);
$ecd->Server->addChild($www);
$ecd->Server->WWW->addChild($apache);
get/set attributes
my $srpm = $busybox->srpm();
$busybox->help('i am busybox of borg -- unix will be assimilated.');
$busybox->requires([
'libc.so.6',
'ld-linux.so.2',
'skellinux',
]);
combine Embedix::ECD objects together
$ecd->mergeWith($other_ecd);
print as text
=over 4
=item new(key => $value, ...)
This returns an Embedix::ECD object. It can be initialized with named
parameters which represent the attributes the object should have. The
set of valid attributes is described under L</Attributes>.
$system = Embedix::ECD::Group->new(name => 'System');
$utilities = Embedix::ECD::Group->new(name => 'Utilities');
$busybox = Embedix::ECD::Component->new(
name => 'busybox',
type => 'bool',
value => 0,
srpm => 'busybox',
static_size => 3006,
min_dynamic_size=> 0,
storage_size => 4408,
startup_time => 0,
keeplist => [ '/bin/busybox' ],
requires_expr => [
'(libc.so.6 == "y") &&',
'(ld-linux.so.2 == "y") &&',
'(skellinux == "y") &&',
'( (Misc-utilities == "y")',
'|| (File-compression-utilities == "y")',
'|| (Network-utilities == "y")',
'|| (Process-utilities == "y")',
'|| (Directory-utilities == "y")',
'|| (User-info-utilities == "y")',
$child_ecd = $ecd->getChild($name)
=item n($name)
C<n()> is an alias for C<getChild()>. "n" stands for "node" and is a
lot easier to type than "getChild".
$ecd->n('System')
->n('Utilities')
->n('busybox')
->n('long-ass-option-name-with-redundant-information');
=item addChild($obj)
This adds a child to the current node.
$ecd->addChild($obj)
=item delChild($obj) or delChild($name)
$ecd->hasChildren()
=back
=head2 Accessing Child Nodes via AUTOLOAD
The name of a node can be used as a method. This is what makes it
possible to say something like:
my $busybox = $ecd->System->Utilities->busybox;
and get back the Embedix::ECD::Component object that contains the
information for the busybox package. "System", "Utilities", and
"busybox" are not predefined methods in Embedix::ECD or any of its
subclasses, so they are delegated to the AUTOLOAD method. The AUTOLOAD
method will try to find a child with the same name as the undefined
method and it will return it if found.
I have not yet decided whether the AUTOLOAD should die when a child is
not found. Currently undef is returned in this situation.
One annoyance is that many nodes have names with "-" in them. These
cannot be AUTOLOADed, because method names may not have a "-" in perl.
When accessing such nodes, use the C<getChild()> method.
=head2 Attributes
If nodes are objects, then attributes are a node's instance variables.
All attributes may be single-valued or aggregate-valued. Single-valued
attributes are non-reference scalar values, and aggregate attributes are
non-reference scalar values enclosed within an arrayref.
A single valued attribute:
my $bbsed = $busybox->n('Misc-utilities')->n('keep-bb-sed');
$bbsed->provides('sed');
The same attribute as an aggregate:
$bbsed->provides([ 'sed' ]);
Semantically, these are equivalent. The main difference one will notice
is cosmetic. When the C<toString()> method is called, the single-valued
one will look like:
<PROVIDES>
sed
</PROVIDES>
Again, these two expressions mean the same thing. An aggregate of one
is interpreted just as if it were a single value.
Aggregates become useful when attributes needs to have a list of values.
$busybox->n('compile-time-features')->n('enable-bb-feature-use-inittab')->requires ([
'keep-bb-init',
'inittab',
'/bin/sh',
]);
This will be rendered by C<toString()> as
<REQUIRES>
keep-bb-init
inittab
</REQUIRES>
There are accessors for attributes that work like your typical perl
getters and setters. That is, when called without a parameter, the
method behaves as a getter. When called I<with> a parameter, the method
behaves as a setter and the value of the parameter is assigned to the
attribute.
getter:
my $name = $busybox->name();
setter:
$busybox->name('busybox');
=head2 Accessors For Single-Valued Attributes
These are accessors for attributes that are typically single-valued.
=over 4
=item name
This is the name of the node.
the file extension. This attribute almost always has the same value as
C<name()>.
$ecd->srpm()
=item specpatch
This attribute is only meaningful within the context of a component.
Specpatches are applied to .spec files just prior to the building of a
component. They are often used to configure the compilation of a
component. The busybox package provides a good example of this in
action.
$ecd->specpatch()
=item static_size
This is the sum of .text, .data, and .bss for an option and/or component.
$ecd->static_size()
=item build_vars
This specifies a list of transformations that can be applied to a .spec
file prior to building.
$ecd->build_vars()
=item provides
This is a list of symbolic names that a node is said to be able to
provide. For example, grep in busybox provides grep. GNU/grep also
provides grep. According to TargetWizard, these two cannot coexist on
the same instance of an Embedix distribution, because they both provide
grep.
$ecd->provides()
=item requires
This is a list of libraries, files, provides, and other nodes required
by the current node.
=item $line: $ATTRIBUTE not allowed in $NODE_TYPE
not implemented
=back
=head1 BUGS
This parser becomes exponentially slower as the size of ECD data
increases. busybox.ecd takes 30 seconds to parse.
Don't even try to parse linux.ecd -- it will sit there for hours
just sucking CPU before it ultimately fails and gives you back
nothing. I don't know if there's anything I can do about it.
I have noticed that XML::Parser (which wraps around the C library,
expat) is 60 times faster than my Parse::RecDescent-based parser
when reading busybox.ecd. I really want to take advantage of this.
=head1 COPYRIGHT
Copyright (c) 2000,2001 John BEPPU. All rights reserved. This program is
free software; you can redistribute it and/or modify it under the same
terms as Perl itself.
=head1 AUTHOR
John BEPPU <beppu@lineo.com>
lib/Embedix/ECD/Option.pm
lib/Embedix/ECD/Root.pm
lib/Embedix/ECD/Util.pm
lib/Embedix/ECD/XMLv1.pm
t/00_init.t
t/01_basic.t
t/02_parser.t
t/03_merge.t
t/04_print.t
t/data/build_vars.ecd
t/data/busybox.ecd
t/data/comment.ecd
t/data/embedix_gui.ecd
t/data/ltgt.ecd
t/data/node.ecd
t/data/tinylogin.ecd
t/data/tinylogin.xecd
bin/ecd2xml view on Meta::CPAN
[OPTION]... < STDIN > STDOUT
=back
=head1 DESCRIPTION
ecd2xml is a script that takes ECD data (whether it be in a file or
a stream), and turns it into XML. The benefit of this is buzzword
compliance and faster parsing. James Clark's expat can parse
busybox.xecd 60 times faster than Embedix::ECD's Parse::RecDescent
parser can parse busybox.ecd. expat is probably more robust than
the parser I made, too.
=head1 OPTIONS
=over 4
=item -h
=item --help
t/01_basic.t view on Meta::CPAN
my $gr1 = Embedix::ECD::Group->new(name => 'system');
my $gr2 = Embedix::ECD::Group->new(name => 'utilities');
$ecd->addChild($gr1);
$ecd->system->addChild($gr2);
my $obj = $ecd->system->utilities;
print "not " if ($gr2->{name} ne $obj->{name});
print "ok $test\n";
$test++;
# instantiating an object w/ attribute values
my $busybox = Embedix::ECD::Component->new (
name => 'busybox',
srpm => 'busybox',
help => 'swiss army knife or something',
);
print "not " if ($busybox->srpm ne 'busybox');
print "ok $test\n";
$test++;
# testing getNodeClass
$ecd->system->utilities->addChild($busybox);
print "not " if ($busybox->getNodeClass() ne "Component");
print "ok $test\n";
$test++;
# testing hasChildren
print "not " unless ($ecd->hasChildren());
print "ok $test\n";
$test++;
# testing hasChildren, again
print "not " if ($busybox->hasChildren());
print "ok $test\n";
$test++;
# testing evaluating getter methods
$busybox->storage_size("5000 + 40 800 + 203");
my ($size, $give_or_take) = $busybox->eval_storage_size;
print "not " unless ($size == 5040 && $give_or_take == 1003);
print "ok $test\n";
$test++;
# testing evaluating getter methods
$busybox->storage_size("5040");
($size, $give_or_take) = $busybox->eval_storage_size;
print "not " unless ($size == 5040 && $give_or_take == 0);
print "ok $test\n";
$test++;
# vim:syntax=perl
t/data/busybox.ecd view on Meta::CPAN
#######################################################
# Embedix Component Description file for: busybox
#
# Copyright 2000, Lineo Inc.
#
# Notes on binaries in busybox
#
# /bin/busybox
# /bin/cat y
# /bin/chgrp y
# /bin/chmod y
# /bin/chown y
# /bin/cp y
# /bin/date y
# /bin/dd y
# /bin/df y
# /bin/dmesg y
# /bin/du y
t/data/busybox.ecd view on Meta::CPAN
# /bin/more y
# /bin/mount y
# /bin/mt y
# /bin/mv y
# /bin/ping y
# /bin/ps y
# /bin/pwd y
# /bin/rm y
# /bin/rmdir y
# /bin/sed y
# /bin/sh --- Provided by busybox-0.45.tar.gz but not in the Embedix SDK
# /bin/sleep y
# /bin/sort
# /bin/sync y
# /bin/tar y
# /bin/tee
# /bin/true y
# /bin/umount y
# /bin/uname y
# /bin/usleep y
# /bin/zcat y
t/data/busybox.ecd view on Meta::CPAN
# /sbin/makedevs y
# /sbin/mkfs.minix y
# /sbin/mkswap y
# /sbin/poweroff y
# /sbin/reboot y
# /sbin/rmmod y
# /sbin/swapoff y
# /sbin/swapon y
# /sbin/syslogd y
### /sbin/update (Removed as functionality is in 2.x kernel)
# /usr/bin/[ --- Provided by busybox-0.45.tar.gz but not in the Embedix SDK
# /usr/bin/ar
# /usr/bin/basename y
# /usr/bin/chvt y
# /usr/bin/clear y
# /usr/bin/cut y
# /usr/bin/dc y
# /usr/bin/deallocvt
# /usr/bin/dirname y
# /usr/bin/find y
# /usr/bin/free y
t/data/busybox.ecd view on Meta::CPAN
# /usr/bin/logger y
# /usr/bin/logname
# /usr/bin/md5sum y
# /usr/bin/mkfifo y
# /usr/bin/nc y
# /usr/bin/nslookup y
# /usr/bin/printf y
# /usr/bin/setkeycodes N
# /usr/bin/tail N
# /usr/bin/telnet N
# /usr/bin/test --- Provided by busybox-0.45.tar.gz but not in the Embedix SDK
# /usr/bin/touch y
# /usr/bin/tr y
# /usr/bin/tty y
# /usr/bin/uniq y
# /usr/bin/uptime y
# /usr/bin/uuencode y
# /usr/bin/uudecode y
# /usr/bin/wc
# /usr/bin/which y
# /usr/bin/whoami y
# /usr/bin/yes
# /usr/sbin/dutmp N
# /usr/sbin/fbset y
<GROUP System>
<GROUP Utilities>
<COMPONENT busybox>
TYPE=bool
VALUE=0
SRPM=busybox
<SPECPATCH>busybox.specpatch</SPECPATCH>
<HELP>
BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It
provides a pretty complete POSIX environment in a very small package.
Just add a kernel, "ash" (Keith Almquists tiny Bourne shell clone), and
an editor such as "elvis-tiny" or "ae", and you have a full system. This
is makes an excellent environment for a "rescue" disk or any small or
embedded system.
Since all of the functions in busybox are standard linux commands, the
help section does not explain each command. Please refer to the man
pages or a Linux guide for an explaination of the commands included
with this package. Be aware that since is a "tiny" Unix utility some
of the standard command line options associated with a command may
not be available.
</HELP>
STATIC_SIZE=3006
MIN_DYNAMIC_SIZE=0
STORAGE_SIZE=4408
STARTUP_TIME=0
<BUILD_VARS>
BB_BUSYBOX=BB_BUSYBOX
</BUILD_VARS>
KEEPLIST=/bin/busybox
##############################################################
### Require at least one option to have been selected ###
### -but- don't count "compile-time-features" as an option ###
##############################################################
<REQUIRESEXPR>
(libc.so.6 == "y") &&
(ld-linux.so.2 == "y") &&
(skellinux == "y") &&
( (Misc-utilities == "y")
|| (File-compression-utilities == "y")
t/data/busybox.ecd view on Meta::CPAN
|| (Screen-utilities == "y")
|| (System-utilities == "y")
|| (File-manipulation-utilities == "y") )
</REQUIRESEXPR>
### features ###
<GROUP compile-time-features>
PROMPT=Enable/Disable compile options?
DEFAULT_VALUE=1
<HELP>
Some of the busybox utilities have features that can be enabled
or disabled by selecting options in this group.
</HELP>
<REQUIRESEXPR>
(compile-time-features == "CHILDREN_ENABLED")
</REQUIRESEXPR>
### See also BB_FEATURE_USE_TERMIOS
### ls.c, more.c, ps.c
<OPTION enable-bb-feature-autowidth>
TYPE=bool
t/data/busybox.ecd view on Meta::CPAN
STORAGE_SIZE=0
STARTUP_TIME=0
<BUILD_VARS>
BB_FEATURE_INSMOD_VERSION_CHECKING=BB_FEATURE_INSMOD_VERSION_CHECKING
</BUILD_VARS>
</OPTION>
#
# Not offered in SDK (yet!).
#
# ### busybox.c
# <OPTION enable-bb-feature-installer>
# TYPE=bool
# DEFAULT_VALUE=0
# PROMPT=Enable BB_FEATURE_INSTALLER?
# <HELP>
# This feature enables "busybox --install [-s]" to create links
# (or symlinks) for all the commands that are compiled into the
# binary. (Needs /proc filesystem.)
# </HELP>
# STATIC_SIZE=1129
# MIN_DYNAMIC_SIZE=0
# STORAGE_SIZE=1112
# STARTUP_TIME=0
# <BUILD_VARS>
# BB_FEATURE_INSTALLER=BB_FEATURE_INSTALLER
# </BUILD_VARS>
t/data/busybox.ecd view on Meta::CPAN
keep-bb-mount
CONFIG_NFS_FS
keep-rpc.portmap
</REQUIRES>
<BUILD_VARS>
BB_FEATURE_NFSMOUNT=BB_FEATURE_NFSMOUNT
</BUILD_VARS>
</OPTION>
#
# See /bin/sh --- Provided by busybox-0.45.tar.gz but not in the Embedix SDK
#
# ### See also BB_CMDEDIT
# ### See also BB_FEATURE_USE_TERMIOS
# ### cmdedit.c, sh.c
# <OPTION enable-bb-feature-sh-command-editing>
# TYPE=bool
# DEFAULT_VALUE=1
# PROMPT=Enable BB_FEATURE_SH_COMMAND_EDITING?
# <HELP>
# This feature enables command line editing in the shell.
t/data/busybox.ecd view on Meta::CPAN
# STATIC_SIZE=0
# MIN_DYNAMIC_SIZE=0
# STORAGE_SIZE=0
# STARTUP_TIME=0
# <BUILD_VARS>
# BB_FEATURE_SH_COMMAND_EDITING=BB_FEATURE_SH_COMMAND_EDITING
# </BUILD_VARS>
# </OPTION>
#
# See /bin/sh --- Provided by busybox-0.45.tar.gz but not in the Embedix SDK
#
# ### sh.c
# <OPTION enable-bb-feature-sh-standalone-shell>
# TYPE=bool
# DEFAULT_VALUE=1
# PROMPT=Enable BB_FEATURE_SH_STANDALONE_SHELL?
# <HELP>
# This feature allows the shell to invoke all the compiled in
# BusyBox commands as if they were shell builtins. Nice for
# staticly linking an emergency rescue shell among other thing.
t/data/busybox.ecd view on Meta::CPAN
# PROMPT=Enable BB_FEATURE_USE_DEVPS_PATCH?
# <HELP>
# This feature enables Erik's very cool devps, devmtab, etc
# kernel drivers, thereby eliminating the need for the /proc
# filesystem and thereby saving lots and lots memory for more
# important things. You can not use this and use PROCFS at the
# same time...
#
# NOTE: If you enable this feature, you _MUST_ have patched
# the kernel to include the devps patch that is included in
# the busybox/kernel-patches directory. You will also need
# to create some device special /dev files on your system:
# mknod /dev/modules c 10 23
# mknod /dev/mtab c 10 22
# mknod /dev/ps c 10 21
# </HELP>
# STATIC_SIZE=0
# MIN_DYNAMIC_SIZE=0
# STORAGE_SIZE=0
# STARTUP_TIME=0
# <REQUIRESEXPR>
t/data/busybox.ecd view on Meta::CPAN
# BB_FEATURE_USE_DEVPS_PATCH=BB_FEATURE_USE_DEVPS_PATCH
# </BUILD_VARS>
# </OPTION>
### init.c
<OPTION enable-bb-feature-use-inittab>
TYPE=bool
DEFAULT_VALUE=1
PROMPT=Enable BB_FEATURE_USE_INITTAB?
<HELP>
If this busybox compile option "BB_FEATURE_USE_INITTAB" is
enabled (recommended), the file /etc/inittab is parsed by the
busybox init utility to determine system process initialization
actions to be taken. If the /etc/inittab file is not found,
default actions of attempting to run the script /etc/rc.d/rcS
as well as starting a pair of "askfirst" shells will be taken.
The format for the /etc/inittab file that this busybox init
uses is different from the inittab format that the standard
Linux init uses. Generally speaking, the new format is fairly
similar but less featureful than the standard format.
</HELP>
STATIC_SIZE=0
MIN_DYNAMIC_SIZE=0
STORAGE_SIZE=0
STARTUP_TIME=0
<REQUIRES>
keep-bb-init
t/data/busybox.ecd view on Meta::CPAN
<BUILD_VARS>
BB_SED=BB_SED
</BUILD_VARS>
KEEPLIST=/bin/sed
<PROVIDES>
sed
</PROVIDES>
</OPTION>
#
# /bin/sh --- Provided by busybox-0.45.tar.gz but not in the Embedix SDK
#
# <OPTION keep-bb-sh>
# TYPE=bool
# DEFAULT_VALUE=0
# PROMPT=Include /bin/sh?
# <HELP>
# The BusyBox command interpreter (shell).
#### lash: The BusyBox LAme SHell (command interpreter).
# </HELP>
# STATIC_SIZE=10420
t/data/busybox.ecd view on Meta::CPAN
<BUILD_VARS>
BB_TEE=BB_TEE
</BUILD_VARS>
KEEPLIST=/bin/tee
<PROVIDES>
tee
</PROVIDES>
</OPTION>
#
# /usr/bin/test --- Provided by busybox-0.45.tar.gz but not in the Embedix SDK
# /usr/bin/[ --- Provided by busybox-0.45.tar.gz but not in the Embedix SDK
#
# <OPTION keep-bb-test>
# TYPE=bool
# DEFAULT_VALUE=0
# PROMPT=Include /usr/bin/test and /usr/bin/[?
# <HELP>
# Checks file types and compares values returning an exit
# code determined by the value of EXPRESSION.
# </HELP>
# STATIC_SIZE=4359
t/data/busybox.ecd view on Meta::CPAN
hostid
</PROVIDES>
</OPTION>
<OPTION keep-bb-init>
TYPE=bool
DEFAULT_VALUE=1
PROMPT=Include /sbin/init?
<HELP>
The /sbin/init utility controls system process initialization.
If this is selected (recommended) and the busybox compile
option "BB_FEATURE_USE_INITTAB" is enabled (recommended), the
file /etc/inittab is parsed to determine any actions to be
taken. If the option "BB_FEATURE_USE_INITTAB" is not enabled,
then default actions include attempting to run the script
/etc/rc.d/rcS as well as starting a pair of "askfirst" shells.
If the option "BB_FEATURE_USE_INITTAB" is enabled and the
/etc/inittab file is not found, busybox init will act as if
the "BB_FEATURE_USE_INITTAB" was not enabled.
The format for the /etc/inittab file that this busybox init
uses is different from the inittab format that the standard
Linux init uses. Generally speaking, the new format is fairly
similar but less featureful than the standard format.
</HELP>
STATIC_SIZE=7919
MIN_DYNAMIC_SIZE=0
STORAGE_SIZE=7928
STARTUP_TIME=0
<BUILD_VARS>
BB_INIT=BB_INIT