mirror of
https://git.yoctoproject.org/poky
synced 2026-01-30 13:28:43 +01:00
Compare commits
2 Commits
master
...
blinky-3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d12616bee8 | ||
|
|
c54cc0c1ca |
39
.gitignore
vendored
39
.gitignore
vendored
@@ -1,39 +0,0 @@
|
||||
*.pyc
|
||||
*.pyo
|
||||
/*.patch
|
||||
/.repo/
|
||||
/build*/
|
||||
pyshtables.py
|
||||
pstage/
|
||||
scripts/oe-git-proxy-socks
|
||||
sources/
|
||||
meta-*/
|
||||
buildtools/
|
||||
!meta-skeleton
|
||||
!meta-selftest
|
||||
hob-image-*.bb
|
||||
*.swp
|
||||
*.orig
|
||||
*.rej
|
||||
*~
|
||||
!meta-poky
|
||||
!meta-yocto
|
||||
!meta-yocto-bsp
|
||||
!meta-yocto-imported
|
||||
/documentation/*/eclipse/
|
||||
/documentation/*/*.html
|
||||
/documentation/*/*.pdf
|
||||
/documentation/*/*.tgz
|
||||
/bitbake/doc/bitbake-user-manual/bitbake-user-manual.html
|
||||
/bitbake/doc/bitbake-user-manual/bitbake-user-manual.pdf
|
||||
/bitbake/doc/bitbake-user-manual/bitbake-user-manual.tgz
|
||||
pull-*/
|
||||
bitbake/lib/toaster/contrib/tts/backlog.txt
|
||||
bitbake/lib/toaster/contrib/tts/log/*
|
||||
bitbake/lib/toaster/contrib/tts/.cache/*
|
||||
bitbake/lib/bb/tests/runqueue-tests/bitbake-cookerdaemon.log
|
||||
_toaster_clones/
|
||||
downloads/
|
||||
sstate-cache/
|
||||
toaster.sqlite
|
||||
.vscode/
|
||||
11
LICENSE
Normal file
11
LICENSE
Normal file
@@ -0,0 +1,11 @@
|
||||
Different components of Poky are under different licenses (a mix of
|
||||
MIT and GPLv2). Please see:
|
||||
|
||||
bitbake/COPYING (GPLv2)
|
||||
meta/COPYING.MIT (MIT)
|
||||
meta-extras/COPYING.MIT (MIT)
|
||||
|
||||
which cover the components in those subdirectories.
|
||||
|
||||
License information for any other files is either explicitly stated
|
||||
or defaults to GPL version 2.
|
||||
142
README
142
README
@@ -1,114 +1,70 @@
|
||||
The poky repository master branch is no longer being updated.
|
||||
Introduction
|
||||
==
|
||||
|
||||
You can either:
|
||||
|
||||
a) switch to individual clones of bitbake, openembedded-core, meta-yocto and yocto-docs
|
||||
|
||||
https://docs.yoctoproject.org/dev/dev-manual/poky-manual-setup.html
|
||||
|
||||
b) use the new bitbake-setup
|
||||
|
||||
https://docs.yoctoproject.org/bitbake/dev/bitbake-user-manual/bitbake-user-manual-environment-setup.html
|
||||
|
||||
You can find more information in our documentation: https://docs.yoctoproject.org/
|
||||
|
||||
Note that "poky" the distro setting is still available in meta-yocto as
|
||||
before and we continue to use and maintain that.
|
||||
|
||||
Long live Poky!
|
||||
'Poky' is a combined cross build system and linux distribution based
|
||||
upon OpenEmbedded. It features support for building X11/Matchbox/GTK
|
||||
based filesystem images for various embedded devices and boards.
|
||||
|
||||
|
||||
Required Packages
|
||||
===
|
||||
|
||||
Running Poky on Debian based distributions requires the following
|
||||
extra packages be installed;
|
||||
|
||||
Some further information on the background of this change follows. The
|
||||
details are taken from:
|
||||
https://lists.openembedded.org/g/openembedded-architecture/message/2179
|
||||
build-essential
|
||||
diffstat
|
||||
texinfo
|
||||
texi2html
|
||||
cvs
|
||||
subversion
|
||||
gawk
|
||||
bochsbios (to run qemux86 images)
|
||||
|
||||
TLDR: People have complained about the combo-layer built poky
|
||||
repository for years. It was meant to be a temporary thing, we now have
|
||||
an alternative and I'm therefore doing what I promised I'd do. Change
|
||||
is tough, things may break but this is the right point to at least try
|
||||
it.
|
||||
You also need to install the qemu from http://debian.o-hand.com/. A
|
||||
poky-depends deb is also available from this source which will install
|
||||
all the dependencies mentioned above for you.
|
||||
|
||||
I'd like to note that:
|
||||
* setting up builds with a separate oe-core and bitbake clone
|
||||
works as it always has done
|
||||
* you can change your CI just to use those two repos instead of poky
|
||||
* bitbake-setup isn't mandatory, it will just be what the yocto-
|
||||
docs presents to users
|
||||
* we don't have to stop maintaining the poky repository
|
||||
however nobody will test the new approach/code unless we do
|
||||
* we are optionally exposing sstate mirrors in the new config
|
||||
* we are also exposing config fragments to users
|
||||
* poky as a DISTRO in meta-yocto remains
|
||||
Alternatively poky can build qemu itself, but for this you need the
|
||||
following packages installed;
|
||||
|
||||
A bit more about the history and background for those who are
|
||||
interested and then some FAQs:
|
||||
gcc-3.4
|
||||
libsdl1.2-dev
|
||||
zlib1g-dev
|
||||
|
||||
Back around 2010 when we split up openembedded-classic and started
|
||||
developing layers, we made the artificial "poky" repository construct
|
||||
as a way to let people easily and quickly get started with the project.
|
||||
without cloning and managing multiple repositories. Layers were a new
|
||||
idea with lots of rough edges. kas didn't exist, I think repo was only
|
||||
just created and it was a different world. For us, it meant hacking up
|
||||
a quick tool, "combo-layer" and it was really a temporary solution to
|
||||
fill a gap and it was at least as functional as repo of the era. It was
|
||||
assumed we'd work it out properly in the future.
|
||||
You will also need to comment out ASSUME_PROVIDED += "qemu-native"' in
|
||||
build/conf/local.conf.
|
||||
|
||||
At developer meetings there are inevitable questions about why
|
||||
poky/combo-layer exist and few seem to actually like/support it. There
|
||||
are continual questions about why a tool doesn't exist or why we don't
|
||||
adopt one too.
|
||||
Building under other distro's such as Fedora is known to work. Use the above
|
||||
package names as a guide for dependencies.
|
||||
|
||||
15 years later, a bit longer than we might have thought, we are finally
|
||||
in a position where there may be a viable way forward to change.
|
||||
Building An Image
|
||||
===
|
||||
|
||||
It has taken us a bit of time to get to this point. I wrote the
|
||||
original description of something like bitbake-setup about 7-8 years
|
||||
ago. I shared it privately with a few people, the review feedback
|
||||
stopped me pushing it further as I simply did not have the bandwidth.
|
||||
We were fortunate to get funding from the Sovereign Tech Fund to start
|
||||
the work and whilst I'd probably prefer to avoid the issue, the time
|
||||
had come to start. Since then, Alexander Kanavin has put a lot of work
|
||||
into getting it to the point where it would be possible to switch. A
|
||||
huge thanks to him for getting this to the current point.
|
||||
Simply run;
|
||||
|
||||
Why not use kas/submodules/repo?
|
||||
% source poky-init-build-env
|
||||
% bitbake poky-image-sato
|
||||
|
||||
This topic has been discussed in depth several times. Very roughly,
|
||||
these are either difficult to focus on our use cases or have specific
|
||||
designs and intent which we as a project would struggle to influence.
|
||||
We are taking significant influence from some of them but also trying
|
||||
to build something where we can benefit from tight direct integration
|
||||
with bitbake and the metadata. For example fragment support is generic
|
||||
and hopefully something other approaches can also benefit from. We want
|
||||
to provide something we can switch the projects docs and autobuilder to
|
||||
which we can control and develop as we need it to. We are not aiming to
|
||||
force anyone to switch, you can use whichever tool you want.
|
||||
This will result in an ext2 image and kernel for qemu arm (see scripts dir).
|
||||
|
||||
Can we not keep poky [repository master branch] around?
|
||||
To build for other machine types see MACHINE in build/conf/local.conf
|
||||
|
||||
If we do that, nobody will use the new tooling and it will be a
|
||||
disaster as issues won't get resolved. We need our CI to use the same
|
||||
thing we promote to our new and experienced users. We need this new
|
||||
tooling to be usable by our experienced developers too. We have tried
|
||||
for months to get people to try it and they simply don't. Making a
|
||||
release with it won't change much either. It needs people using it and
|
||||
for that, poky has to stop being updated.
|
||||
Other image targets such as poky-image-sdk or poky-image-minimal are available,
|
||||
see meta/packages/images/*.
|
||||
|
||||
What happens to poky [repository]?
|
||||
Notes:
|
||||
===
|
||||
|
||||
The LTS branches continue their lifetime as planned. For master, I'll
|
||||
probably put a final commit in changing to just a README which points
|
||||
people at the bitbake-setup changes and explains what happened.
|
||||
Useful Links;
|
||||
|
||||
What are the timelines? Why now?
|
||||
OpenedHand
|
||||
http://openedhand.com
|
||||
|
||||
If we're going to make a change, we really want this in the next LTS
|
||||
release, which is April 2026. We only have one release before that
|
||||
which is now, October 2025. We therefore need to switch now, and then
|
||||
give us time to update docs, fix issues that arise and so on and have
|
||||
it in a release cycle. Whilst it means delaying the Oct 2025 release
|
||||
slightly, that is the right thing to do in the context of the bigger
|
||||
picture.
|
||||
Poky Homepage
|
||||
http://projects.o-hand.com/poky
|
||||
|
||||
OE Homepage and wiki
|
||||
http://openembedded.org
|
||||
|
||||
Copyright (C) 2006-2007 OpenedHand Ltd.
|
||||
|
||||
106
README.commands
Normal file
106
README.commands
Normal file
@@ -0,0 +1,106 @@
|
||||
Using Poky - Poky Commands
|
||||
==========================
|
||||
|
||||
Bitbake
|
||||
=======
|
||||
|
||||
Bitbake is the tool at the heart of poky and is responsible for parsing the
|
||||
metadata, generating a list of tasks from it and then executing them. To see a
|
||||
list of the options it supports look at "bitbake --help".
|
||||
|
||||
The most common usage is "bitbake <packagename>" where <packagename> is the name
|
||||
of the package you wish to build. This often equates to the first part of a .bb
|
||||
filename so to run the matchbox-desktop_1.2.3.bb file, you might type "bitbake
|
||||
matchbox-desktop. Several different versions of matchbox-desktop might exist
|
||||
and bitbake will choose the one selected by the distribution configuration.
|
||||
Bitbake will also try to execute any dependent tasks first so before building
|
||||
matchbox-desktop it would build a cross compiler and glibc if not already built.
|
||||
|
||||
|
||||
Bitbake - Package Tasks
|
||||
=======================
|
||||
|
||||
Any given package consists of a set of tasks, in most cases the series is fetch,
|
||||
unpack, patch, configure, compile, install, package, package_write and build.
|
||||
The default task is "build" and any tasks this depends on are built first hence
|
||||
the standard bitbake behaviour. There are some tasks such as devshell which are
|
||||
not part of the default build chain. If you wish to run such a task you can use
|
||||
the "-c" option to bitbake e.g. "bitbake matchbox-desktop -c devshell".
|
||||
|
||||
If you wish to rerun a task you can use the force option "-f". A typical usage
|
||||
case might look like:
|
||||
|
||||
% bitbake matchbox-desktop
|
||||
[change some source in the WORKDIR for example]
|
||||
% bitbake matchbox-desktop -c compile -f
|
||||
% bitbake matchbox-desktop
|
||||
|
||||
which would build matchbox-desktop, then recompile it. The final command reruns
|
||||
all tasks after the compile (basically the packaging tasks) since bitbake will
|
||||
notice the the compile has been rerun and hence the other tasks also need to run
|
||||
again.
|
||||
|
||||
You can view a list of tasks in a given package by running the listtasks task
|
||||
e.g. "bitbake matchbox-desktop -c listtasks".
|
||||
|
||||
|
||||
Bitbake - Dependency Graphs
|
||||
===========================
|
||||
|
||||
Sometimes it can be hard to see why bitbake wants to build some other packages
|
||||
before a given package you've specified. "bitbake matchbox-desktop -g" will
|
||||
create a task-depends.dot file in the current directory. This shows which
|
||||
packages and tasks depend on which other packages and tasks and it useful for
|
||||
debugging purposes.
|
||||
|
||||
|
||||
Bitbake - Advanced Usage
|
||||
========================
|
||||
|
||||
Debug output from bitbake can be seen with the "-D" option and can sometimes
|
||||
give more information about what bitbake is doing and/or why. Each -D options
|
||||
increases the logging level, the most common usage being "-DDD".
|
||||
|
||||
If you really want to build a specific .bb file, you can use the form "bitbake
|
||||
-b somepath/somefile.bb". Note that this will not check the dependencies so this
|
||||
option should only be used when you know the dependencies already exist. You can
|
||||
specify fragments of the filename and bitbake will see if it can find a unique
|
||||
match.
|
||||
|
||||
The -e option will dump the resulting environment for either the configuration
|
||||
(no package specified) or for a specific package when specified with the -b
|
||||
option.
|
||||
|
||||
The -k option will cause bitbake to try and continue even if a task fails. It
|
||||
can be useful for world or unattended builds.
|
||||
|
||||
The -s option lists all the versions of packages that bitbake will use.
|
||||
|
||||
|
||||
Bitbake - More Information
|
||||
==========================
|
||||
|
||||
See the bitbake user manual at: http://bitbake.berlios.de/manual/
|
||||
|
||||
QEMU
|
||||
====
|
||||
|
||||
Running images built by poky under qemu is possible within the poky environment
|
||||
through the "runqemu" command. It has the form:
|
||||
|
||||
runqemu MACHINE IMAGETYPE ZIMAGE IMAGEFILE
|
||||
|
||||
where:
|
||||
|
||||
MACHINE - the machine to emulate (qemux86, qemuarm, spitz, akita)
|
||||
IMAGETYPE - the type of image to use (nfs or ext2)
|
||||
ZIMAGE - location of the kernel binary to use
|
||||
IMAGEFILE - location of the image file to use
|
||||
(common options are in brackets)
|
||||
|
||||
MACHINE is mandatory, the others are optional.
|
||||
|
||||
This assumes a suitable qemu binary is available with support for a given
|
||||
machine. For further information see scripts/poky-qemu.README.
|
||||
|
||||
Copyright (C) 2006-2007 OpenedHand Ltd.
|
||||
51
README.host.sdk
Normal file
51
README.host.sdk
Normal file
@@ -0,0 +1,51 @@
|
||||
Using Poky generated host SDK
|
||||
=============================
|
||||
|
||||
How to build host SDK
|
||||
====
|
||||
|
||||
You need to setup Poky and then run one command:
|
||||
|
||||
$ bitbake meta-toolchain
|
||||
|
||||
Result would be tarball in tmp/deploy/sdk/ with everything needed to build for
|
||||
your target device. Unpack this in / directory - toolchain will reside in
|
||||
/usr/local/poky/arm/ dir.
|
||||
|
||||
Usage of SDK
|
||||
=====
|
||||
|
||||
First add toolchain into PATH:
|
||||
|
||||
$ export PATH=/usr/local/poky/arm/bin/:$PATH
|
||||
|
||||
Compiler is 'arm-poky-linux-gnueabi-gcc'. Building 'helloworld' example is
|
||||
simple:
|
||||
|
||||
$ arm-poky-linux-gnueabi-gcc hello.c -o hello
|
||||
$ file hello
|
||||
hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, dynamically linked (uses shared libs), not stripped
|
||||
|
||||
Autotools and SDK
|
||||
======
|
||||
|
||||
'Configure' scripts allow to specify Host, Target, Build architecture. To build
|
||||
with Poky SDK you need to specify:
|
||||
|
||||
./configure --target=arm-poky-linux-gnueabi --host=arm-poky-linux-gnueabi
|
||||
|
||||
|
||||
Using packages from Poky
|
||||
========
|
||||
|
||||
During development it is often situation that we want to use some libraries
|
||||
which are available in Poky build. Their packages need to be unpacked to
|
||||
/usr/local/poky/arm/arm-poky-linux-gnueabi/ directory.
|
||||
|
||||
For example to add libiw (from wireless-tools package) you need to unpack two
|
||||
packages:
|
||||
|
||||
libiw29_29-pre20-r0_armv5te.ipk
|
||||
libiw-dev_29-pre20-r0_armv5te.ipk
|
||||
|
||||
Copyright (C) 2006-2007 OpenedHand Ltd.
|
||||
214
README.structure
Normal file
214
README.structure
Normal file
@@ -0,0 +1,214 @@
|
||||
A walk through the poky directory tree
|
||||
======================================
|
||||
|
||||
Poky consists of several components and understanding what these are and where
|
||||
they each live is one of the keys to using it.
|
||||
|
||||
Top level core components
|
||||
=========================
|
||||
|
||||
|
||||
bitbake/
|
||||
|
||||
A copy of bitbake is included within poky for ease of use and resides here.
|
||||
This should usually be the same as a standard bitbake release from the bitbake
|
||||
project. Bitbake is a metadata interpreter and is responsible for reading the
|
||||
poky metadata and running the tasks it defines. Failures are usually from the
|
||||
metadata and not bitbake itself and most users don't need to worry about
|
||||
bitbake. bitbake/bin is placed into the PATH environmental variable so bitbake
|
||||
can be found.
|
||||
|
||||
build/
|
||||
|
||||
This directory contains user configuration files and the output from Poky is
|
||||
also placed here.
|
||||
|
||||
meta/
|
||||
|
||||
The core metadata - this is the key part of poky. Within this directory there
|
||||
are definitions of the machines, the poky distribution and the packages that
|
||||
make up a given system.
|
||||
|
||||
meta-extras/
|
||||
|
||||
Similar to meta containing some extra package files not included in standard
|
||||
poky, disabled by default and hence not supported as part of poky.
|
||||
|
||||
scripts/
|
||||
|
||||
Various integration scripts which implement extra functionality in the poky
|
||||
environment for example the qemu scripts. This directory is appended to the
|
||||
PATH environmental variable.
|
||||
|
||||
sources/
|
||||
|
||||
Whilst not part of a checkout, poky will create this directory as part of any
|
||||
build. Any downloads are placed in this directory (as specified by the
|
||||
DL_DIR variable). This directory can be shared between poky builds to save
|
||||
downloading files multiple times. SCM checkouts are also stored here as e.g.
|
||||
sources/svn/, sources/cvs/ or sources/git/ and the sources directory may contain
|
||||
archives of checkouts for various revisions or dates.
|
||||
|
||||
Its worth noting that bitbake creates .md5 stamp files for downloads. It uses
|
||||
these to mark downloads as complete as well as for checksum and access
|
||||
accounting purposes. If you add a file manually to the directory, you need to
|
||||
touch the corresponding .md5 file too.
|
||||
|
||||
poky-init-build-env
|
||||
|
||||
This script is used to setup the poky build environment. Sourcing this file in
|
||||
a shell makes changes to PATH and sets other core bitbake variables based on the
|
||||
current working directory. You need to use this before running poky commands.
|
||||
Internally it uses scripts within the scripts/ directory to do the bulk of the
|
||||
work.
|
||||
|
||||
|
||||
The Build Directory
|
||||
===================
|
||||
|
||||
conf/local.conf
|
||||
|
||||
This file contains all the local user configuration of poky. If it isn't
|
||||
present, its created from local.conf.sample. That file contains documentation
|
||||
on the various standard options which can be configured there although any
|
||||
standard conf file variable can be also be set here and usually overrides any
|
||||
variable set elsewhere within poky.
|
||||
|
||||
Edit this file to set the MACHINE you want to build for, which package types you
|
||||
which to use (PACKAGE_CLASSES) or where downloaded files should go (DL_DIR) for
|
||||
exmaple.
|
||||
|
||||
tmp/
|
||||
|
||||
This is created by bitbake if it doesn't exist and is where all the poky output
|
||||
is placed. To clean poky and start a build from scratch (other than downloads),
|
||||
you can wipe this directory. tmp has some important subcomponents detailed
|
||||
below.
|
||||
|
||||
tmp/cache/
|
||||
|
||||
When bitbake parses the metadata it creates a cache file of the result which can
|
||||
be used when subsequently running the command. These are stored here, usually on
|
||||
a per machine basis.
|
||||
|
||||
tmp/cross/
|
||||
|
||||
The cross compiler when generated is placed into this directory and those
|
||||
beneath it.
|
||||
|
||||
tmp/deploy/
|
||||
|
||||
Any 'end result' output from poky is placed under here.
|
||||
|
||||
tmp/deploy/deb/
|
||||
|
||||
Any .deb packages emitted by poky are placed here, sorted into feeds for
|
||||
different architecture types.
|
||||
|
||||
tmp/deploy/images/
|
||||
|
||||
Complete filesystem images are placed here. If you want to flash the resulting
|
||||
image from a build onto a device, look here for them.
|
||||
|
||||
tmp/deploy/ipk/
|
||||
|
||||
Any resulting .ipk packages emitted by poky are placed here.
|
||||
|
||||
tmp/rootfs/
|
||||
|
||||
This is a temporary scratch area used when creating filesystem images. It is run
|
||||
under fakeroot and is not useful once that fakeroot session has ended as
|
||||
information is lost. It is left around since it is still useful in debugging
|
||||
image creation problems.
|
||||
|
||||
tmp/staging/
|
||||
|
||||
Any package needing to share output with other packages does so within staging.
|
||||
This means it contains any shared header files and any shared libraries amongst
|
||||
other data. It is subdivided by architecture so multiple builds can run within
|
||||
the one build directory.
|
||||
|
||||
tmp/stamps/
|
||||
|
||||
This is used by bitbake for accounting purposes to keep track of which tasks
|
||||
have been run and when. It is also subdivided by architecture. The files are
|
||||
empty and the important information is the filenames and timestamps.
|
||||
|
||||
tmp/work/
|
||||
|
||||
Each package build by bitbake is worked on its own work directory. Here, the
|
||||
source is unpacked, patched, configured, compiled etc. It is subdivided by
|
||||
architecture.
|
||||
|
||||
It is worth considering the structure of a typical work directory. An example is
|
||||
the linux-rp kernel, version 2.6.20 r7 on the machine spitz built within poky
|
||||
which would result in a work directory of
|
||||
"tmp/work/spitz-poky-linux-gnueabi/linux-rp-2.6.20-r7", referred to as WORKDIR.
|
||||
|
||||
Within this, the source is unpacked to linux-2.6.20 and then patched by quilt
|
||||
hence the existence of the standard quilt directories linux-2.6.20/patches and
|
||||
linux-2.6.20/.pc. Within the linux-2.6.20 directory, standard quilt commands
|
||||
can be used.
|
||||
|
||||
There are other directories generated within WORKDIR. The most important/useful
|
||||
is WORKDIR/temp which has log files for each task (log.do_*.pid) and the scripts
|
||||
bitbake runs for each task (run.do_*.pid). WORKDIR/image is where "make install"
|
||||
places its output which is then split into subpackages within WORKDIR/install.
|
||||
|
||||
|
||||
The Metadata
|
||||
============
|
||||
|
||||
As mentioned previously, this is the core of poky. It has several important
|
||||
subdivisions:
|
||||
|
||||
meta/classes/
|
||||
|
||||
Contains the *.bbclass files. Class files are used to abstract common code
|
||||
allowing it to be reused by multiple packages. The base.bbclass file is
|
||||
inherited by every package. Examples of other important classes are
|
||||
autotools.bbclass which in theory allows any "autotooled" package to work with
|
||||
poky with minimal effort or kernel.bbclass which contains common code and
|
||||
functions for working with the linux kernel. Functions like image generation or
|
||||
packaging also have their specific class files (image.bbclass, rootfs_*.bbclass
|
||||
and package*.bbclass).
|
||||
|
||||
meta/conf/
|
||||
|
||||
This is the core set of configuration files which start from bitbake.conf and
|
||||
from which all other configuration files are included (see the includes at the
|
||||
end of the file, even local.conf is loaded from there!). Whilst bitbake.conf
|
||||
sets up the defaults, often these can be overridden by user (local.conf),
|
||||
machine or distribution configuration files.
|
||||
|
||||
meta/conf/machine/
|
||||
|
||||
Contains all the machine configuration files. If you set MACHINE="spitz", the
|
||||
end result is poky looking for a spitz.conf file in this directory. The includes
|
||||
directory contains various data common to multiple machines. If you want to add
|
||||
support for a new machine to poky, this is the directory to look in.
|
||||
|
||||
meta/conf/distro/
|
||||
|
||||
Any distribution specific configuration is controlled from here. OpenEmbedded
|
||||
supports multiple distributions of which poky is one. Poky only contains the
|
||||
poky distribution so poky.conf is the main file here. This includes the
|
||||
versions and SRCDATES for applications which are configured here. An example of
|
||||
an alternative configuration is poky-bleeding.conf although this mainly inherits
|
||||
its configuration from poky itself.
|
||||
|
||||
packages/
|
||||
|
||||
Each application (package) poky can build has an associated .bb file which are
|
||||
all stored under this directory. Poky finds them through the BBFILES variable
|
||||
which defaults to packages/*/*.bb. Adding a new piece of software to poky
|
||||
consists of adding the appropriate .bb file. The .bb files from OpenEmbedded
|
||||
upstream are usually compatible although they are not supported.
|
||||
|
||||
site/
|
||||
|
||||
Certain autoconf test results cannot be determined when cross compiling since it
|
||||
can't run tests on a live system. This directory therefore contains a list of
|
||||
cached results for various architectures which is passed to autoconf.
|
||||
|
||||
Copyright (C) 2006-2007 OpenedHand Ltd.
|
||||
10
bitbake/AUTHORS
Normal file
10
bitbake/AUTHORS
Normal file
@@ -0,0 +1,10 @@
|
||||
Tim Ansell <mithro@mithis.net>
|
||||
Phil Blundell <pb@handhelds.org>
|
||||
Seb Frankengul <seb@frankengul.org>
|
||||
Holger Freyther <zecke@handhelds.org>
|
||||
Marcin Juszkiewicz <hrw@hrw.one.pl>
|
||||
Chris Larson <kergoth@handhelds.org>
|
||||
Ulrich Luckas <luckas@musoft.de>
|
||||
Mickey Lauer <mickey@Vanille.de>
|
||||
Richard Purdie <rpurdie@rpsys.net>
|
||||
Holger Schurig <holgerschurig@gmx.de>
|
||||
339
bitbake/COPYING
Normal file
339
bitbake/COPYING
Normal file
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
158
bitbake/ChangeLog
Normal file
158
bitbake/ChangeLog
Normal file
@@ -0,0 +1,158 @@
|
||||
Changes in Bitbake 1.8.x:
|
||||
- Correctly redirect stdin when forking
|
||||
- If parsing errors are found, exit, too many users miss the errors
|
||||
- Remove supriours PREFERRED_PROVIDER warnings
|
||||
- Start to fix path quoting
|
||||
|
||||
Changes in Bitbake 1.8.4:
|
||||
- Make sure __inherit_cache is updated before calling include() (from Michael Krelin)
|
||||
- Fix bug when target was in ASSUME_PROVIDED (#2236)
|
||||
- Raise ParseError for filenames with multiple underscores instead of infinitely looping (#2062)
|
||||
- Fix invalid regexp in BBMASK error handling (missing import) (#1124)
|
||||
- Don't run build sanity checks on incomplete builds
|
||||
- Promote certain warnings from debug to note 2 level
|
||||
- Update manual
|
||||
|
||||
Changes in Bitbake 1.8.2:
|
||||
- Catch truncated cache file errors
|
||||
- Add PE (Package Epoch) support from Philipp Zabel (pH5)
|
||||
- Add code to handle inter-task dependencies
|
||||
- Allow operations other than assignment on flag variables
|
||||
- Fix cache errors when generation dotGraphs
|
||||
|
||||
Changes in Bitbake 1.8.0:
|
||||
- Release 1.7.x as a stable series
|
||||
|
||||
Changes in BitBake 1.7.x:
|
||||
- Major updates of the dependency handling and execution
|
||||
of tasks. Code from bin/bitbake replaced with runqueue.py
|
||||
and taskdata.py
|
||||
- New task execution code supports multithreading with a simplistic
|
||||
threading algorithm controlled by BB_NUMBER_THREADS
|
||||
- Change of the SVN Fetcher to keep the checkout around
|
||||
courtsey of Paul Sokolovsky (#1367)
|
||||
- PATH fix to bbimage (#1108)
|
||||
- Allow debug domains to be specified on the commandline (-l)
|
||||
- Allow 'interactive' tasks
|
||||
- Logging message improvements
|
||||
- Drop now uneeded BUILD_ALL_DEPS variable
|
||||
- Add support for wildcards to -b option
|
||||
- Major overhaul of the fetchers making a large amount of code common
|
||||
including mirroring code
|
||||
- Fetchers now touch md5 stamps upon access (to show activity)
|
||||
- Fix -f force option when used without -b (long standing bug)
|
||||
- Add expand_cache to data_cache.py, caching expanded data (speedup)
|
||||
- Allow version field in DEPENDS (ignored for now)
|
||||
- Add abort flag support to the shell
|
||||
- Make inherit fail if the class doesn't exist (#1478)
|
||||
- Fix data.emit_env() to expand keynames as well as values
|
||||
- Add ssh fetcher
|
||||
- Add perforce fetcher
|
||||
- Make PREFERRED_PROVIDER_foobar defaults to foobar if available
|
||||
- Share the parser's mtime_cache, reducing the number of stat syscalls
|
||||
- Compile all anonfuncs at once!
|
||||
*** Anonfuncs must now use common spacing format ***
|
||||
- Memorise the list of handlers in __BBHANDLERS and tasks in __BBTASKS
|
||||
This removes 2 million function calls resulting in a 5-10% speedup
|
||||
- Add manpage
|
||||
- Update generateDotGraph to use taskData/runQueue improving accuracy
|
||||
and also adding a task dependency graph
|
||||
- Fix/standardise on GPLv2 licence
|
||||
- Move most functionality from bin/bitbake to cooker.py and split into
|
||||
separate funcitons
|
||||
- CVS fetcher: Added support for non-default port
|
||||
- Add BBINCLUDELOGS_LINES, the number of lines to read from any logfile
|
||||
- Drop shebangs from lib/bb scripts
|
||||
|
||||
Changes in Bitbake 1.6.0:
|
||||
- Better msg handling
|
||||
- COW dict implementation from Tim Ansell (mithro) leading
|
||||
to better performance
|
||||
- Speed up of -s
|
||||
|
||||
Changes in Bitbake 1.4.4:
|
||||
- SRCDATE now handling courtsey Justin Patrin
|
||||
- #1017 fix to work with rm_work
|
||||
|
||||
Changes in BitBake 1.4.2:
|
||||
- Send logs to oe.pastebin.com instead of pastebin.com
|
||||
fixes #856
|
||||
- Copy the internal bitbake data before building the
|
||||
dependency graph. This fixes nano not having a
|
||||
virtual/libc dependency
|
||||
- Allow multiple TARBALL_STASH entries
|
||||
- Cache, check if the directory exists before changing
|
||||
into it
|
||||
- git speedup cloning by not doing a checkout
|
||||
- allow to have spaces in filenames (.conf, .bb, .bbclass)
|
||||
|
||||
Changes in BitBake 1.4.0:
|
||||
- Fix to check both RDEPENDS and RDEPENDS_${PN}
|
||||
- Fix a RDEPENDS parsing bug in utils:explode_deps()
|
||||
- Update git fetcher behaviour to match git changes
|
||||
- ASSUME_PROVIDED allowed to include runtime packages
|
||||
- git fetcher cleanup and efficency improvements
|
||||
- Change the format of the cache
|
||||
- Update usermanual to document the Fetchers
|
||||
- Major changes to caching with a new strategy
|
||||
giving a major performance increase when reparsing
|
||||
with few data changes
|
||||
|
||||
Changes in BitBake 1.3.3:
|
||||
- Create a new Fetcher module to ease the
|
||||
development of new Fetchers.
|
||||
Issue #438 fixed by rpurdie@openedhand.com
|
||||
- Make the Subversion fetcher honor the SRC Date
|
||||
(CVSDATE).
|
||||
Issue #555 fixed by chris@openedhand.com
|
||||
- Expand PREFERRED_PROVIDER properly
|
||||
Issue #436 fixed by rprudie@openedhand.com
|
||||
- Typo fix for Issue #531 by Philipp Zabel for the
|
||||
BitBake Shell
|
||||
- Introduce a new special variable SRCDATE as
|
||||
a generic naming to replace CVSDATE.
|
||||
- Introduce a new keyword 'required'. In contrast
|
||||
to 'include' parsing will fail if a to be included
|
||||
file can not be found.
|
||||
- Remove hardcoding of the STAMP directory. Patch
|
||||
courtsey pHilipp Zabel
|
||||
- Track the RDEPENDS of each package (rpurdie@openedhand.com)
|
||||
- Introduce BUILD_ALL_DEPS to build all RDEPENDS. E.g
|
||||
this is used by the OpenEmbedded Meta Packages.
|
||||
(rpurdie@openedhand.com).
|
||||
|
||||
Changes in BitBake 1.3.2:
|
||||
- reintegration of make.py into BitBake
|
||||
- bbread is gone, use bitbake -e
|
||||
- lots of shell updates and bugfixes
|
||||
- Introduction of the .= and =. operator
|
||||
- Sort variables, keys and groups in bitdoc
|
||||
- Fix regression in the handling of BBCOLLECTIONS
|
||||
- Update the bitbake usermanual
|
||||
|
||||
Changes in BitBake 1.3.0:
|
||||
- add bitbake interactive shell (bitbake -i)
|
||||
- refactor bitbake utility in OO style
|
||||
- kill default arguments in methods in the bb.data module
|
||||
- kill default arguments in methods in the bb.fetch module
|
||||
- the http/https/ftp fetcher will fail if the to be
|
||||
downloaded file was not found in DL_DIR (this is needed
|
||||
to avoid unpacking the sourceforge mirror page)
|
||||
- Switch to a cow like data instance for persistent and non
|
||||
persisting mode (called data_smart.py)
|
||||
- Changed the callback of bb.make.collect_bbfiles to carry
|
||||
additional parameters
|
||||
- Drastically reduced the amount of needed RAM by not holding
|
||||
each data instance in memory when using a cache/persistent
|
||||
storage
|
||||
|
||||
Changes in BitBake 1.2.1:
|
||||
The 1.2.1 release is meant as a intermediate release to lay the
|
||||
ground for more radical changes. The most notable changes are:
|
||||
|
||||
- Do not hardcode {}, use bb.data.init() instead if you want to
|
||||
get a instance of a data class
|
||||
- bb.data.init() is a factory and the old bb.data methods are delegates
|
||||
- Do not use deepcopy use bb.data.createCopy() instead.
|
||||
- Removed default arguments in bb.fetch
|
||||
|
||||
19
bitbake/HEADER
Normal file
19
bitbake/HEADER
Normal file
@@ -0,0 +1,19 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# <one line to give the program's name and a brief idea of what it does.>
|
||||
# Copyright (C) <year> <name of author>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
49
bitbake/MANIFEST
Normal file
49
bitbake/MANIFEST
Normal file
@@ -0,0 +1,49 @@
|
||||
AUTHORS
|
||||
COPYING
|
||||
ChangeLog
|
||||
MANIFEST
|
||||
setup.py
|
||||
bin/bitdoc
|
||||
bin/bbimage
|
||||
bin/bitbake
|
||||
lib/bb/__init__.py
|
||||
lib/bb/build.py
|
||||
lib/bb/cache.py
|
||||
lib/bb/cooker.py
|
||||
lib/bb/COW.py
|
||||
lib/bb/data.py
|
||||
lib/bb/data_smart.py
|
||||
lib/bb/event.py
|
||||
lib/bb/fetch/__init__.py
|
||||
lib/bb/fetch/cvs.py
|
||||
lib/bb/fetch/git.py
|
||||
lib/bb/fetch/local.py
|
||||
lib/bb/fetch/perforce.py
|
||||
lib/bb/fetch/ssh.py
|
||||
lib/bb/fetch/svk.py
|
||||
lib/bb/fetch/svn.py
|
||||
lib/bb/fetch/wget.py
|
||||
lib/bb/manifest.py
|
||||
lib/bb/methodpool.py
|
||||
lib/bb/msg.py
|
||||
lib/bb/parse/__init__.py
|
||||
lib/bb/parse/parse_py/__init__.py
|
||||
lib/bb/parse/parse_py/BBHandler.py
|
||||
lib/bb/parse/parse_py/ConfHandler.py
|
||||
lib/bb/providers.py
|
||||
lib/bb/runqueue.py
|
||||
lib/bb/shell.py
|
||||
lib/bb/taskdata.py
|
||||
lib/bb/utils.py
|
||||
setup.py
|
||||
doc/COPYING.GPL
|
||||
doc/COPYING.MIT
|
||||
doc/bitbake.1
|
||||
doc/manual/html.css
|
||||
doc/manual/Makefile
|
||||
doc/manual/usermanual.xml
|
||||
contrib/bbdev.sh
|
||||
contrib/vim/syntax/bitbake.vim
|
||||
contrib/vim/ftdetect/bitbake.vim
|
||||
conf/bitbake.conf
|
||||
classes/base.bbclass
|
||||
155
bitbake/bin/bbimage
Executable file
155
bitbake/bin/bbimage
Executable file
@@ -0,0 +1,155 @@
|
||||
#!/usr/bin/env python
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# Copyright (C) 2003 Chris Larson
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import sys, os
|
||||
sys.path.insert(0,os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
|
||||
import bb
|
||||
from bb import *
|
||||
|
||||
__version__ = 1.1
|
||||
type = "jffs2"
|
||||
cfg_bb = data.init()
|
||||
cfg_oespawn = data.init()
|
||||
|
||||
bb.msg.set_debug_level(0)
|
||||
|
||||
def usage():
|
||||
print "Usage: bbimage [options ...]"
|
||||
print "Creates an image for a target device from a root filesystem,"
|
||||
print "obeying configuration parameters from the BitBake"
|
||||
print "configuration files, thereby easing handling of deviceisms."
|
||||
print ""
|
||||
print " %s\t\t%s" % ("-r [arg], --root [arg]", "root directory (default=${IMAGE_ROOTFS})")
|
||||
print " %s\t\t%s" % ("-t [arg], --type [arg]", "image type (jffs2[default], cramfs)")
|
||||
print " %s\t\t%s" % ("-n [arg], --name [arg]", "image name (override IMAGE_NAME variable)")
|
||||
print " %s\t\t%s" % ("-v, --version", "output version information and exit")
|
||||
sys.exit(0)
|
||||
|
||||
def version():
|
||||
print "BitBake Build Tool Core version %s" % bb.__version__
|
||||
print "BBImage version %s" % __version__
|
||||
|
||||
def emit_bb(d, base_d = {}):
|
||||
for v in d.keys():
|
||||
if d[v] != base_d[v]:
|
||||
data.emit_var(v, d)
|
||||
|
||||
def getopthash(l):
|
||||
h = {}
|
||||
for (opt, val) in l:
|
||||
h[opt] = val
|
||||
return h
|
||||
|
||||
import getopt
|
||||
try:
|
||||
(opts, args) = getopt.getopt(sys.argv[1:], 'vr:t:e:n:', [ 'version', 'root=', 'type=', 'bbfile=', 'name=' ])
|
||||
except getopt.GetoptError:
|
||||
usage()
|
||||
|
||||
# handle opts
|
||||
opthash = getopthash(opts)
|
||||
|
||||
if '--version' in opthash or '-v' in opthash:
|
||||
version()
|
||||
sys.exit(0)
|
||||
|
||||
try:
|
||||
cfg_bb = parse.handle(os.path.join('conf', 'bitbake.conf'), cfg_bb)
|
||||
except IOError:
|
||||
fatal("Unable to open bitbake.conf")
|
||||
|
||||
# sanity check
|
||||
if cfg_bb is None:
|
||||
fatal("Unable to open/parse %s" % os.path.join('conf', 'bitbake.conf'))
|
||||
usage(1)
|
||||
|
||||
rootfs = None
|
||||
extra_files = []
|
||||
|
||||
if '--root' in opthash:
|
||||
rootfs = opthash['--root']
|
||||
if '-r' in opthash:
|
||||
rootfs = opthash['-r']
|
||||
|
||||
if '--type' in opthash:
|
||||
type = opthash['--type']
|
||||
if '-t' in opthash:
|
||||
type = opthash['-t']
|
||||
|
||||
if '--bbfile' in opthash:
|
||||
extra_files.append(opthash['--bbfile'])
|
||||
if '-e' in opthash:
|
||||
extra_files.append(opthash['-e'])
|
||||
|
||||
for f in extra_files:
|
||||
try:
|
||||
cfg_bb = parse.handle(f, cfg_bb)
|
||||
except IOError:
|
||||
print "unable to open %s" % f
|
||||
|
||||
if not rootfs:
|
||||
rootfs = data.getVar('IMAGE_ROOTFS', cfg_bb, 1)
|
||||
|
||||
if not rootfs:
|
||||
bb.fatal("IMAGE_ROOTFS not defined")
|
||||
|
||||
data.setVar('IMAGE_ROOTFS', rootfs, cfg_bb)
|
||||
|
||||
from copy import copy, deepcopy
|
||||
localdata = data.createCopy(cfg_bb)
|
||||
|
||||
overrides = data.getVar('OVERRIDES', localdata)
|
||||
if not overrides:
|
||||
bb.fatal("OVERRIDES not defined.")
|
||||
data.setVar('OVERRIDES', '%s:%s' % (overrides, type), localdata)
|
||||
data.update_data(localdata)
|
||||
data.setVar('OVERRIDES', overrides, localdata)
|
||||
|
||||
if '-n' in opthash:
|
||||
data.setVar('IMAGE_NAME', opthash['-n'], localdata)
|
||||
if '--name' in opthash:
|
||||
data.setVar('IMAGE_NAME', opthash['--name'], localdata)
|
||||
|
||||
topdir = data.getVar('TOPDIR', localdata, 1) or os.getcwd()
|
||||
|
||||
cmd = data.getVar('IMAGE_CMD', localdata, 1)
|
||||
if not cmd:
|
||||
bb.fatal("IMAGE_CMD not defined")
|
||||
|
||||
outdir = data.getVar('DEPLOY_DIR_IMAGE', localdata, 1)
|
||||
if not outdir:
|
||||
bb.fatal('DEPLOY_DIR_IMAGE not defined')
|
||||
mkdirhier(outdir)
|
||||
|
||||
#depends = data.getVar('IMAGE_DEPENDS', localdata, 1) or ""
|
||||
#if depends:
|
||||
# bb.note("Spawning bbmake to satisfy dependencies: %s" % depends)
|
||||
# ret = os.system('bbmake %s' % depends)
|
||||
# if ret != 0:
|
||||
# bb.error("executing bbmake to satisfy dependencies")
|
||||
|
||||
bb.note("Executing %s" % cmd)
|
||||
data.setVar('image_cmd', cmd, localdata)
|
||||
data.setVarFlag('image_cmd', 'func', 1, localdata)
|
||||
try:
|
||||
bb.build.exec_func('image_cmd', localdata)
|
||||
except bb.build.FuncFailed:
|
||||
sys.exit(1)
|
||||
#ret = os.system(cmd)
|
||||
#sys.exit(ret)
|
||||
117
bitbake/bin/bitbake
Executable file
117
bitbake/bin/bitbake
Executable file
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env python
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
# Copyright (C) 2003, 2004 Phil Blundell
|
||||
# Copyright (C) 2003 - 2005 Michael 'Mickey' Lauer
|
||||
# Copyright (C) 2005 Holger Hans Peter Freyther
|
||||
# Copyright (C) 2005 ROAD GmbH
|
||||
# Copyright (C) 2006 Richard Purdie
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import sys, os, getopt, re, time, optparse
|
||||
sys.path.insert(0,os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
|
||||
import bb
|
||||
from bb import cooker
|
||||
|
||||
__version__ = "1.8.5"
|
||||
|
||||
#============================================================================#
|
||||
# BBOptions
|
||||
#============================================================================#
|
||||
class BBConfiguration( object ):
|
||||
"""
|
||||
Manages build options and configurations for one run
|
||||
"""
|
||||
def __init__( self, options ):
|
||||
for key, val in options.__dict__.items():
|
||||
setattr( self, key, val )
|
||||
|
||||
|
||||
#============================================================================#
|
||||
# main
|
||||
#============================================================================#
|
||||
|
||||
def main():
|
||||
parser = optparse.OptionParser( version = "BitBake Build Tool Core version %s, %%prog version %s" % ( bb.__version__, __version__ ),
|
||||
usage = """%prog [options] [package ...]
|
||||
|
||||
Executes the specified task (default is 'build') for a given set of BitBake files.
|
||||
It expects that BBFILES is defined, which is a space seperated list of files to
|
||||
be executed. BBFILES does support wildcards.
|
||||
Default BBFILES are the .bb files in the current directory.""" )
|
||||
|
||||
parser.add_option( "-b", "--buildfile", help = "execute the task against this .bb file, rather than a package from BBFILES.",
|
||||
action = "store", dest = "buildfile", default = None )
|
||||
|
||||
parser.add_option( "-k", "--continue", help = "continue as much as possible after an error. While the target that failed, and those that depend on it, cannot be remade, the other dependencies of these targets can be processed all the same.",
|
||||
action = "store_false", dest = "abort", default = True )
|
||||
|
||||
parser.add_option( "-f", "--force", help = "force run of specified cmd, regardless of stamp status",
|
||||
action = "store_true", dest = "force", default = False )
|
||||
|
||||
parser.add_option( "-i", "--interactive", help = "drop into the interactive mode also called the BitBake shell.",
|
||||
action = "store_true", dest = "interactive", default = False )
|
||||
|
||||
parser.add_option( "-c", "--cmd", help = "Specify task to execute. Note that this only executes the specified task for the providee and the packages it depends on, i.e. 'compile' does not implicitly call stage for the dependencies (IOW: use only if you know what you are doing). Depending on the base.bbclass a listtasks tasks is defined and will show available tasks",
|
||||
action = "store", dest = "cmd" )
|
||||
|
||||
parser.add_option( "-r", "--read", help = "read the specified file before bitbake.conf",
|
||||
action = "append", dest = "file", default = [] )
|
||||
|
||||
parser.add_option( "-v", "--verbose", help = "output more chit-chat to the terminal",
|
||||
action = "store_true", dest = "verbose", default = False )
|
||||
|
||||
parser.add_option( "-D", "--debug", help = "Increase the debug level. You can specify this more than once.",
|
||||
action = "count", dest="debug", default = 0)
|
||||
|
||||
parser.add_option( "-n", "--dry-run", help = "don't execute, just go through the motions",
|
||||
action = "store_true", dest = "dry_run", default = False )
|
||||
|
||||
parser.add_option( "-p", "--parse-only", help = "quit after parsing the BB files (developers only)",
|
||||
action = "store_true", dest = "parse_only", default = False )
|
||||
|
||||
parser.add_option( "-d", "--disable-psyco", help = "disable using the psyco just-in-time compiler (not recommended)",
|
||||
action = "store_true", dest = "disable_psyco", default = False )
|
||||
|
||||
parser.add_option( "-s", "--show-versions", help = "show current and preferred versions of all packages",
|
||||
action = "store_true", dest = "show_versions", default = False )
|
||||
|
||||
parser.add_option( "-e", "--environment", help = "show the global or per-package environment (this is what used to be bbread)",
|
||||
action = "store_true", dest = "show_environment", default = False )
|
||||
|
||||
parser.add_option( "-g", "--graphviz", help = "emit the dependency trees of the specified packages in the dot syntax",
|
||||
action = "store_true", dest = "dot_graph", default = False )
|
||||
|
||||
parser.add_option( "-I", "--ignore-deps", help = """Stop processing at the given list of dependencies when generating dependency graphs. This can help to make the graph more appealing""",
|
||||
action = "append", dest = "ignored_dot_deps", default = [] )
|
||||
|
||||
parser.add_option( "-l", "--log-domains", help = """Show debug logging for the specified logging domains""",
|
||||
action = "append", dest = "debug_domains", default = [] )
|
||||
|
||||
|
||||
options, args = parser.parse_args(sys.argv)
|
||||
|
||||
configuration = BBConfiguration(options)
|
||||
configuration.pkgs_to_build = []
|
||||
configuration.pkgs_to_build.extend(args[1:])
|
||||
|
||||
cooker = bb.cooker.BBCooker(configuration)
|
||||
cooker.cook()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
532
bitbake/bin/bitdoc
Executable file
532
bitbake/bin/bitdoc
Executable file
@@ -0,0 +1,532 @@
|
||||
#!/usr/bin/env python
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# Copyright (C) 2005 Holger Hans Peter Freyther
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import optparse, os, sys
|
||||
|
||||
# bitbake
|
||||
sys.path.append(os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
|
||||
import bb
|
||||
import bb.parse
|
||||
from string import split, join
|
||||
|
||||
__version__ = "0.0.2"
|
||||
|
||||
class HTMLFormatter:
|
||||
"""
|
||||
Simple class to help to generate some sort of HTML files. It is
|
||||
quite inferior solution compared to docbook, gtkdoc, doxygen but it
|
||||
should work for now.
|
||||
We've a global introduction site (index.html) and then one site for
|
||||
the list of keys (alphabetical sorted) and one for the list of groups,
|
||||
one site for each key with links to the relations and groups.
|
||||
|
||||
index.html
|
||||
all_keys.html
|
||||
all_groups.html
|
||||
groupNAME.html
|
||||
keyNAME.html
|
||||
"""
|
||||
|
||||
def replace(self, text, *pairs):
|
||||
"""
|
||||
From pydoc... almost identical at least
|
||||
"""
|
||||
while pairs:
|
||||
(a,b) = pairs[0]
|
||||
text = join(split(text, a), b)
|
||||
pairs = pairs[1:]
|
||||
return text
|
||||
def escape(self, text):
|
||||
"""
|
||||
Escape string to be conform HTML
|
||||
"""
|
||||
return self.replace(text,
|
||||
('&', '&'),
|
||||
('<', '<' ),
|
||||
('>', '>' ) )
|
||||
def createNavigator(self):
|
||||
"""
|
||||
Create the navgiator
|
||||
"""
|
||||
return """<table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
|
||||
<tr valign="middle">
|
||||
<td><a accesskey="g" href="index.html">Home</a></td>
|
||||
<td><a accesskey="n" href="all_groups.html">Groups</a></td>
|
||||
<td><a accesskey="u" href="all_keys.html">Keys</a></td>
|
||||
</tr></table>
|
||||
"""
|
||||
|
||||
def relatedKeys(self, item):
|
||||
"""
|
||||
Create HTML to link to foreign keys
|
||||
"""
|
||||
|
||||
if len(item.related()) == 0:
|
||||
return ""
|
||||
|
||||
txt = "<p><b>See also:</b><br>"
|
||||
txts = []
|
||||
for it in item.related():
|
||||
txts.append("""<a href="key%(it)s.html">%(it)s</a>""" % vars() )
|
||||
|
||||
return txt + ",".join(txts)
|
||||
|
||||
def groups(self,item):
|
||||
"""
|
||||
Create HTML to link to related groups
|
||||
"""
|
||||
|
||||
if len(item.groups()) == 0:
|
||||
return ""
|
||||
|
||||
|
||||
txt = "<p><b>See also:</b><br>"
|
||||
txts = []
|
||||
for group in item.groups():
|
||||
txts.append( """<a href="group%s.html">%s</a> """ % (group,group) )
|
||||
|
||||
return txt + ",".join(txts)
|
||||
|
||||
|
||||
def createKeySite(self,item):
|
||||
"""
|
||||
Create a site for a key. It contains the header/navigator, a heading,
|
||||
the description, links to related keys and to the groups.
|
||||
"""
|
||||
|
||||
return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Key %s</title></head>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
%s
|
||||
<h2><span class="refentrytitle">%s</span></h2>
|
||||
|
||||
<div class="refsynopsisdiv">
|
||||
<h2>Synopsis</h2>
|
||||
<p>
|
||||
%s
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="refsynopsisdiv">
|
||||
<h2>Related Keys</h2>
|
||||
<p>
|
||||
%s
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="refsynopsisdiv">
|
||||
<h2>Groups</h2>
|
||||
<p>
|
||||
%s
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
""" % (item.name(), self.createNavigator(), item.name(),
|
||||
self.escape(item.description()), self.relatedKeys(item), self.groups(item))
|
||||
|
||||
def createGroupsSite(self, doc):
|
||||
"""
|
||||
Create the Group Overview site
|
||||
"""
|
||||
|
||||
groups = ""
|
||||
sorted_groups = doc.groups()
|
||||
sorted_groups.sort()
|
||||
for group in sorted_groups:
|
||||
groups += """<a href="group%s.html">%s</a><br>""" % (group, group)
|
||||
|
||||
return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Group overview</title></head>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
%s
|
||||
<h2>Available Groups</h2>
|
||||
%s
|
||||
</body>
|
||||
""" % (self.createNavigator(), groups)
|
||||
|
||||
def createIndex(self):
|
||||
"""
|
||||
Create the index file
|
||||
"""
|
||||
|
||||
return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Bitbake Documentation</title></head>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
%s
|
||||
<h2>Documentation Entrance</h2>
|
||||
<a href="all_groups.html">All available groups</a><br>
|
||||
<a href="all_keys.html">All available keys</a><br>
|
||||
</body>
|
||||
""" % self.createNavigator()
|
||||
|
||||
def createKeysSite(self, doc):
|
||||
"""
|
||||
Create Overview of all avilable keys
|
||||
"""
|
||||
keys = ""
|
||||
sorted_keys = doc.doc_keys()
|
||||
sorted_keys.sort()
|
||||
for key in sorted_keys:
|
||||
keys += """<a href="key%s.html">%s</a><br>""" % (key, key)
|
||||
|
||||
return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Key overview</title></head>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
%s
|
||||
<h2>Available Keys</h2>
|
||||
%s
|
||||
</body>
|
||||
""" % (self.createNavigator(), keys)
|
||||
|
||||
def createGroupSite(self, gr, items, _description = None):
|
||||
"""
|
||||
Create a site for a group:
|
||||
Group the name of the group, items contain the name of the keys
|
||||
inside this group
|
||||
"""
|
||||
groups = ""
|
||||
description = ""
|
||||
|
||||
# create a section with the group descriptions
|
||||
if _description:
|
||||
description += "<h2 Description of Grozp %s</h2>" % gr
|
||||
description += _description
|
||||
|
||||
items.sort(lambda x,y:cmp(x.name(),y.name()))
|
||||
for group in items:
|
||||
groups += """<a href="key%s.html">%s</a><br>""" % (group.name(), group.name())
|
||||
|
||||
return """<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Group %s</title></head>
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
%s
|
||||
%s
|
||||
<div class="refsynopsisdiv">
|
||||
<h2>Keys in Group %s</h2>
|
||||
<pre class="synopsis">
|
||||
%s
|
||||
</pre>
|
||||
</div>
|
||||
</body>
|
||||
""" % (gr, self.createNavigator(), description, gr, groups)
|
||||
|
||||
|
||||
|
||||
def createCSS(self):
|
||||
"""
|
||||
Create the CSS file
|
||||
"""
|
||||
return """.synopsis, .classsynopsis
|
||||
{
|
||||
background: #eeeeee;
|
||||
border: solid 1px #aaaaaa;
|
||||
padding: 0.5em;
|
||||
}
|
||||
.programlisting
|
||||
{
|
||||
background: #eeeeff;
|
||||
border: solid 1px #aaaaff;
|
||||
padding: 0.5em;
|
||||
}
|
||||
.variablelist
|
||||
{
|
||||
padding: 4px;
|
||||
margin-left: 3em;
|
||||
}
|
||||
.variablelist td:first-child
|
||||
{
|
||||
vertical-align: top;
|
||||
}
|
||||
table.navigation
|
||||
{
|
||||
background: #ffeeee;
|
||||
border: solid 1px #ffaaaa;
|
||||
margin-top: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
.navigation a
|
||||
{
|
||||
color: #770000;
|
||||
}
|
||||
.navigation a:visited
|
||||
{
|
||||
color: #550000;
|
||||
}
|
||||
.navigation .title
|
||||
{
|
||||
font-size: 200%;
|
||||
}
|
||||
div.refnamediv
|
||||
{
|
||||
margin-top: 2em;
|
||||
}
|
||||
div.gallery-float
|
||||
{
|
||||
float: left;
|
||||
padding: 10px;
|
||||
}
|
||||
div.gallery-float img
|
||||
{
|
||||
border-style: none;
|
||||
}
|
||||
div.gallery-spacer
|
||||
{
|
||||
clear: both;
|
||||
}
|
||||
a
|
||||
{
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover
|
||||
{
|
||||
text-decoration: underline;
|
||||
color: #FF0000;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
|
||||
class DocumentationItem:
|
||||
"""
|
||||
A class to hold information about a configuration
|
||||
item. It contains the key name, description, a list of related names,
|
||||
and the group this item is contained in.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._groups = []
|
||||
self._related = []
|
||||
self._name = ""
|
||||
self._desc = ""
|
||||
|
||||
def groups(self):
|
||||
return self._groups
|
||||
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
def description(self):
|
||||
return self._desc
|
||||
|
||||
def related(self):
|
||||
return self._related
|
||||
|
||||
def setName(self, name):
|
||||
self._name = name
|
||||
|
||||
def setDescription(self, desc):
|
||||
self._desc = desc
|
||||
|
||||
def addGroup(self, group):
|
||||
self._groups.append(group)
|
||||
|
||||
def addRelation(self,relation):
|
||||
self._related.append(relation)
|
||||
|
||||
def sort(self):
|
||||
self._related.sort()
|
||||
self._groups.sort()
|
||||
|
||||
|
||||
class Documentation:
|
||||
"""
|
||||
Holds the documentation... with mappings from key to items...
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.__keys = {}
|
||||
self.__groups = {}
|
||||
|
||||
def insert_doc_item(self, item):
|
||||
"""
|
||||
Insert the Doc Item into the internal list
|
||||
of representation
|
||||
"""
|
||||
item.sort()
|
||||
self.__keys[item.name()] = item
|
||||
|
||||
for group in item.groups():
|
||||
if not group in self.__groups:
|
||||
self.__groups[group] = []
|
||||
self.__groups[group].append(item)
|
||||
self.__groups[group].sort()
|
||||
|
||||
|
||||
def doc_item(self, key):
|
||||
"""
|
||||
Return the DocumentationInstance describing the key
|
||||
"""
|
||||
try:
|
||||
return self.__keys[key]
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
def doc_keys(self):
|
||||
"""
|
||||
Return the documented KEYS (names)
|
||||
"""
|
||||
return self.__keys.keys()
|
||||
|
||||
def groups(self):
|
||||
"""
|
||||
Return the names of available groups
|
||||
"""
|
||||
return self.__groups.keys()
|
||||
|
||||
def group_content(self,group_name):
|
||||
"""
|
||||
Return a list of keys/names that are in a specefic
|
||||
group or the empty list
|
||||
"""
|
||||
try:
|
||||
return self.__groups[group_name]
|
||||
except KeyError:
|
||||
return []
|
||||
|
||||
|
||||
def parse_cmdline(args):
|
||||
"""
|
||||
Parse the CMD line and return the result as a n-tuple
|
||||
"""
|
||||
|
||||
parser = optparse.OptionParser( version = "Bitbake Documentation Tool Core version %s, %%prog version %s" % (bb.__version__,__version__))
|
||||
usage = """%prog [options]
|
||||
|
||||
Create a set of html pages (documentation) for a bitbake.conf....
|
||||
"""
|
||||
|
||||
# Add the needed options
|
||||
parser.add_option( "-c", "--config", help = "Use the specified configuration file as source",
|
||||
action = "store", dest = "config", default = os.path.join("conf", "documentation.conf") )
|
||||
|
||||
parser.add_option( "-o", "--output", help = "Output directory for html files",
|
||||
action = "store", dest = "output", default = "html/" )
|
||||
|
||||
parser.add_option( "-D", "--debug", help = "Increase the debug level",
|
||||
action = "count", dest = "debug", default = 0 )
|
||||
|
||||
parser.add_option( "-v","--verbose", help = "output more chit-char to the terminal",
|
||||
action = "store_true", dest = "verbose", default = False )
|
||||
|
||||
options, args = parser.parse_args( sys.argv )
|
||||
|
||||
if options.debug:
|
||||
bb.msg.set_debug_level(options.debug)
|
||||
|
||||
return options.config, options.output
|
||||
|
||||
def main():
|
||||
"""
|
||||
The main Method
|
||||
"""
|
||||
|
||||
(config_file,output_dir) = parse_cmdline( sys.argv )
|
||||
|
||||
# right to let us load the file now
|
||||
try:
|
||||
documentation = bb.parse.handle( config_file, bb.data.init() )
|
||||
except IOError:
|
||||
bb.fatal( "Unable to open %s" % config_file )
|
||||
except bb.parse.ParseError:
|
||||
bb.fatal( "Unable to parse %s" % config_file )
|
||||
|
||||
|
||||
# Assuming we've the file loaded now, we will initialize the 'tree'
|
||||
doc = Documentation()
|
||||
|
||||
# defined states
|
||||
state_begin = 0
|
||||
state_see = 1
|
||||
state_group = 2
|
||||
|
||||
for key in bb.data.keys(documentation):
|
||||
data = bb.data.getVarFlag(key, "doc", documentation)
|
||||
if not data:
|
||||
continue
|
||||
|
||||
# The Documentation now starts
|
||||
doc_ins = DocumentationItem()
|
||||
doc_ins.setName(key)
|
||||
|
||||
|
||||
tokens = data.split(' ')
|
||||
state = state_begin
|
||||
string= ""
|
||||
for token in tokens:
|
||||
token = token.strip(',')
|
||||
|
||||
if not state == state_see and token == "@see":
|
||||
state = state_see
|
||||
continue
|
||||
elif not state == state_group and token == "@group":
|
||||
state = state_group
|
||||
continue
|
||||
|
||||
if state == state_begin:
|
||||
string += " %s" % token
|
||||
elif state == state_see:
|
||||
doc_ins.addRelation(token)
|
||||
elif state == state_group:
|
||||
doc_ins.addGroup(token)
|
||||
|
||||
# set the description
|
||||
doc_ins.setDescription(string)
|
||||
doc.insert_doc_item(doc_ins)
|
||||
|
||||
# let us create the HTML now
|
||||
bb.mkdirhier(output_dir)
|
||||
os.chdir(output_dir)
|
||||
|
||||
# Let us create the sites now. We do it in the following order
|
||||
# Start with the index.html. It will point to sites explaining all
|
||||
# keys and groups
|
||||
html_slave = HTMLFormatter()
|
||||
|
||||
f = file('style.css', 'w')
|
||||
print >> f, html_slave.createCSS()
|
||||
|
||||
f = file('index.html', 'w')
|
||||
print >> f, html_slave.createIndex()
|
||||
|
||||
f = file('all_groups.html', 'w')
|
||||
print >> f, html_slave.createGroupsSite(doc)
|
||||
|
||||
f = file('all_keys.html', 'w')
|
||||
print >> f, html_slave.createKeysSite(doc)
|
||||
|
||||
# now for each group create the site
|
||||
for group in doc.groups():
|
||||
f = file('group%s.html' % group, 'w')
|
||||
print >> f, html_slave.createGroupSite(group, doc.group_content(group))
|
||||
|
||||
# now for the keys
|
||||
for key in doc.doc_keys():
|
||||
f = file('key%s.html' % doc.doc_item(key).name(), 'w')
|
||||
print >> f, html_slave.createKeySite(doc.doc_item(key))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
1
bitbake/contrib/README
Normal file
1
bitbake/contrib/README
Normal file
@@ -0,0 +1 @@
|
||||
This directory is for additional contributed files which may be useful.
|
||||
31
bitbake/contrib/bbdev.sh
Normal file
31
bitbake/contrib/bbdev.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
# This is a shell function to be sourced into your shell or placed in your .profile,
|
||||
# which makes setting things up for BitBake a bit easier.
|
||||
#
|
||||
# The author disclaims copyright to the contents of this file and places it in the
|
||||
# public domain.
|
||||
|
||||
bbdev () {
|
||||
local BBDIR PKGDIR BUILDDIR
|
||||
if test x"$1" = "x--help"; then echo >&2 "syntax: bbdev [bbdir [pkgdir [builddir]]]"; return 1; fi
|
||||
if test x"$1" = x; then BBDIR=`pwd`; else BBDIR=$1; fi
|
||||
if test x"$2" = x; then PKGDIR=`pwd`; else PKGDIR=$2; fi
|
||||
if test x"$3" = x; then BUILDDIR=`pwd`; else BUILDDIR=$3; fi
|
||||
|
||||
BBDIR=`readlink -f $BBDIR`
|
||||
PKGDIR=`readlink -f $PKGDIR`
|
||||
BUILDDIR=`readlink -f $BUILDDIR`
|
||||
if ! (test -d $BBDIR && test -d $PKGDIR && test -d $BUILDDIR); then
|
||||
echo >&2 "syntax: bbdev [bbdir [pkgdir [builddir]]]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
PATH=$BBDIR/bin:$PATH
|
||||
BBPATH=$BBDIR
|
||||
if test x"$BBDIR" != x"$PKGDIR"; then
|
||||
BBPATH=$PKGDIR:$BBPATH
|
||||
fi
|
||||
if test x"$PKGDIR" != x"$BUILDDIR"; then
|
||||
BBPATH=$BUILDDIR:$BBPATH
|
||||
fi
|
||||
export BBPATH
|
||||
}
|
||||
4
bitbake/contrib/vim/ftdetect/bitbake.vim
Normal file
4
bitbake/contrib/vim/ftdetect/bitbake.vim
Normal file
@@ -0,0 +1,4 @@
|
||||
au BufNewFile,BufRead *.bb setfiletype bitbake
|
||||
au BufNewFile,BufRead *.bbclass setfiletype bitbake
|
||||
au BufNewFile,BufRead *.inc setfiletype bitbake
|
||||
" au BufNewFile,BufRead *.conf setfiletype bitbake
|
||||
120
bitbake/contrib/vim/syntax/bitbake.vim
Normal file
120
bitbake/contrib/vim/syntax/bitbake.vim
Normal file
@@ -0,0 +1,120 @@
|
||||
" Vim syntax file
|
||||
"
|
||||
" Copyright (C) 2004 Chris Larson <kergoth@handhelds.org>
|
||||
" This file is licensed under the MIT license, see COPYING.MIT in
|
||||
" this source distribution for the terms.
|
||||
"
|
||||
" Language: BitBake
|
||||
" Maintainer: Chris Larson <kergoth@handhelds.org>
|
||||
" Filenames: *.bb, *.bbclass
|
||||
|
||||
if version < 600
|
||||
syntax clear
|
||||
elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
syn case match
|
||||
|
||||
|
||||
" Catch incorrect syntax (only matches if nothing else does)
|
||||
"
|
||||
syn match bbUnmatched "."
|
||||
|
||||
|
||||
" Other
|
||||
|
||||
syn match bbComment "^#.*$" display contains=bbTodo
|
||||
syn keyword bbTodo TODO FIXME XXX contained
|
||||
syn match bbDelimiter "[(){}=]" contained
|
||||
syn match bbQuote /['"]/ contained
|
||||
syn match bbArrayBrackets "[\[\]]" contained
|
||||
|
||||
|
||||
" BitBake strings
|
||||
|
||||
syn match bbContinue "\\$"
|
||||
syn region bbString matchgroup=bbQuote start=/"/ skip=/\\$/ excludenl end=/"/ contained keepend contains=bbTodo,bbContinue,bbVarDeref
|
||||
syn region bbString matchgroup=bbQuote start=/'/ skip=/\\$/ excludenl end=/'/ contained keepend contains=bbTodo,bbContinue,bbVarDeref
|
||||
|
||||
|
||||
" BitBake variable metadata
|
||||
|
||||
syn keyword bbExportFlag export contained nextgroup=bbIdentifier skipwhite
|
||||
syn match bbVarDeref "${[a-zA-Z0-9\-_\.]\+}" contained
|
||||
syn match bbVarDef "^\(export\s*\)\?\([a-zA-Z0-9\-_\.]\+\(_[${}a-zA-Z0-9\-_\.]\+\)\?\)\s*\(:=\|+=\|=+\|\.=\|=\.\|?=\|=\)\@=" contains=bbExportFlag,bbIdentifier,bbVarDeref nextgroup=bbVarEq
|
||||
|
||||
syn match bbIdentifier "[a-zA-Z0-9\-_\.]\+" display contained
|
||||
"syn keyword bbVarEq = display contained nextgroup=bbVarValue
|
||||
syn match bbVarEq "\(:=\|+=\|=+\|\.=\|=\.\|?=\|=\)" contained nextgroup=bbVarValue
|
||||
syn match bbVarValue ".*$" contained contains=bbString,bbVarDeref
|
||||
|
||||
|
||||
" BitBake variable metadata flags
|
||||
syn match bbVarFlagDef "^\([a-zA-Z0-9\-_\.]\+\)\(\[[a-zA-Z0-9\-_\.]\+\]\)\@=" contains=bbIdentifier nextgroup=bbVarFlagFlag
|
||||
syn region bbVarFlagFlag matchgroup=bbArrayBrackets start="\[" end="\]\s*\(=\)\@=" keepend excludenl contained contains=bbIdentifier nextgroup=bbVarEq
|
||||
"syn match bbVarFlagFlag "\[\([a-zA-Z0-9\-_\.]\+\)\]\s*\(=\)\@=" contains=bbIdentifier nextgroup=bbVarEq
|
||||
|
||||
|
||||
" Functions!
|
||||
syn match bbFunction "\h\w*" display contained
|
||||
|
||||
|
||||
" BitBake python metadata
|
||||
syn include @python syntax/python.vim
|
||||
if exists("b:current_syntax")
|
||||
unlet b:current_syntax
|
||||
endif
|
||||
|
||||
syn keyword bbPythonFlag python contained nextgroup=bbFunction
|
||||
syn match bbPythonFuncDef "^\(python\s\+\)\(\w\+\)\?\(\s*()\s*\)\({\)\@=" contains=bbPythonFlag,bbFunction,bbDelimiter nextgroup=bbPythonFuncRegion skipwhite
|
||||
syn region bbPythonFuncRegion matchgroup=bbDelimiter start="{\s*$" end="^}\s*$" keepend contained contains=@python
|
||||
"hi def link bbPythonFuncRegion Comment
|
||||
|
||||
|
||||
" BitBake shell metadata
|
||||
syn include @shell syntax/sh.vim
|
||||
if exists("b:current_syntax")
|
||||
unlet b:current_syntax
|
||||
endif
|
||||
|
||||
syn keyword bbFakerootFlag fakeroot contained nextgroup=bbFunction
|
||||
syn match bbShellFuncDef "^\(fakeroot\s*\)\?\(\w\+\)\(python\)\@<!\(\s*()\s*\)\({\)\@=" contains=bbFakerootFlag,bbFunction,bbDelimiter nextgroup=bbShellFuncRegion skipwhite
|
||||
syn region bbShellFuncRegion matchgroup=bbDelimiter start="{\s*$" end="^}\s*$" keepend contained contains=@shell
|
||||
"hi def link bbShellFuncRegion Comment
|
||||
|
||||
|
||||
" BitBake 'def'd python functions
|
||||
syn keyword bbDef def contained
|
||||
syn region bbDefRegion start='^def\s\+\w\+\s*([^)]*)\s*:\s*$' end='^\(\s\|$\)\@!' contains=@python
|
||||
|
||||
|
||||
" BitBake statements
|
||||
syn keyword bbStatement include inherit require addtask addhandler EXPORT_FUNCTIONS display contained
|
||||
syn match bbStatementLine "^\(include\|inherit\|require\|addtask\|addhandler\|EXPORT_FUNCTIONS\)\s\+" contains=bbStatement nextgroup=bbStatementRest
|
||||
syn match bbStatementRest ".*$" contained contains=bbString,bbVarDeref
|
||||
|
||||
" Highlight
|
||||
"
|
||||
hi def link bbArrayBrackets Statement
|
||||
hi def link bbUnmatched Error
|
||||
hi def link bbVarDeref String
|
||||
hi def link bbContinue Special
|
||||
hi def link bbDef Statement
|
||||
hi def link bbPythonFlag Type
|
||||
hi def link bbExportFlag Type
|
||||
hi def link bbFakerootFlag Type
|
||||
hi def link bbStatement Statement
|
||||
hi def link bbString String
|
||||
hi def link bbTodo Todo
|
||||
hi def link bbComment Comment
|
||||
hi def link bbOperator Operator
|
||||
hi def link bbError Error
|
||||
hi def link bbFunction Function
|
||||
hi def link bbDelimiter Delimiter
|
||||
hi def link bbIdentifier Identifier
|
||||
hi def link bbVarEq Operator
|
||||
hi def link bbQuote String
|
||||
hi def link bbVarValue String
|
||||
|
||||
let b:current_syntax = "bb"
|
||||
339
bitbake/doc/COPYING.GPL
Normal file
339
bitbake/doc/COPYING.GPL
Normal file
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
17
bitbake/doc/COPYING.MIT
Normal file
17
bitbake/doc/COPYING.MIT
Normal file
@@ -0,0 +1,17 @@
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
117
bitbake/doc/bitbake.1
Normal file
117
bitbake/doc/bitbake.1
Normal file
@@ -0,0 +1,117 @@
|
||||
.\" Hey, EMACS: -*- nroff -*-
|
||||
.\" First parameter, NAME, should be all caps
|
||||
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
|
||||
.\" other parameters are allowed: see man(7), man(1)
|
||||
.TH BITBAKE 1 "November 19, 2006"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.\" Some roff macros, for reference:
|
||||
.\" .nh disable hyphenation
|
||||
.\" .hy enable hyphenation
|
||||
.\" .ad l left justify
|
||||
.\" .ad b justify to both left and right margins
|
||||
.\" .nf disable filling
|
||||
.\" .fi enable filling
|
||||
.\" .br insert line break
|
||||
.\" .sp <n> insert n+1 empty lines
|
||||
.\" for manpage-specific macros, see man(7)
|
||||
.SH NAME
|
||||
BitBake \- simple tool for the execution of tasks
|
||||
.SH SYNOPSIS
|
||||
.B bitbake
|
||||
.RI [ options ] " packagenames"
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
This manual page documents briefly the
|
||||
.B bitbake
|
||||
command.
|
||||
.PP
|
||||
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
|
||||
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
|
||||
.\" respectively.
|
||||
\fBbitbake\fP is a program that executes the specified task (default is 'build')
|
||||
for a given set of BitBake files.
|
||||
.br
|
||||
It expects that BBFILES is defined, which is a space seperated list of files to
|
||||
be executed. BBFILES does support wildcards.
|
||||
.br
|
||||
Default BBFILES are the .bb files in the current directory.
|
||||
.SH OPTIONS
|
||||
This program follow the usual GNU command line syntax, with long
|
||||
options starting with two dashes (`-').
|
||||
.TP
|
||||
.B \-h, \-\-help
|
||||
Show summary of options.
|
||||
.TP
|
||||
.B \-\-version
|
||||
Show version of program.
|
||||
.TP
|
||||
.B \-bBUILDFILE, \-\-buildfile=BUILDFILE
|
||||
execute the task against this .bb file, rather than a package from BBFILES.
|
||||
.TP
|
||||
.B \-k, \-\-continue
|
||||
continue as much as possible after an error. While the target that failed, and
|
||||
those that depend on it, cannot be remade, the other dependencies of these
|
||||
targets can be processed all the same.
|
||||
.TP
|
||||
.B \-f, \-\-force
|
||||
force run of specified cmd, regardless of stamp status
|
||||
.TP
|
||||
.B \-i, \-\-interactive
|
||||
drop into the interactive mode also called the BitBake shell.
|
||||
.TP
|
||||
.B \-cCMD, \-\-cmd=CMD
|
||||
Specify task to execute. Note that this only executes the specified task for
|
||||
the providee and the packages it depends on, i.e. 'compile' does not implicitly
|
||||
call stage for the dependencies (IOW: use only if you know what you are doing).
|
||||
Depending on the base.bbclass a listtaks tasks is defined and will show
|
||||
available tasks.
|
||||
.TP
|
||||
.B \-rFILE, \-\-read=FILE
|
||||
read the specified file before bitbake.conf
|
||||
.TP
|
||||
.B \-v, \-\-verbose
|
||||
output more chit-chat to the terminal
|
||||
.TP
|
||||
.B \-D, \-\-debug
|
||||
Increase the debug level. You can specify this more than once.
|
||||
.TP
|
||||
.B \-n, \-\-dry-run
|
||||
don't execute, just go through the motions
|
||||
.TP
|
||||
.B \-p, \-\-parse-only
|
||||
quit after parsing the BB files (developers only)
|
||||
.TP
|
||||
.B \-d, \-\-disable-psyco
|
||||
disable using the psyco just-in-time compiler (not recommended)
|
||||
.TP
|
||||
.B \-s, \-\-show-versions
|
||||
show current and preferred versions of all packages
|
||||
.TP
|
||||
.B \-e, \-\-environment
|
||||
show the global or per-package environment (this is what used to be bbread)
|
||||
.TP
|
||||
.B \-g, \-\-graphviz
|
||||
emit the dependency trees of the specified packages in the dot syntax
|
||||
.TP
|
||||
.B \-IIGNORED\_DOT\_DEPS, \-\-ignore-deps=IGNORED_DOT_DEPS
|
||||
Stop processing at the given list of dependencies when generating dependency
|
||||
graphs. This can help to make the graph more appealing
|
||||
.\"
|
||||
.\" Next option is only in BitBake 1.7.x (trunk)
|
||||
.\"
|
||||
.\".TP
|
||||
.\".B \-lDEBUG_DOMAINS, \-\-log-domains=DEBUG_DOMAINS
|
||||
.\"Show debug logging for the specified logging domains
|
||||
|
||||
.SH AUTHORS
|
||||
BitBake was written by
|
||||
Phil Blundell,
|
||||
Holger Freyther,
|
||||
Chris Larson,
|
||||
Mickey Lauer,
|
||||
Richard Purdie,
|
||||
Holger Schurig
|
||||
.PP
|
||||
This manual page was written by Marcin Juszkiewicz <marcin@hrw.one.pl>
|
||||
for the Debian project (but may be used by others).
|
||||
56
bitbake/doc/manual/Makefile
Normal file
56
bitbake/doc/manual/Makefile
Normal file
@@ -0,0 +1,56 @@
|
||||
topdir = .
|
||||
manual = $(topdir)/usermanual.xml
|
||||
# types = pdf txt rtf ps xhtml html man tex texi dvi
|
||||
# types = pdf txt
|
||||
types = $(xmltotypes) $(htmltypes)
|
||||
xmltotypes = pdf txt
|
||||
htmltypes = html xhtml
|
||||
htmlxsl = $(if $(filter $@,$(foreach type,$(htmltypes),$(type)-nochunks)),http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl,http://docbook.sourceforge.net/release/xsl/current/$@/chunk.xsl)
|
||||
htmlcssfile = docbook.css
|
||||
htmlcss = $(topdir)/html.css
|
||||
# htmlcssfile =
|
||||
# htmlcss =
|
||||
cleanfiles = $(foreach i,$(types),$(topdir)/$(i))
|
||||
|
||||
ifdef DEBUG
|
||||
define command
|
||||
$(1)
|
||||
endef
|
||||
else
|
||||
define command
|
||||
@echo $(2) $(3) $(4)
|
||||
@$(1) >/dev/null
|
||||
endef
|
||||
endif
|
||||
|
||||
all: $(types)
|
||||
|
||||
lint: $(manual) FORCE
|
||||
$(call command,xmllint --xinclude --postvalid --noout $(manual),XMLLINT $(manual))
|
||||
|
||||
$(types) $(foreach type,$(htmltypes),$(type)-nochunks): lint FORCE
|
||||
|
||||
$(foreach type,$(htmltypes),$(type)-nochunks): $(if $(htmlcss),$(htmlcss)) $(manual)
|
||||
@mkdir -p $@
|
||||
ifdef htmlcss
|
||||
$(call command,install -m 0644 $(htmlcss) $@/$(htmlcssfile),CP $(htmlcss) $@/$(htmlcssfile))
|
||||
endif
|
||||
$(call command,xsltproc --stringparam base.dir $@/ $(if $(htmlcssfile),--stringparam html.stylesheet $(htmlcssfile)) $(htmlxsl) $(manual) > $@/index.$(patsubst %-nochunks,%,$@),XSLTPROC $@ $(manual))
|
||||
|
||||
$(htmltypes): $(if $(htmlcss),$(htmlcss)) $(manual)
|
||||
@mkdir -p $@
|
||||
ifdef htmlcss
|
||||
$(call command,install -m 0644 $(htmlcss) $@/$(htmlcssfile),CP $(htmlcss) $@/$(htmlcssfile))
|
||||
endif
|
||||
$(call command,xsltproc --stringparam base.dir $@/ $(if $(htmlcssfile),--stringparam html.stylesheet $(htmlcssfile)) $(htmlxsl) $(manual),XSLTPROC $@ $(manual))
|
||||
|
||||
$(xmltotypes): $(manual)
|
||||
$(call command,xmlto --extensions -o $(topdir)/$@ $@ $(manual),XMLTO $@ $(manual))
|
||||
|
||||
clean:
|
||||
rm -rf $(cleanfiles)
|
||||
|
||||
$(foreach i,$(types) $(foreach type,$(htmltypes),$(type)-nochunks),clean-$(i)):
|
||||
rm -rf $(patsubst clean-%,%,$@)
|
||||
|
||||
FORCE:
|
||||
281
bitbake/doc/manual/html.css
Normal file
281
bitbake/doc/manual/html.css
Normal file
@@ -0,0 +1,281 @@
|
||||
/* Feuille de style DocBook du projet Traduc.org */
|
||||
/* DocBook CSS stylesheet of the Traduc.org project */
|
||||
|
||||
/* (c) Jean-Philippe Gu<47>rard - 14 ao<61>t 2004 */
|
||||
/* (c) Jean-Philippe Gu<47>rard - 14 August 2004 */
|
||||
|
||||
/* Cette feuille de style est libre, vous pouvez la */
|
||||
/* redistribuer et la modifier selon les termes de la Licence */
|
||||
/* Art Libre. Vous trouverez un exemplaire de cette Licence sur */
|
||||
/* http://tigreraye.org/Petit-guide-du-traducteur.html#licence-art-libre */
|
||||
|
||||
/* This work of art is free, you can redistribute it and/or */
|
||||
/* modify it according to terms of the Free Art license. You */
|
||||
/* will find a specimen of this license on the Copyleft */
|
||||
/* Attitude web site: http://artlibre.org as well as on other */
|
||||
/* sites. */
|
||||
/* Please note that the French version of this licence as shown */
|
||||
/* on http://tigreraye.org/Petit-guide-du-traducteur.html#licence-art-libre */
|
||||
/* is only official licence of this document. The English */
|
||||
/* is only provided to help you understand this licence. */
|
||||
|
||||
/* La derni<6E>re version de cette feuille de style est toujours */
|
||||
/* disponible sur<75>: http://tigreraye.org/style.css */
|
||||
/* Elle est <20>galement disponible sur<75>: */
|
||||
/* http://www.traduc.org/docs/HOWTO/lecture/style.css */
|
||||
|
||||
/* The latest version of this stylesheet is available from: */
|
||||
/* http://tigreraye.org/style.css */
|
||||
/* It is also available on: */
|
||||
/* http://www.traduc.org/docs/HOWTO/lecture/style.css */
|
||||
|
||||
/* N'h<>sitez pas <20> envoyer vos commentaires et corrections <20> */
|
||||
/* Jean-Philippe Gu<47>rard <jean-philippe.guerard@tigreraye.org> */
|
||||
|
||||
/* Please send feedback and bug reports to */
|
||||
/* Jean-Philippe Gu<47>rard <jean-philippe.guerard@tigreraye.org> */
|
||||
|
||||
/* $Id: style.css,v 1.14 2004/09/10 20:12:09 fevrier Exp fevrier $ */
|
||||
|
||||
/* Pr<50>sentation g<>n<EFBFBD>rale du document */
|
||||
/* Overall document presentation */
|
||||
|
||||
body {
|
||||
/*
|
||||
font-family: Apolline, "URW Palladio L", Garamond, jGaramond,
|
||||
"Bitstream Cyberbit", "Palatino Linotype", serif;
|
||||
*/
|
||||
margin: 7%;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
/* Taille du texte */
|
||||
/* Text size */
|
||||
|
||||
* { font-size: 100%; }
|
||||
|
||||
/* Gestion des textes mis en relief imbriqu<71>s */
|
||||
/* Embedded emphasis */
|
||||
|
||||
em { font-style: italic; }
|
||||
em em { font-style: normal; }
|
||||
em em em { font-style: italic; }
|
||||
|
||||
/* Titres */
|
||||
/* Titles */
|
||||
|
||||
h1 { font-size: 200%; font-weight: 900; }
|
||||
h2 { font-size: 160%; font-weight: 900; }
|
||||
h3 { font-size: 130%; font-weight: bold; }
|
||||
h4 { font-size: 115%; font-weight: bold; }
|
||||
h5 { font-size: 108%; font-weight: bold; }
|
||||
h6 { font-weight: bold; }
|
||||
|
||||
/* Nom de famille en petites majuscules (uniquement en fran<61>ais) */
|
||||
/* Last names in small caps (for French only) */
|
||||
|
||||
*[class~="surname"]:lang(fr) { font-variant: small-caps; }
|
||||
|
||||
/* Blocs de citation */
|
||||
/* Quotation blocs */
|
||||
|
||||
div[class~="blockquote"] {
|
||||
border: solid 2px #AAA;
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
div[class~="blockquote"] > table {
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* Blocs lit<69>raux<75>: fond gris clair */
|
||||
/* Literal blocs: light gray background */
|
||||
|
||||
*[class~="literallayout"] {
|
||||
background: #f0f0f0;
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
/* Programmes et captures texte<74>: fond bleu clair */
|
||||
/* Listing and text screen snapshots: light blue background */
|
||||
|
||||
*[class~="programlisting"], *[class~="screen"] {
|
||||
background: #f0f0ff;
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
/* Les textes <20> remplacer sont surlign<67>s en vert p<>le */
|
||||
/* Replaceable text in highlighted in pale green */
|
||||
|
||||
*[class~="replaceable"] {
|
||||
background-color: #98fb98;
|
||||
font-style: normal; }
|
||||
|
||||
/* Tables<65>: fonds gris clair & bords simples */
|
||||
/* Tables: light gray background and solid borders */
|
||||
|
||||
*[class~="table"] *[class~="title"] { width:100%; border: 0px; }
|
||||
|
||||
table {
|
||||
border: 1px solid #aaa;
|
||||
border-collapse: collapse;
|
||||
padding: 2px;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
/* Listes simples en style table */
|
||||
/* Simples lists in table presentation */
|
||||
|
||||
table[class~="simplelist"] {
|
||||
background-color: #F0F0F0;
|
||||
margin: 5px;
|
||||
border: solid 1px #AAA;
|
||||
}
|
||||
|
||||
table[class~="simplelist"] td {
|
||||
border: solid 1px #AAA;
|
||||
}
|
||||
|
||||
/* Les tables */
|
||||
/* Tables */
|
||||
|
||||
*[class~="table"] table {
|
||||
background-color: #F0F0F0;
|
||||
border: solid 1px #AAA;
|
||||
}
|
||||
*[class~="informaltable"] table { background-color: #F0F0F0; }
|
||||
|
||||
th,td {
|
||||
vertical-align: baseline;
|
||||
text-align: left;
|
||||
padding: 0.1em 0.3em;
|
||||
empty-cells: show;
|
||||
}
|
||||
|
||||
/* Alignement des colonnes */
|
||||
/* Colunms alignment */
|
||||
|
||||
td[align=center] , th[align=center] { text-align: center; }
|
||||
td[align=right] , th[align=right] { text-align: right; }
|
||||
td[align=left] , th[align=left] { text-align: left; }
|
||||
td[align=justify] , th[align=justify] { text-align: justify; }
|
||||
|
||||
/* Pas de marge autour des images */
|
||||
/* No inside margins for images */
|
||||
|
||||
img { border: 0; }
|
||||
|
||||
/* Les liens ne sont pas soulign<67>s */
|
||||
/* No underlines for links */
|
||||
|
||||
:link , :visited , :active { text-decoration: none; }
|
||||
|
||||
/* Prudence<63>: cadre jaune et fond jaune clair */
|
||||
/* Caution: yellow border and light yellow background */
|
||||
|
||||
*[class~="caution"] {
|
||||
border: solid 2px yellow;
|
||||
background-color: #ffffe0;
|
||||
padding: 1em 6px 1em ;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
*[class~="caution"] th {
|
||||
vertical-align: middle
|
||||
}
|
||||
|
||||
*[class~="caution"] table {
|
||||
background-color: #ffffe0;
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* Note importante<74>: cadre jaune et fond jaune clair */
|
||||
/* Important: yellow border and light yellow background */
|
||||
|
||||
*[class~="important"] {
|
||||
border: solid 2px yellow;
|
||||
background-color: #ffffe0;
|
||||
padding: 1em 6px 1em;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
*[class~="important"] th {
|
||||
vertical-align: middle
|
||||
}
|
||||
|
||||
*[class~="important"] table {
|
||||
background-color: #ffffe0;
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* Mise en <20>vidence<63>: texte l<>g<EFBFBD>rement plus grand */
|
||||
/* Highlights: slightly larger texts */
|
||||
|
||||
*[class~="highlights"] {
|
||||
font-size: 110%;
|
||||
}
|
||||
|
||||
/* Note<74>: cadre bleu et fond bleu clair */
|
||||
/* Notes: blue border and light blue background */
|
||||
|
||||
*[class~="note"] {
|
||||
border: solid 2px #7099C5;
|
||||
background-color: #f0f0ff;
|
||||
padding: 1em 6px 1em ;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
*[class~="note"] th {
|
||||
vertical-align: middle
|
||||
}
|
||||
|
||||
*[class~="note"] table {
|
||||
background-color: #f0f0ff;
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* Astuce<63>: cadre vert et fond vert clair */
|
||||
/* Tip: green border and light green background */
|
||||
|
||||
*[class~="tip"] {
|
||||
border: solid 2px #00ff00;
|
||||
background-color: #f0ffff;
|
||||
padding: 1em 6px 1em ;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
*[class~="tip"] th {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
*[class~="tip"] table {
|
||||
background-color: #f0ffff;
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* Avertissement<6E>: cadre rouge et fond rouge clair */
|
||||
/* Warning: red border and light red background */
|
||||
|
||||
*[class~="warning"] {
|
||||
border: solid 2px #ff0000;
|
||||
background-color: #fff0f0;
|
||||
padding: 1em 6px 1em ;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
*[class~="warning"] th {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
||||
*[class~="warning"] table {
|
||||
background-color: #fff0f0;
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* Fin */
|
||||
/* The End */
|
||||
|
||||
518
bitbake/doc/manual/usermanual.xml
Normal file
518
bitbake/doc/manual/usermanual.xml
Normal file
@@ -0,0 +1,518 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
ex:ts=4:sw=4:sts=4:et
|
||||
-*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
-->
|
||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
||||
<book>
|
||||
<bookinfo>
|
||||
<title>BitBake User Manual</title>
|
||||
<authorgroup>
|
||||
<corpauthor>BitBake Team</corpauthor>
|
||||
</authorgroup>
|
||||
<copyright>
|
||||
<year>2004, 2005, 2006</year>
|
||||
<holder>Chris Larson</holder>
|
||||
<holder>Phil Blundell</holder>
|
||||
</copyright>
|
||||
<legalnotice>
|
||||
<para>This work is licensed under the Creative Commons Attribution License. To view a copy of this license, visit <ulink url="http://creativecommons.org/licenses/by/2.5/">http://creativecommons.org/licenses/by/2.5/</ulink> or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.</para>
|
||||
</legalnotice>
|
||||
</bookinfo>
|
||||
<chapter>
|
||||
<title>Introduction</title>
|
||||
<section>
|
||||
<title>Overview</title>
|
||||
<para>BitBake is, at its simplest, a tool for executing
|
||||
tasks and managing metadata. As such, its similarities to GNU make and other
|
||||
build tools are readily apparent. It was inspired by Portage, the package management system used by the Gentoo Linux distribution. BitBake is the basis of the <ulink url="http://www.openembedded.org/">OpenEmbedded</ulink> project, which is being used to build and maintain a number of embedded Linux distributions, including OpenZaurus and Familiar.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Background and Goals</title>
|
||||
<para>Prior to BitBake, no other build tool adequately met
|
||||
the needs of an aspiring embedded Linux distribution. All of the
|
||||
buildsystems used by traditional desktop Linux distributions lacked
|
||||
important functionality, and none of the ad-hoc
|
||||
<emphasis>buildroot</emphasis> systems, prevalent in the
|
||||
embedded space, were scalable or maintainable.</para>
|
||||
|
||||
<para>Some important goals for BitBake were:
|
||||
<itemizedlist>
|
||||
<listitem><para>Handle crosscompilation.</para></listitem>
|
||||
<listitem><para>Handle interpackage dependencies (build time on target architecture, build time on native architecture, and runtime).</para></listitem>
|
||||
<listitem><para>Support running any number of tasks within a given package, including, but not limited to, fetching upstream sources, unpacking them, patching them, configuring them, et cetera.</para></listitem>
|
||||
<listitem><para>Must be linux distribution agnostic (both build and target).</para></listitem>
|
||||
<listitem><para>Must be architecture agnostic</para></listitem>
|
||||
<listitem><para>Must support multiple build and target operating systems (including cygwin, the BSDs, etc).</para></listitem>
|
||||
<listitem><para>Must be able to be self contained, rather than tightly integrated into the build machine's root filesystem.</para></listitem>
|
||||
<listitem><para>There must be a way to handle conditional metadata (on target architecture, operating system, distribution, machine).</para></listitem>
|
||||
<listitem><para>It must be easy for the person using the tools to supply their own local metadata and packages to operate against.</para></listitem>
|
||||
<listitem><para>Must make it easy to collaborate
|
||||
between multiple projects using BitBake for their
|
||||
builds.</para></listitem>
|
||||
<listitem><para>Should provide an inheritance mechanism to
|
||||
share common metadata between many packages.</para></listitem>
|
||||
<listitem><para>Et cetera...</para></listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>BitBake satisfies all these and many more. Flexibility and power have always been the priorities. It is highly extensible, supporting embedded Python code and execution of any arbitrary tasks.</para>
|
||||
</section>
|
||||
</chapter>
|
||||
<chapter>
|
||||
<title>Metadata</title>
|
||||
<section>
|
||||
<title>Description</title>
|
||||
<itemizedlist>
|
||||
<para>BitBake metadata can be classified into 3 major areas:</para>
|
||||
<listitem>
|
||||
<para>Configuration Files</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>.bb Files</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Classes</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<para>What follows are a large number of examples of BitBake metadata. Any syntax which isn't supported in any of the aforementioned areas will be documented as such.</para>
|
||||
<section>
|
||||
<title>Basic variable setting</title>
|
||||
<para><screen><varname>VARIABLE</varname> = "value"</screen></para>
|
||||
<para>In this example, <varname>VARIABLE</varname> is <literal>value</literal>.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Variable expansion</title>
|
||||
<para>BitBake supports variables referencing one another's contents using a syntax which is similar to shell scripting</para>
|
||||
<para><screen><varname>A</varname> = "aval"
|
||||
<varname>B</varname> = "pre${A}post"</screen></para>
|
||||
<para>This results in <varname>A</varname> containing <literal>aval</literal> and <varname>B</varname> containing <literal>preavalpost</literal>.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Immediate variable expansion (:=)</title>
|
||||
<para>:= results in a variable's contents being expanded immediately, rather than when the variable is actually used.</para>
|
||||
<para><screen><varname>T</varname> = "123"
|
||||
<varname>A</varname> := "${B} ${A} test ${T}"
|
||||
<varname>T</varname> = "456"
|
||||
<varname>B</varname> = "${T} bval"
|
||||
|
||||
<varname>C</varname> = "cval"
|
||||
<varname>C</varname> := "${C}append"</screen></para>
|
||||
<para>In that example, <varname>A</varname> would contain <literal> test 123</literal>, <varname>B</varname> would contain <literal>456 bval</literal>, and <varname>C</varname> would be <literal>cvalappend</literal>.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Appending (+=) and prepending (=+)</title>
|
||||
<para><screen><varname>B</varname> = "bval"
|
||||
<varname>B</varname> += "additionaldata"
|
||||
<varname>C</varname> = "cval"
|
||||
<varname>C</varname> =+ "test"</screen></para>
|
||||
<para>In this example, <varname>B</varname> is now <literal>bval additionaldata</literal> and <varname>C</varname> is <literal>test cval</literal>.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Appending (.=) and prepending (=.) without spaces</title>
|
||||
<para><screen><varname>B</varname> = "bval"
|
||||
<varname>B</varname> .= "additionaldata"
|
||||
<varname>C</varname> = "cval"
|
||||
<varname>C</varname> =. "test"</screen></para>
|
||||
<para>In this example, <varname>B</varname> is now <literal>bvaladditionaldata</literal> and <varname>C</varname> is <literal>testcval</literal>. In contrast to the above Appending and Prepending operators no additional space
|
||||
will be introduced.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Conditional metadata set</title>
|
||||
<para>OVERRIDES is a <quote>:</quote> seperated variable containing each item you want to satisfy conditions. So, if you have a variable which is conditional on <quote>arm</quote>, and <quote>arm</quote> is in OVERRIDES, then the <quote>arm</quote> specific version of the variable is used rather than the non-conditional version. Example:</para>
|
||||
<para><screen><varname>OVERRIDES</varname> = "architecture:os:machine"
|
||||
<varname>TEST</varname> = "defaultvalue"
|
||||
<varname>TEST_os</varname> = "osspecificvalue"
|
||||
<varname>TEST_condnotinoverrides</varname> = "othercondvalue"</screen></para>
|
||||
<para>In this example, <varname>TEST</varname> would be <literal>osspecificvalue</literal>, due to the condition <quote>os</quote> being in <varname>OVERRIDES</varname>.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Conditional appending</title>
|
||||
<para>BitBake also supports appending and prepending to variables based on whether something is in OVERRIDES. Example:</para>
|
||||
<para><screen><varname>DEPENDS</varname> = "glibc ncurses"
|
||||
<varname>OVERRIDES</varname> = "machine:local"
|
||||
<varname>DEPENDS_append_machine</varname> = " libmad"</screen></para>
|
||||
<para>In this example, <varname>DEPENDS</varname> is set to <literal>glibc ncurses libmad</literal>.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Inclusion</title>
|
||||
<para>Next, there is the <literal>include</literal> directive, which causes BitBake to parse in whatever file you specify, and insert it at that location, which is not unlike <command>make</command>. However, if the path specified on the <literal>include</literal> line is a relative path, BitBake will locate the first one it can find within <envar>BBPATH</envar>.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Requiring Inclusion</title>
|
||||
<para>In contrast to the <literal>include</literal> directive, <literal>require</literal> will
|
||||
raise an ParseError if the to be included file can not be found. Otherwise it will behave just like the <literal>
|
||||
include</literal> directive.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Python variable expansion</title>
|
||||
<para><screen><varname>DATE</varname> = "${@time.strftime('%Y%m%d',time.gmtime())}"</screen></para>
|
||||
<para>This would result in the <varname>DATE</varname> variable containing today's date.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Defining executable metadata</title>
|
||||
<para><emphasis>NOTE:</emphasis> This is only supported in .bb and .bbclass files.</para>
|
||||
<para><screen>do_mytask () {
|
||||
echo "Hello, world!"
|
||||
}</screen></para>
|
||||
<para>This is essentially identical to setting a variable, except that this variable happens to be executable shell code.</para>
|
||||
<para><screen>python do_printdate () {
|
||||
import time
|
||||
print time.strftime('%Y%m%d', time.gmtime())
|
||||
}</screen></para>
|
||||
<para>This is the similar to the previous, but flags it as python so that BitBake knows it is python code.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Defining python functions into the global python namespace</title>
|
||||
<para><emphasis>NOTE:</emphasis> This is only supported in .bb and .bbclass files.</para>
|
||||
<para><screen>def get_depends(bb, d):
|
||||
if bb.data.getVar('SOMECONDITION', d, True):
|
||||
return "dependencywithcond"
|
||||
else:
|
||||
return "dependency"
|
||||
|
||||
<varname>SOMECONDITION</varname> = "1"
|
||||
<varname>DEPENDS</varname> = "${@get_depends(bb, d)}"</screen></para>
|
||||
<para>This would result in <varname>DEPENDS</varname> containing <literal>dependencywithcond</literal>.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Variable Flags</title>
|
||||
<para>Variables can have associated flags which provide a way of tagging extra information onto a variable. Several flags are used internally by bitbake but they can be used externally too if needed. The standard operations mentioned above also work on flags.</para>
|
||||
<para><screen><varname>VARIABLE</varname>[<varname>SOMEFLAG</varname>] = "value"</screen></para>
|
||||
<para>In this example, <varname>VARIABLE</varname> has a flag, <varname>SOMEFLAG</varname> which is set to <literal>value</literal>.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Inheritance</title>
|
||||
<para><emphasis>NOTE:</emphasis> This is only supported in .bb and .bbclass files.</para>
|
||||
<para>The <literal>inherit</literal> directive is a means of specifying what classes of functionality your .bb requires. It is a rudamentary form of inheritence. For example, you can easily abstract out the tasks involved in building a package that uses autoconf and automake, and put that into a bbclass for your packages to make use of. A given bbclass is located by searching for classes/filename.oeclass in <envar>BBPATH</envar>, where filename is what you inherited.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Tasks</title>
|
||||
<para><emphasis>NOTE:</emphasis> This is only supported in .bb and .bbclass files.</para>
|
||||
<para>In BitBake, each step that needs to be run for a given .bb is known as a task. There is a command <literal>addtask</literal> to add new tasks (must be a defined python executable metadata and must start with <quote>do_</quote>) and describe intertask dependencies.</para>
|
||||
<para><screen>python do_printdate () {
|
||||
import time
|
||||
print time.strftime('%Y%m%d', time.gmtime())
|
||||
}
|
||||
|
||||
addtask printdate before do_build</screen></para>
|
||||
<para>This defines the necessary python function and adds it as a task which is now a dependency of do_build (the default task). If anyone executes the do_build task, that will result in do_printdate being run first.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Events</title>
|
||||
<para><emphasis>NOTE:</emphasis> This is only supported in .bb and .bbclass files.</para>
|
||||
<para>BitBake allows to install event handlers. Events are triggered at certain points during operation, such as, the beginning of operation against a given .bb, the start of a given task, task failure, task success, et cetera. The intent was to make it easy to do things like email notifications on build failure.</para>
|
||||
<para><screen>addhandler myclass_eventhandler
|
||||
python myclass_eventhandler() {
|
||||
from bb.event import NotHandled, getName
|
||||
from bb import data
|
||||
|
||||
print "The name of the Event is %s" % getName(e)
|
||||
print "The file we run for is %s" % data.getVar('FILE', e.data, True)
|
||||
|
||||
return NotHandled
|
||||
}
|
||||
</screen></para><para>
|
||||
This event handler gets called every time an event is triggered. A global variable <varname>e</varname> is defined. <varname>e</varname>.data contains an instance of bb.data. With the getName(<varname>e</varname>)
|
||||
method one can get the name of the triggered event.</para><para>The above event handler prints the name
|
||||
of the event and the content of the <varname>FILE</varname> variable.</para>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<title>Dependency Handling</title>
|
||||
<para>Bitbake 1.7.x onwards works with the metadata at the task level since this is optimal when dealing with multiple threads of execution. A robust method of specifing task dependencies is therefore needed. </para>
|
||||
<section>
|
||||
<title>Dependencies internal to the .bb file</title>
|
||||
<para>Where the dependencies are internal to a given .bb file, the dependencies are handled by the previously detailed addtask directive.</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>DEPENDS</title>
|
||||
<para>DEPENDS is taken to specify build time dependencies. The 'deptask' flag for tasks is used to signify the task of each DEPENDS which must have completed before that task can be executed.</para>
|
||||
<para><screen>do_configure[deptask] = "do_populate_staging"</screen></para>
|
||||
<para>means the do_populate_staging task of each item in DEPENDS must have completed before do_configure can execute.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>RDEPENDS</title>
|
||||
<para>RDEPENDS is taken to specify runtime dependencies. The 'rdeptask' flag for tasks is used to signify the task of each RDEPENDS which must have completed before that task can be executed.</para>
|
||||
<para><screen>do_package_write[rdeptask] = "do_package"</screen></para>
|
||||
<para>means the do_package task of each item in RDEPENDS must have completed before do_package_write can execute.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Recursive DEPENDS</title>
|
||||
<para>These are specified with the 'recdeptask' flag and is used signify the task(s) of each DEPENDS which must have completed before that task can be executed. It applies recursively so also, the DEPENDS of each item in the original DEPENDS must be met and so on.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Recursive RDEPENDS</title>
|
||||
<para>These are specified with the 'recrdeptask' flag and is used signify the task(s) of each RDEPENDS which must have completed before that task can be executed. It applies recursively so also, the RDEPENDS of each item in the original RDEPENDS must be met and so on. It also runs all DEPENDS first too.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Inter Task</title>
|
||||
<para>The 'depends' flag for tasks is a more generic form of which allows an interdependency on specific tasks rather than specifying the data in DEPENDS or RDEPENDS.</para>
|
||||
<para><screen>do_patch[depends] = "quilt-native:do_populate_staging"</screen></para>
|
||||
<para>means the do_populate_staging task of the target quilt-native must have completed before the do_patch can execute.</para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Parsing</title>
|
||||
<section>
|
||||
<title>Configuration Files</title>
|
||||
<para>The first of the classifications of metadata in BitBake is configuration metadata. This metadata is global, and therefore affects <emphasis>all</emphasis> packages and tasks which are executed. Currently, BitBake has hardcoded knowledge of a single configuration file. It expects to find 'conf/bitbake.conf' somewhere in the user specified <envar>BBPATH</envar>. That configuration file generally has include directives to pull in any other metadata (generally files specific to architecture, machine, <emphasis>local</emphasis> and so on.</para>
|
||||
<para>Only variable definitions and include directives are allowed in .conf files.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Classes</title>
|
||||
<para>BitBake classes are our rudamentary inheritence mechanism. As briefly mentioned in the metadata introduction, they're parsed when an <literal>inherit</literal> directive is encountered, and they are located in classes/ relative to the dirs in <envar>BBPATH</envar>.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>.bb Files</title>
|
||||
<para>A BitBake (.bb) file is a logical unit of tasks to be executed. Normally this is a package to be built. Inter-.bb dependencies are obeyed. The files themselves are located via the <varname>BBFILES</varname> variable, which is set to a space seperated list of .bb files, and does handle wildcards.</para>
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
|
||||
<chapter>
|
||||
<title>File Download support</title>
|
||||
<section>
|
||||
<title>Overview</title>
|
||||
<para>BitBake provides support to download files this procedure is called fetching. The SRC_URI is normally used to indicate BitBake which files to fetch. The next sections will describe th available fetchers and the options they have. Each Fetcher honors a set of Variables and
|
||||
a per URI parameters separated by a <quote>;</quote> consisting of a key and a value. The semantic of the Variables and Parameters are defined by the Fetcher. BitBakes tries to have a consistent semantic between the different Fetchers.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Local File Fetcher</title>
|
||||
<para>The URN for the Local File Fetcher is <emphasis>file</emphasis>. The filename can be either absolute or relative. If the filename is relative <varname>FILESPATH</varname> and <varname>FILESDIR</varname> will be used to find the appropriate relative file depending on the <varname>OVERRIDES</varname>. Single files and complete directories can be specified.
|
||||
<screen><varname>SRC_URI</varname>= "file://relativefile.patch"
|
||||
<varname>SRC_URI</varname>= "file://relativefile.patch;this=ignored"
|
||||
<varname>SRC_URI</varname>= "file:///Users/ich/very_important_software"
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>CVS File Fetcher</title>
|
||||
<para>The URN for the CVS Fetcher is <emphasis>cvs</emphasis>. This Fetcher honors the variables <varname>DL_DIR</varname>, <varname>SRCDATE</varname>, <varname>FETCHCOMMAND_cvs</varname>, <varname>UPDATECOMMAND_cvs</varname>. <varname>DL_DIRS</varname> specifies where a temporary checkout is saved, <varname>SRCDATE</varname> specifies which date to use when doing the fetching (the special value of "now" will cause the checkout to be updated on every build), <varname>FETCHCOMMAND</varname> and <varname>UPDATECOMMAND</varname> specify which executables should be used when doing the CVS checkout or update.
|
||||
</para>
|
||||
<para>The supported Parameters are <varname>module</varname>, <varname>tag</varname>, <varname>date</varname>, <varname>method</varname>, <varname>localdir</varname>, <varname>rsh</varname>. The <varname>module</varname> specifies which module to check out, the <varname>tag</varname> describes which CVS TAG should be used for the checkout by default the TAG is empty. A <varname>date</varname> can be specified to override the SRCDATE of the configuration to checkout a specific date. The special value of "now" will cause the checkout to be updated on every build.<varname>method</varname> is by default <emphasis>pserver</emphasis>, if <emphasis>ext</emphasis> is used the <varname>rsh</varname> parameter will be evaluated and <varname>CVS_RSH</varname> will be set. Finally <varname>localdir</varname> is used to checkout into a special directory relative to <varname>CVSDIR></varname>.
|
||||
<screen><varname>SRC_URI</varname> = "cvs://CVSROOT;module=mymodule;tag=some-version;method=ext"
|
||||
<varname>SRC_URI</varname> = "cvs://CVSROOT;module=mymodule;date=20060126;localdir=usethat"
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>HTTP/FTP Fetcher</title>
|
||||
<para>The URNs for the HTTP/FTP are <emphasis>http</emphasis>, <emphasis>https</emphasis> and <emphasis>ftp</emphasis>. This Fetcher honors the variables <varname>DL_DIR</varname>, <varname>FETCHCOMMAND_wget</varname>, <varname>PREMIRRORS</varname>, <varname>MIRRORS</varname>. The <varname>DL_DIR</varname> defines where to store the fetched file, <varname>FETCHCOMMAND</varname> contains the command used for fetching. <quote>${URI}</quote> and <quote>${FILES}</quote> will be replaced by the uri and basename of the to be fetched file. <varname>PREMIRRORS</varname>
|
||||
will be tried first when fetching a file if that fails the actual file will be tried and finally all <varname>MIRRORS</varname> will be tried.
|
||||
</para>
|
||||
<para>The only supported Parameter is <varname>md5sum</varname>. After a fetch the <varname>md5sum</varname> of the file will be calculated and the two sums will be compared.
|
||||
</para>
|
||||
<para><screen><varname>SRC_URI</varname> = "http://oe.handhelds.org/not_there.aac;md5sum=12343"
|
||||
<varname>SRC_URI</varname> = "ftp://oe.handhelds.org/not_there_as_well.aac;md5sum=1234"
|
||||
<varname>SRC_URI</varname> = "ftp://you@oe.handheld.sorg/home/you/secret.plan;md5sum=1234"
|
||||
</screen></para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>SVK Fetcher</title>
|
||||
<para>
|
||||
<emphasis>Currently NOT supported</emphasis>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>SVN Fetcher</title>
|
||||
<para>The URN for the SVN Fetcher is <emphasis>svn</emphasis>.
|
||||
</para>
|
||||
<para>This Fetcher honors the variables <varname>FETCHCOMMAND_svn</varname>, <varname>DL_DIR</varname>, <varname>SRCDATE</varname>. <varname>FETCHCOMMAND</varname> contains the subversion command, <varname>DL_DIR</varname> is the directory where tarballs will be saved, <varname>SRCDATE</varname> specifies which date to use when doing the fetching (the special value of "now" will cause the checkout to be updated on every build).
|
||||
</para>
|
||||
<para>The supported Parameters are <varname>proto</varname>, <varname>rev</varname>. <varname>proto</varname> is the subversion prototype, <varname>rev</varname> is the subversions revision.
|
||||
</para>
|
||||
<para><screen><varname>SRC_URI</varname> = "svn://svn.oe.handhelds.org/svn;module=vip;proto=http;rev=667"
|
||||
<varname>SRC_URI</varname> = "svn://svn.oe.handhelds.org/svn/;module=opie;proto=svn+ssh;date=20060126"
|
||||
</screen></para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>GIT Fetcher</title>
|
||||
<para>The URN for the GIT Fetcher is <emphasis>git</emphasis>.
|
||||
</para>
|
||||
<para>The Variables <varname>DL_DIR</varname>, <varname>GITDIR</varname> are used. <varname>DL_DIR</varname> will be used to store the checkedout version. <varname>GITDIR</varname> will be used as the base directory where the git tree is cloned to.
|
||||
</para>
|
||||
<para>The Parameters are <emphasis>tag</emphasis>, <emphasis>protocol</emphasis>. <emphasis>tag</emphasis> is a git tag, the default is <quote>master</quote>. <emphasis>protocol</emphasis> is the git protocol to use and defaults to <quote>rsync</quote>.
|
||||
</para>
|
||||
<para><screen><varname>SRC_URI</varname> = "git://git.oe.handhelds.org/git/vip.git;tag=version-1"
|
||||
<varname>SRC_URI</varname> = "git://git.oe.handhelds.org/git/vip.git;protocol=http"
|
||||
</screen></para>
|
||||
</section>
|
||||
|
||||
</chapter>
|
||||
|
||||
|
||||
<chapter>
|
||||
<title>Commands</title>
|
||||
<section>
|
||||
<title>bbread</title>
|
||||
<para>bbread is a command for displaying BitBake metadata. When run with no arguments, it has the core parse 'conf/bitbake.conf', as located in BBPATH, and displays that. If you supply a file on the commandline, such as a .bb, then it parses that afterwards, using the aforementioned configuration metadata.</para>
|
||||
<para><emphasis>NOTE: the stand a lone bbread command was removed. Instead of bbread use bitbake -e.
|
||||
</emphasis></para>
|
||||
</section>
|
||||
<section>
|
||||
<title>bitbake</title>
|
||||
<section>
|
||||
<title>Introduction</title>
|
||||
<para>bitbake is the primary command in the system. It facilitates executing tasks in a single .bb file, or executing a given task on a set of multiple .bb files, accounting for interdependencies amongst them.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Usage and Syntax</title>
|
||||
<para>
|
||||
<screen><prompt>$ </prompt>bitbake --help
|
||||
usage: bitbake [options] [package ...]
|
||||
|
||||
Executes the specified task (default is 'build') for a given set of BitBake files.
|
||||
It expects that BBFILES is defined, which is a space seperated list of files to
|
||||
be executed. BBFILES does support wildcards.
|
||||
Default BBFILES are the .bb files in the current directory.
|
||||
|
||||
options:
|
||||
--version show program's version number and exit
|
||||
-h, --help show this help message and exit
|
||||
-b BUILDFILE, --buildfile=BUILDFILE
|
||||
execute the task against this .bb file, rather than a
|
||||
package from BBFILES.
|
||||
-k, --continue continue as much as possible after an error. While the
|
||||
target that failed, and those that depend on it,
|
||||
cannot be remade, the other dependencies of these
|
||||
targets can be processed all the same.
|
||||
-f, --force force run of specified cmd, regardless of stamp status
|
||||
-i, --interactive drop into the interactive mode also called the BitBake
|
||||
shell.
|
||||
-c CMD, --cmd=CMD Specify task to execute. Note that this only executes
|
||||
the specified task for the providee and the packages
|
||||
it depends on, i.e. 'compile' does not implicitly call
|
||||
stage for the dependencies (IOW: use only if you know
|
||||
what you are doing). Depending on the base.bbclass a
|
||||
listtasks tasks is defined and will show available
|
||||
tasks
|
||||
-r FILE, --read=FILE read the specified file before bitbake.conf
|
||||
-v, --verbose output more chit-chat to the terminal
|
||||
-D, --debug Increase the debug level. You can specify this more
|
||||
than once.
|
||||
-n, --dry-run don't execute, just go through the motions
|
||||
-p, --parse-only quit after parsing the BB files (developers only)
|
||||
-d, --disable-psyco disable using the psyco just-in-time compiler (not
|
||||
recommended)
|
||||
-s, --show-versions show current and preferred versions of all packages
|
||||
-e, --environment show the global or per-package environment (this is
|
||||
what used to be bbread)
|
||||
-g, --graphviz emit the dependency trees of the specified packages in
|
||||
the dot syntax
|
||||
-I IGNORED_DOT_DEPS, --ignore-deps=IGNORED_DOT_DEPS
|
||||
Stop processing at the given list of dependencies when
|
||||
generating dependency graphs. This can help to make
|
||||
the graph more appealing
|
||||
-l DEBUG_DOMAINS, --log-domains=DEBUG_DOMAINS
|
||||
Show debug logging for the specified logging domains
|
||||
|
||||
</screen>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Executing a task against a single .bb</title>
|
||||
<para>Executing tasks for a single file is relatively simple. You specify the file in question, and bitbake parses it and executes the specified task (or <quote>build</quote> by default). It obeys intertask dependencies when doing so.</para>
|
||||
<para><quote>clean</quote> task:</para>
|
||||
<para><screen><prompt>$ </prompt>bitbake -b blah_1.0.bb -c clean</screen></para>
|
||||
<para><quote>build</quote> task:</para>
|
||||
<para><screen><prompt>$ </prompt>bitbake -b blah_1.0.bb</screen></para>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Executing tasks against a set of .bb files</title>
|
||||
<para>There are a number of additional complexities introduced when one wants to manage multiple .bb files. Clearly there needs to be a way to tell bitbake what files are available, and of those, which we want to execute at this time. There also needs to be a way for each .bb to express its dependencies, both for build time and runtime. There must be a way for the user to express their preferences when multiple .bb's provide the same functionality, or when there are multiple versions of a .bb.</para>
|
||||
<para>The next section, Metadata, outlines how one goes about specifying such things.</para>
|
||||
<para>Note that the bitbake command, when not using --buildfile, accepts a <varname>PROVIDER</varname>, not a filename or anything else. By default, a .bb generally PROVIDES its packagename, packagename-version, and packagename-version-revision.</para>
|
||||
<screen><prompt>$ </prompt>bitbake blah</screen>
|
||||
<screen><prompt>$ </prompt>bitbake blah-1.0</screen>
|
||||
<screen><prompt>$ </prompt>bitbake blah-1.0-r0</screen>
|
||||
<screen><prompt>$ </prompt>bitbake -c clean blah</screen>
|
||||
<screen><prompt>$ </prompt>bitbake virtual/whatever</screen>
|
||||
<screen><prompt>$ </prompt>bitbake -c clean virtual/whatever</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title>Generating dependency graphs</title>
|
||||
<para>BitBake is able to generate dependency graphs using the dot syntax. These graphs can be converted
|
||||
to images using the <application>dot</application> application from <ulink url="http://www.graphviz.org">graphviz</ulink>.
|
||||
Two files will be written into the current working directory, <emphasis>depends.dot</emphasis> containing dependency information at the package level and <emphasis>task-depends.dot</emphasis> containing a breakdown of the dependencies at the task level. To stop depending on common depends one can use the <prompt>-I depend</prompt> to omit these from the graph. This can lead to more readable graphs. E.g. this way <varname>DEPENDS</varname> from inherited classes, e.g. base.bbclass, can be removed from the graph.</para>
|
||||
<screen><prompt>$ </prompt>bitbake -g blah</screen>
|
||||
<screen><prompt>$ </prompt>bitbake -g -I virtual/whatever -I bloom blah</screen>
|
||||
</example>
|
||||
</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Special variables</title>
|
||||
<para>Certain variables affect bitbake operation:</para>
|
||||
<section>
|
||||
<title><varname>BB_NUMBER_THREADS</varname></title>
|
||||
<para> The number of threads bitbake should run at once (default: 1).</para>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<title>Metadata</title>
|
||||
<para>As you may have seen in the usage information, or in the information about .bb files, the BBFILES variable is how the bitbake tool locates its files. This variable is a space seperated list of files that are available, and supports wildcards.
|
||||
<example>
|
||||
<title>Setting BBFILES</title>
|
||||
<programlisting><varname>BBFILES</varname> = "/path/to/bbfiles/*.bb"</programlisting>
|
||||
</example></para>
|
||||
<para>With regard to dependencies, it expects the .bb to define a <varname>DEPENDS</varname> variable, which contains a space seperated list of <quote>package names</quote>, which themselves are the <varname>PN</varname> variable. The <varname>PN</varname> variable is, in general, by default, set to a component of the .bb filename.</para>
|
||||
<example>
|
||||
<title>Depending on another .bb</title>
|
||||
<para>a.bb:
|
||||
<screen>PN = "package-a"
|
||||
DEPENDS += "package-b"</screen>
|
||||
</para>
|
||||
<para>b.bb:
|
||||
<screen>PN = "package-b"</screen>
|
||||
</para>
|
||||
</example>
|
||||
<example>
|
||||
<title>Using PROVIDES</title>
|
||||
<para>This example shows the usage of the PROVIDES variable, which allows a given .bb to specify what functionality it provides.</para>
|
||||
<para>package1.bb:
|
||||
<screen>PROVIDES += "virtual/package"</screen>
|
||||
</para>
|
||||
<para>package2.bb:
|
||||
<screen>DEPENDS += "virtual/package"</screen>
|
||||
</para>
|
||||
<para>package3.bb:
|
||||
<screen>PROVIDES += "virtual/package"</screen>
|
||||
</para>
|
||||
<para>As you can see, here there are two different .bb's that provide the same functionality (virtual/package). Clearly, there needs to be a way for the person running bitbake to control which of those providers gets used. There is, indeed, such a way.</para>
|
||||
<para>The following would go into a .conf file, to select package1:
|
||||
<screen>PREFERRED_PROVIDER_virtual/package = "package1"</screen>
|
||||
</para>
|
||||
</example>
|
||||
<example>
|
||||
<title>Specifying version preference</title>
|
||||
<para>When there are multiple <quote>versions</quote> of a given package, bitbake defaults to selecting the most recent version, unless otherwise specified. If the .bb in question has a <varname>DEFAULT_PREFERENCE</varname> set lower than the other .bb's (default is 0), then it will not be selected. This allows the person or persons maintaining the repository of .bb files to specify their preferences for the default selected version. In addition, the user can specify their preferences with regard to version.</para>
|
||||
<para>If the first .bb is named <filename>a_1.1.bb</filename>, then the <varname>PN</varname> variable will be set to <quote>a</quote>, and the <varname>PV</varname> variable will be set to 1.1.</para>
|
||||
<para>If we then have an <filename>a_1.2.bb</filename>, bitbake will choose 1.2 by default. However, if we define the following variable in a .conf that bitbake parses, we can change that.
|
||||
<screen>PREFERRED_VERSION_a = "1.1"</screen>
|
||||
</para>
|
||||
</example>
|
||||
<example>
|
||||
<title>Using <quote>bbfile collections</quote></title>
|
||||
<para>bbfile collections exist to allow the user to have multiple repositories of bbfiles that contain the same exact package. For example, one could easily use them to make one's own local copy of an upstream repository, but with custom modifications that one does not want upstream. Usage:</para>
|
||||
<screen>BBFILES = "/stuff/openembedded/*/*.bb /stuff/openembedded.modified/*/*.bb"
|
||||
BBFILE_COLLECTIONS = "upstream local"
|
||||
BBFILE_PATTERN_upstream = "^/stuff/openembedded/"
|
||||
BBFILE_PATTERN_local = "^/stuff/openembedded.modified/"
|
||||
BBFILE_PRIORITY_upstream = "5"
|
||||
BBFILE_PRIORITY_local = "10"</screen>
|
||||
</example>
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
</book>
|
||||
320
bitbake/lib/bb/COW.py
Normal file
320
bitbake/lib/bb/COW.py
Normal file
@@ -0,0 +1,320 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# This is a copy on write dictionary and set which abuses classes to try and be nice and fast.
|
||||
#
|
||||
# Copyright (C) 2006 Tim Amsell
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
#Please Note:
|
||||
# Be careful when using mutable types (ie Dict and Lists) - operations involving these are SLOW.
|
||||
# Assign a file to __warn__ to get warnings about slow operations.
|
||||
#
|
||||
|
||||
from inspect import getmro
|
||||
|
||||
import copy
|
||||
import types, sets
|
||||
types.ImmutableTypes = tuple([ \
|
||||
types.BooleanType, \
|
||||
types.ComplexType, \
|
||||
types.FloatType, \
|
||||
types.IntType, \
|
||||
types.LongType, \
|
||||
types.NoneType, \
|
||||
types.TupleType, \
|
||||
sets.ImmutableSet] + \
|
||||
list(types.StringTypes))
|
||||
|
||||
MUTABLE = "__mutable__"
|
||||
|
||||
class COWMeta(type):
|
||||
pass
|
||||
|
||||
class COWDictMeta(COWMeta):
|
||||
__warn__ = False
|
||||
__hasmutable__ = False
|
||||
__marker__ = tuple()
|
||||
|
||||
def __str__(cls):
|
||||
# FIXME: I have magic numbers!
|
||||
return "<COWDict Level: %i Current Keys: %i>" % (cls.__count__, len(cls.__dict__) - 3)
|
||||
__repr__ = __str__
|
||||
|
||||
def cow(cls):
|
||||
class C(cls):
|
||||
__count__ = cls.__count__ + 1
|
||||
return C
|
||||
copy = cow
|
||||
__call__ = cow
|
||||
|
||||
def __setitem__(cls, key, value):
|
||||
if not isinstance(value, types.ImmutableTypes):
|
||||
if not isinstance(value, COWMeta):
|
||||
cls.__hasmutable__ = True
|
||||
key += MUTABLE
|
||||
setattr(cls, key, value)
|
||||
|
||||
def __getmutable__(cls, key, readonly=False):
|
||||
nkey = key + MUTABLE
|
||||
try:
|
||||
return cls.__dict__[nkey]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
value = getattr(cls, nkey)
|
||||
if readonly:
|
||||
return value
|
||||
|
||||
if not cls.__warn__ is False and not isinstance(value, COWMeta):
|
||||
print >> cls.__warn__, "Warning: Doing a copy because %s is a mutable type." % key
|
||||
try:
|
||||
value = value.copy()
|
||||
except AttributeError, e:
|
||||
value = copy.copy(value)
|
||||
setattr(cls, nkey, value)
|
||||
return value
|
||||
|
||||
__getmarker__ = []
|
||||
def __getreadonly__(cls, key, default=__getmarker__):
|
||||
"""\
|
||||
Get a value (even if mutable) which you promise not to change.
|
||||
"""
|
||||
return cls.__getitem__(key, default, True)
|
||||
|
||||
def __getitem__(cls, key, default=__getmarker__, readonly=False):
|
||||
try:
|
||||
try:
|
||||
value = getattr(cls, key)
|
||||
except AttributeError:
|
||||
value = cls.__getmutable__(key, readonly)
|
||||
|
||||
# This is for values which have been deleted
|
||||
if value is cls.__marker__:
|
||||
raise AttributeError("key %s does not exist." % key)
|
||||
|
||||
return value
|
||||
except AttributeError, e:
|
||||
if not default is cls.__getmarker__:
|
||||
return default
|
||||
|
||||
raise KeyError(str(e))
|
||||
|
||||
def __delitem__(cls, key):
|
||||
cls.__setitem__(key, cls.__marker__)
|
||||
|
||||
def __revertitem__(cls, key):
|
||||
if not cls.__dict__.has_key(key):
|
||||
key += MUTABLE
|
||||
delattr(cls, key)
|
||||
|
||||
def has_key(cls, key):
|
||||
value = cls.__getreadonly__(key, cls.__marker__)
|
||||
if value is cls.__marker__:
|
||||
return False
|
||||
return True
|
||||
|
||||
def iter(cls, type, readonly=False):
|
||||
for key in dir(cls):
|
||||
if key.startswith("__"):
|
||||
continue
|
||||
|
||||
if key.endswith(MUTABLE):
|
||||
key = key[:-len(MUTABLE)]
|
||||
|
||||
if type == "keys":
|
||||
yield key
|
||||
|
||||
try:
|
||||
if readonly:
|
||||
value = cls.__getreadonly__(key)
|
||||
else:
|
||||
value = cls[key]
|
||||
except KeyError:
|
||||
continue
|
||||
|
||||
if type == "values":
|
||||
yield value
|
||||
if type == "items":
|
||||
yield (key, value)
|
||||
raise StopIteration()
|
||||
|
||||
def iterkeys(cls):
|
||||
return cls.iter("keys")
|
||||
def itervalues(cls, readonly=False):
|
||||
if not cls.__warn__ is False and cls.__hasmutable__ and readonly is False:
|
||||
print >> cls.__warn__, "Warning: If you arn't going to change any of the values call with True."
|
||||
return cls.iter("values", readonly)
|
||||
def iteritems(cls, readonly=False):
|
||||
if not cls.__warn__ is False and cls.__hasmutable__ and readonly is False:
|
||||
print >> cls.__warn__, "Warning: If you arn't going to change any of the values call with True."
|
||||
return cls.iter("items", readonly)
|
||||
|
||||
class COWSetMeta(COWDictMeta):
|
||||
def __str__(cls):
|
||||
# FIXME: I have magic numbers!
|
||||
return "<COWSet Level: %i Current Keys: %i>" % (cls.__count__, len(cls.__dict__) -3)
|
||||
__repr__ = __str__
|
||||
|
||||
def cow(cls):
|
||||
class C(cls):
|
||||
__count__ = cls.__count__ + 1
|
||||
return C
|
||||
|
||||
def add(cls, value):
|
||||
COWDictMeta.__setitem__(cls, repr(hash(value)), value)
|
||||
|
||||
def remove(cls, value):
|
||||
COWDictMeta.__delitem__(cls, repr(hash(value)))
|
||||
|
||||
def __in__(cls, value):
|
||||
return COWDictMeta.has_key(repr(hash(value)))
|
||||
|
||||
def iterkeys(cls):
|
||||
raise TypeError("sets don't have keys")
|
||||
|
||||
def iteritems(cls):
|
||||
raise TypeError("sets don't have 'items'")
|
||||
|
||||
# These are the actual classes you use!
|
||||
class COWDictBase(object):
|
||||
__metaclass__ = COWDictMeta
|
||||
__count__ = 0
|
||||
|
||||
class COWSetBase(object):
|
||||
__metaclass__ = COWSetMeta
|
||||
__count__ = 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
COWDictBase.__warn__ = sys.stderr
|
||||
a = COWDictBase()
|
||||
print "a", a
|
||||
|
||||
a['a'] = 'a'
|
||||
a['b'] = 'b'
|
||||
a['dict'] = {}
|
||||
|
||||
b = a.copy()
|
||||
print "b", b
|
||||
b['c'] = 'b'
|
||||
|
||||
print
|
||||
|
||||
print "a", a
|
||||
for x in a.iteritems():
|
||||
print x
|
||||
print "--"
|
||||
print "b", b
|
||||
for x in b.iteritems():
|
||||
print x
|
||||
print
|
||||
|
||||
b['dict']['a'] = 'b'
|
||||
b['a'] = 'c'
|
||||
|
||||
print "a", a
|
||||
for x in a.iteritems():
|
||||
print x
|
||||
print "--"
|
||||
print "b", b
|
||||
for x in b.iteritems():
|
||||
print x
|
||||
print
|
||||
|
||||
try:
|
||||
b['dict2']
|
||||
except KeyError, e:
|
||||
print "Okay!"
|
||||
|
||||
a['set'] = COWSetBase()
|
||||
a['set'].add("o1")
|
||||
a['set'].add("o1")
|
||||
a['set'].add("o2")
|
||||
|
||||
print "a", a
|
||||
for x in a['set'].itervalues():
|
||||
print x
|
||||
print "--"
|
||||
print "b", b
|
||||
for x in b['set'].itervalues():
|
||||
print x
|
||||
print
|
||||
|
||||
b['set'].add('o3')
|
||||
|
||||
print "a", a
|
||||
for x in a['set'].itervalues():
|
||||
print x
|
||||
print "--"
|
||||
print "b", b
|
||||
for x in b['set'].itervalues():
|
||||
print x
|
||||
print
|
||||
|
||||
a['set2'] = set()
|
||||
a['set2'].add("o1")
|
||||
a['set2'].add("o1")
|
||||
a['set2'].add("o2")
|
||||
|
||||
print "a", a
|
||||
for x in a.iteritems():
|
||||
print x
|
||||
print "--"
|
||||
print "b", b
|
||||
for x in b.iteritems(readonly=True):
|
||||
print x
|
||||
print
|
||||
|
||||
del b['b']
|
||||
try:
|
||||
print b['b']
|
||||
except KeyError:
|
||||
print "Yay! deleted key raises error"
|
||||
|
||||
if b.has_key('b'):
|
||||
print "Boo!"
|
||||
else:
|
||||
print "Yay - has_key with delete works!"
|
||||
|
||||
print "a", a
|
||||
for x in a.iteritems():
|
||||
print x
|
||||
print "--"
|
||||
print "b", b
|
||||
for x in b.iteritems(readonly=True):
|
||||
print x
|
||||
print
|
||||
|
||||
b.__revertitem__('b')
|
||||
|
||||
print "a", a
|
||||
for x in a.iteritems():
|
||||
print x
|
||||
print "--"
|
||||
print "b", b
|
||||
for x in b.iteritems(readonly=True):
|
||||
print x
|
||||
print
|
||||
|
||||
b.__revertitem__('dict')
|
||||
print "a", a
|
||||
for x in a.iteritems():
|
||||
print x
|
||||
print "--"
|
||||
print "b", b
|
||||
for x in b.iteritems(readonly=True):
|
||||
print x
|
||||
print
|
||||
1229
bitbake/lib/bb/__init__.py
Normal file
1229
bitbake/lib/bb/__init__.py
Normal file
File diff suppressed because it is too large
Load Diff
454
bitbake/lib/bb/build.py
Normal file
454
bitbake/lib/bb/build.py
Normal file
@@ -0,0 +1,454 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# BitBake 'Build' implementation
|
||||
#
|
||||
# Core code for function execution and task handling in the
|
||||
# BitBake build tools.
|
||||
#
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
#
|
||||
# Based on Gentoo's portage.py.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
#Based on functions from the base bb module, Copyright 2003 Holger Schurig
|
||||
|
||||
from bb import data, fetch, event, mkdirhier, utils
|
||||
import bb, os
|
||||
|
||||
# events
|
||||
class FuncFailed(Exception):
|
||||
"""Executed function failed"""
|
||||
|
||||
class EventException(Exception):
|
||||
"""Exception which is associated with an Event."""
|
||||
|
||||
def __init__(self, msg, event):
|
||||
self.args = msg, event
|
||||
|
||||
class TaskBase(event.Event):
|
||||
"""Base class for task events"""
|
||||
|
||||
def __init__(self, t, d ):
|
||||
self._task = t
|
||||
event.Event.__init__(self, d)
|
||||
|
||||
def getTask(self):
|
||||
return self._task
|
||||
|
||||
def setTask(self, task):
|
||||
self._task = task
|
||||
|
||||
task = property(getTask, setTask, None, "task property")
|
||||
|
||||
class TaskStarted(TaskBase):
|
||||
"""Task execution started"""
|
||||
|
||||
class TaskSucceeded(TaskBase):
|
||||
"""Task execution completed"""
|
||||
|
||||
class TaskFailed(TaskBase):
|
||||
"""Task execution failed"""
|
||||
|
||||
class InvalidTask(TaskBase):
|
||||
"""Invalid Task"""
|
||||
|
||||
# functions
|
||||
|
||||
def exec_func(func, d, dirs = None):
|
||||
"""Execute an BB 'function'"""
|
||||
|
||||
body = data.getVar(func, d)
|
||||
if not body:
|
||||
return
|
||||
|
||||
if not dirs:
|
||||
dirs = (data.getVarFlag(func, 'dirs', d) or "").split()
|
||||
for adir in dirs:
|
||||
adir = data.expand(adir, d)
|
||||
mkdirhier(adir)
|
||||
|
||||
if len(dirs) > 0:
|
||||
adir = dirs[-1]
|
||||
else:
|
||||
adir = data.getVar('B', d, 1)
|
||||
|
||||
adir = data.expand(adir, d)
|
||||
|
||||
try:
|
||||
prevdir = os.getcwd()
|
||||
except OSError:
|
||||
prevdir = data.expand('${TOPDIR}', d)
|
||||
if adir and os.access(adir, os.F_OK):
|
||||
os.chdir(adir)
|
||||
|
||||
if data.getVarFlag(func, "python", d):
|
||||
exec_func_python(func, d)
|
||||
else:
|
||||
exec_func_shell(func, d)
|
||||
|
||||
if os.path.exists(prevdir):
|
||||
os.chdir(prevdir)
|
||||
|
||||
def exec_func_python(func, d):
|
||||
"""Execute a python BB 'function'"""
|
||||
import re, os
|
||||
|
||||
tmp = "def " + func + "():\n%s" % data.getVar(func, d)
|
||||
tmp += '\n' + func + '()'
|
||||
comp = utils.better_compile(tmp, func, bb.data.getVar('FILE', d, 1) )
|
||||
prevdir = os.getcwd()
|
||||
g = {} # globals
|
||||
g['bb'] = bb
|
||||
g['os'] = os
|
||||
g['d'] = d
|
||||
utils.better_exec(comp,g,tmp, bb.data.getVar('FILE',d,1))
|
||||
if os.path.exists(prevdir):
|
||||
os.chdir(prevdir)
|
||||
|
||||
def exec_func_shell(func, d):
|
||||
"""Execute a shell BB 'function' Returns true if execution was successful.
|
||||
|
||||
For this, it creates a bash shell script in the tmp dectory, writes the local
|
||||
data into it and finally executes. The output of the shell will end in a log file and stdout.
|
||||
|
||||
Note on directory behavior. The 'dirs' varflag should contain a list
|
||||
of the directories you need created prior to execution. The last
|
||||
item in the list is where we will chdir/cd to.
|
||||
"""
|
||||
import sys
|
||||
|
||||
deps = data.getVarFlag(func, 'deps', d)
|
||||
check = data.getVarFlag(func, 'check', d)
|
||||
interact = data.getVarFlag(func, 'interactive', d)
|
||||
if check in globals():
|
||||
if globals()[check](func, deps):
|
||||
return
|
||||
|
||||
global logfile
|
||||
t = data.getVar('T', d, 1)
|
||||
if not t:
|
||||
return 0
|
||||
mkdirhier(t)
|
||||
logfile = "%s/log.%s.%s" % (t, func, str(os.getpid()))
|
||||
runfile = "%s/run.%s.%s" % (t, func, str(os.getpid()))
|
||||
|
||||
f = open(runfile, "w")
|
||||
f.write("#!/bin/sh -e\n")
|
||||
if bb.msg.debug_level['default'] > 0: f.write("set -x\n")
|
||||
data.emit_env(f, d)
|
||||
|
||||
f.write("cd '%s'\n" % os.getcwd())
|
||||
if func: f.write("%s\n" % func)
|
||||
f.close()
|
||||
os.chmod(runfile, 0775)
|
||||
if not func:
|
||||
bb.msg.error(bb.msg.domain.Build, "Function not specified")
|
||||
raise FuncFailed()
|
||||
|
||||
# open logs
|
||||
si = file('/dev/null', 'r')
|
||||
try:
|
||||
if bb.msg.debug_level['default'] > 0:
|
||||
so = os.popen("tee \"%s\"" % logfile, "w")
|
||||
else:
|
||||
so = file(logfile, 'w')
|
||||
except OSError, e:
|
||||
bb.msg.error(bb.msg.domain.Build, "opening log file: %s" % e)
|
||||
pass
|
||||
|
||||
se = so
|
||||
|
||||
if not interact:
|
||||
# dup the existing fds so we dont lose them
|
||||
osi = [os.dup(sys.stdin.fileno()), sys.stdin.fileno()]
|
||||
oso = [os.dup(sys.stdout.fileno()), sys.stdout.fileno()]
|
||||
ose = [os.dup(sys.stderr.fileno()), sys.stderr.fileno()]
|
||||
|
||||
# replace those fds with our own
|
||||
os.dup2(si.fileno(), osi[1])
|
||||
os.dup2(so.fileno(), oso[1])
|
||||
os.dup2(se.fileno(), ose[1])
|
||||
|
||||
# execute function
|
||||
prevdir = os.getcwd()
|
||||
if data.getVarFlag(func, "fakeroot", d):
|
||||
maybe_fakeroot = "PATH=\"%s\" fakeroot " % bb.data.getVar("PATH", d, 1)
|
||||
else:
|
||||
maybe_fakeroot = ''
|
||||
lang_environment = "LC_ALL=C "
|
||||
ret = os.system('%s%ssh -e "%s"' % (lang_environment, maybe_fakeroot, runfile))
|
||||
try:
|
||||
os.chdir(prevdir)
|
||||
except:
|
||||
pass
|
||||
|
||||
if not interact:
|
||||
# restore the backups
|
||||
os.dup2(osi[0], osi[1])
|
||||
os.dup2(oso[0], oso[1])
|
||||
os.dup2(ose[0], ose[1])
|
||||
|
||||
# close our logs
|
||||
si.close()
|
||||
so.close()
|
||||
se.close()
|
||||
|
||||
# close the backup fds
|
||||
os.close(osi[0])
|
||||
os.close(oso[0])
|
||||
os.close(ose[0])
|
||||
|
||||
if ret==0:
|
||||
if bb.msg.debug_level['default'] > 0:
|
||||
os.remove(runfile)
|
||||
# os.remove(logfile)
|
||||
return
|
||||
else:
|
||||
bb.msg.error(bb.msg.domain.Build, "function %s failed" % func)
|
||||
if data.getVar("BBINCLUDELOGS", d):
|
||||
bb.msg.error(bb.msg.domain.Build, "log data follows (%s)" % logfile)
|
||||
number_of_lines = data.getVar("BBINCLUDELOGS_LINES", d)
|
||||
if number_of_lines:
|
||||
os.system('tail -n%s %s' % (number_of_lines, logfile))
|
||||
else:
|
||||
f = open(logfile, "r")
|
||||
while True:
|
||||
l = f.readline()
|
||||
if l == '':
|
||||
break
|
||||
l = l.rstrip()
|
||||
print '| %s' % l
|
||||
f.close()
|
||||
else:
|
||||
bb.msg.error(bb.msg.domain.Build, "see log in %s" % logfile)
|
||||
raise FuncFailed( logfile )
|
||||
|
||||
|
||||
def exec_task(task, d):
|
||||
"""Execute an BB 'task'
|
||||
|
||||
The primary difference between executing a task versus executing
|
||||
a function is that a task exists in the task digraph, and therefore
|
||||
has dependencies amongst other tasks."""
|
||||
|
||||
# check if the task is in the graph..
|
||||
task_graph = data.getVar('_task_graph', d)
|
||||
if not task_graph:
|
||||
task_graph = bb.digraph()
|
||||
data.setVar('_task_graph', task_graph, d)
|
||||
task_cache = data.getVar('_task_cache', d)
|
||||
if not task_cache:
|
||||
task_cache = []
|
||||
data.setVar('_task_cache', task_cache, d)
|
||||
if not task_graph.hasnode(task):
|
||||
raise EventException("Missing node in task graph", InvalidTask(task, d))
|
||||
|
||||
# check whether this task needs executing..
|
||||
if stamp_is_current(task, d):
|
||||
return 1
|
||||
|
||||
# follow digraph path up, then execute our way back down
|
||||
def execute(graph, item):
|
||||
if data.getVarFlag(item, 'task', d):
|
||||
if item in task_cache:
|
||||
return 1
|
||||
|
||||
if task != item:
|
||||
# deeper than toplevel, exec w/ deps
|
||||
exec_task(item, d)
|
||||
return 1
|
||||
|
||||
try:
|
||||
bb.msg.debug(1, bb.msg.domain.Build, "Executing task %s" % item)
|
||||
old_overrides = data.getVar('OVERRIDES', d, 0)
|
||||
localdata = data.createCopy(d)
|
||||
data.setVar('OVERRIDES', 'task_%s:%s' % (item, old_overrides), localdata)
|
||||
data.update_data(localdata)
|
||||
event.fire(TaskStarted(item, localdata))
|
||||
exec_func(item, localdata)
|
||||
event.fire(TaskSucceeded(item, localdata))
|
||||
task_cache.append(item)
|
||||
data.setVar('_task_cache', task_cache, d)
|
||||
except FuncFailed, reason:
|
||||
bb.msg.note(1, bb.msg.domain.Build, "Task failed: %s" % reason )
|
||||
failedevent = TaskFailed(item, d)
|
||||
event.fire(failedevent)
|
||||
raise EventException("Function failed in task: %s" % reason, failedevent)
|
||||
|
||||
if data.getVarFlag(task, 'dontrundeps', d):
|
||||
execute(None, task)
|
||||
else:
|
||||
task_graph.walkdown(task, execute)
|
||||
|
||||
# make stamp, or cause event and raise exception
|
||||
if not data.getVarFlag(task, 'nostamp', d):
|
||||
make_stamp(task, d)
|
||||
|
||||
def extract_stamp_data(d, fn):
|
||||
"""
|
||||
Extracts stamp data from d which is either a data dictonary (fn unset)
|
||||
or a dataCache entry (fn set).
|
||||
"""
|
||||
if fn:
|
||||
return (d.task_queues[fn], d.stamp[fn], d.task_deps[fn])
|
||||
task_graph = data.getVar('_task_graph', d)
|
||||
if not task_graph:
|
||||
task_graph = bb.digraph()
|
||||
data.setVar('_task_graph', task_graph, d)
|
||||
return (task_graph, data.getVar('STAMP', d, 1), None)
|
||||
|
||||
def extract_stamp(d, fn):
|
||||
"""
|
||||
Extracts stamp format which is either a data dictonary (fn unset)
|
||||
or a dataCache entry (fn set).
|
||||
"""
|
||||
if fn:
|
||||
return d.stamp[fn]
|
||||
return data.getVar('STAMP', d, 1)
|
||||
|
||||
def stamp_is_current(task, d, file_name = None, checkdeps = 1):
|
||||
"""
|
||||
Check status of a given task's stamp.
|
||||
Returns 0 if it is not current and needs updating.
|
||||
(d can be a data dict or dataCache)
|
||||
"""
|
||||
|
||||
(task_graph, stampfn, taskdep) = extract_stamp_data(d, file_name)
|
||||
|
||||
if not stampfn:
|
||||
return 0
|
||||
|
||||
stampfile = "%s.%s" % (stampfn, task)
|
||||
if not os.access(stampfile, os.F_OK):
|
||||
return 0
|
||||
|
||||
if checkdeps == 0:
|
||||
return 1
|
||||
|
||||
import stat
|
||||
tasktime = os.stat(stampfile)[stat.ST_MTIME]
|
||||
|
||||
_deps = []
|
||||
def checkStamp(graph, task):
|
||||
# check for existance
|
||||
if file_name:
|
||||
if 'nostamp' in taskdep and task in taskdep['nostamp']:
|
||||
return 1
|
||||
else:
|
||||
if data.getVarFlag(task, 'nostamp', d):
|
||||
return 1
|
||||
|
||||
if not stamp_is_current(task, d, file_name, 0 ):
|
||||
return 0
|
||||
|
||||
depfile = "%s.%s" % (stampfn, task)
|
||||
deptime = os.stat(depfile)[stat.ST_MTIME]
|
||||
if deptime > tasktime:
|
||||
return 0
|
||||
return 1
|
||||
|
||||
return task_graph.walkdown(task, checkStamp)
|
||||
|
||||
def stamp_internal(task, d, file_name):
|
||||
"""
|
||||
Internal stamp helper function
|
||||
Removes any stamp for the given task
|
||||
Makes sure the stamp directory exists
|
||||
Returns the stamp path+filename
|
||||
"""
|
||||
stamp = extract_stamp(d, file_name)
|
||||
if not stamp:
|
||||
return
|
||||
stamp = "%s.%s" % (stamp, task)
|
||||
mkdirhier(os.path.dirname(stamp))
|
||||
# Remove the file and recreate to force timestamp
|
||||
# change on broken NFS filesystems
|
||||
if os.access(stamp, os.F_OK):
|
||||
os.remove(stamp)
|
||||
return stamp
|
||||
|
||||
def make_stamp(task, d, file_name = None):
|
||||
"""
|
||||
Creates/updates a stamp for a given task
|
||||
(d can be a data dict or dataCache)
|
||||
"""
|
||||
stamp = stamp_internal(task, d, file_name)
|
||||
if stamp:
|
||||
f = open(stamp, "w")
|
||||
f.close()
|
||||
|
||||
def del_stamp(task, d, file_name = None):
|
||||
"""
|
||||
Removes a stamp for a given task
|
||||
(d can be a data dict or dataCache)
|
||||
"""
|
||||
stamp_internal(task, d, file_name)
|
||||
|
||||
def add_task(task, deps, d):
|
||||
task_graph = data.getVar('_task_graph', d)
|
||||
if not task_graph:
|
||||
task_graph = bb.digraph()
|
||||
data.setVarFlag(task, 'task', 1, d)
|
||||
task_graph.addnode(task, None)
|
||||
for dep in deps:
|
||||
if not task_graph.hasnode(dep):
|
||||
task_graph.addnode(dep, None)
|
||||
task_graph.addnode(task, dep)
|
||||
# don't assume holding a reference
|
||||
data.setVar('_task_graph', task_graph, d)
|
||||
|
||||
task_deps = data.getVar('_task_deps', d)
|
||||
if not task_deps:
|
||||
task_deps = {}
|
||||
def getTask(name):
|
||||
deptask = data.getVarFlag(task, name, d)
|
||||
if deptask:
|
||||
deptask = data.expand(deptask, d)
|
||||
if not name in task_deps:
|
||||
task_deps[name] = {}
|
||||
task_deps[name][task] = deptask
|
||||
getTask('depends')
|
||||
getTask('deptask')
|
||||
getTask('rdeptask')
|
||||
getTask('recrdeptask')
|
||||
getTask('nostamp')
|
||||
|
||||
data.setVar('_task_deps', task_deps, d)
|
||||
|
||||
def remove_task(task, kill, d):
|
||||
"""Remove an BB 'task'.
|
||||
|
||||
If kill is 1, also remove tasks that depend on this task."""
|
||||
|
||||
task_graph = data.getVar('_task_graph', d)
|
||||
if not task_graph:
|
||||
task_graph = bb.digraph()
|
||||
if not task_graph.hasnode(task):
|
||||
return
|
||||
|
||||
data.delVarFlag(task, 'task', d)
|
||||
ref = 1
|
||||
if kill == 1:
|
||||
ref = 2
|
||||
task_graph.delnode(task, ref)
|
||||
data.setVar('_task_graph', task_graph, d)
|
||||
|
||||
def task_exists(task, d):
|
||||
task_graph = data.getVar('_task_graph', d)
|
||||
if not task_graph:
|
||||
task_graph = bb.digraph()
|
||||
data.setVar('_task_graph', task_graph, d)
|
||||
return task_graph.hasnode(task)
|
||||
433
bitbake/lib/bb/cache.py
Normal file
433
bitbake/lib/bb/cache.py
Normal file
@@ -0,0 +1,433 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# BitBake 'Event' implementation
|
||||
#
|
||||
# Caching of bitbake variables before task execution
|
||||
|
||||
# Copyright (C) 2006 Richard Purdie
|
||||
|
||||
# but small sections based on code from bin/bitbake:
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
# Copyright (C) 2003, 2004 Phil Blundell
|
||||
# Copyright (C) 2003 - 2005 Michael 'Mickey' Lauer
|
||||
# Copyright (C) 2005 Holger Hans Peter Freyther
|
||||
# Copyright (C) 2005 ROAD GmbH
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
|
||||
import os, re
|
||||
import bb.data
|
||||
import bb.utils
|
||||
from sets import Set
|
||||
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except ImportError:
|
||||
import pickle
|
||||
bb.msg.note(1, bb.msg.domain.Cache, "Importing cPickle failed. Falling back to a very slow implementation.")
|
||||
|
||||
__cache_version__ = "126"
|
||||
|
||||
class Cache:
|
||||
"""
|
||||
BitBake Cache implementation
|
||||
"""
|
||||
def __init__(self, cooker):
|
||||
|
||||
|
||||
self.cachedir = bb.data.getVar("CACHE", cooker.configuration.data, True)
|
||||
self.clean = {}
|
||||
self.depends_cache = {}
|
||||
self.data = None
|
||||
self.data_fn = None
|
||||
|
||||
if self.cachedir in [None, '']:
|
||||
self.has_cache = False
|
||||
bb.msg.note(1, bb.msg.domain.Cache, "Not using a cache. Set CACHE = <directory> to enable.")
|
||||
else:
|
||||
self.has_cache = True
|
||||
self.cachefile = os.path.join(self.cachedir,"bb_cache.dat")
|
||||
|
||||
bb.msg.debug(1, bb.msg.domain.Cache, "Using cache in '%s'" % self.cachedir)
|
||||
try:
|
||||
os.stat( self.cachedir )
|
||||
except OSError:
|
||||
bb.mkdirhier( self.cachedir )
|
||||
|
||||
if self.has_cache and (self.mtime(self.cachefile)):
|
||||
try:
|
||||
p = pickle.Unpickler( file(self.cachefile,"rb"))
|
||||
self.depends_cache, version_data = p.load()
|
||||
if version_data['CACHE_VER'] != __cache_version__:
|
||||
raise ValueError, 'Cache Version Mismatch'
|
||||
if version_data['BITBAKE_VER'] != bb.__version__:
|
||||
raise ValueError, 'Bitbake Version Mismatch'
|
||||
except EOFError:
|
||||
bb.msg.note(1, bb.msg.domain.Cache, "Truncated cache found, rebuilding...")
|
||||
self.depends_cache = {}
|
||||
except (ValueError, KeyError):
|
||||
bb.msg.note(1, bb.msg.domain.Cache, "Invalid cache found, rebuilding...")
|
||||
self.depends_cache = {}
|
||||
|
||||
if self.depends_cache:
|
||||
for fn in self.depends_cache.keys():
|
||||
self.clean[fn] = ""
|
||||
self.cacheValidUpdate(fn)
|
||||
|
||||
def getVar(self, var, fn, exp = 0):
|
||||
"""
|
||||
Gets the value of a variable
|
||||
(similar to getVar in the data class)
|
||||
|
||||
There are two scenarios:
|
||||
1. We have cached data - serve from depends_cache[fn]
|
||||
2. We're learning what data to cache - serve from data
|
||||
backend but add a copy of the data to the cache.
|
||||
"""
|
||||
|
||||
if fn in self.clean:
|
||||
return self.depends_cache[fn][var]
|
||||
|
||||
if not fn in self.depends_cache:
|
||||
self.depends_cache[fn] = {}
|
||||
|
||||
if fn != self.data_fn:
|
||||
# We're trying to access data in the cache which doesn't exist
|
||||
# yet setData hasn't been called to setup the right access. Very bad.
|
||||
bb.msg.error(bb.msg.domain.Cache, "Parsing error data_fn %s and fn %s don't match" % (self.data_fn, fn))
|
||||
|
||||
result = bb.data.getVar(var, self.data, exp)
|
||||
self.depends_cache[fn][var] = result
|
||||
return result
|
||||
|
||||
def setData(self, fn, data):
|
||||
"""
|
||||
Called to prime bb_cache ready to learn which variables to cache.
|
||||
Will be followed by calls to self.getVar which aren't cached
|
||||
but can be fulfilled from self.data.
|
||||
"""
|
||||
self.data_fn = fn
|
||||
self.data = data
|
||||
|
||||
# Make sure __depends makes the depends_cache
|
||||
self.getVar("__depends", fn, True)
|
||||
self.depends_cache[fn]["CACHETIMESTAMP"] = bb.parse.cached_mtime(fn)
|
||||
|
||||
def loadDataFull(self, fn, cfgData):
|
||||
"""
|
||||
Return a complete set of data for fn.
|
||||
To do this, we need to parse the file.
|
||||
"""
|
||||
bb_data, skipped = self.load_bbfile(fn, cfgData)
|
||||
return bb_data
|
||||
|
||||
def loadData(self, fn, cfgData):
|
||||
"""
|
||||
Load a subset of data for fn.
|
||||
If the cached data is valid we do nothing,
|
||||
To do this, we need to parse the file and set the system
|
||||
to record the variables accessed.
|
||||
Return the cache status and whether the file was skipped when parsed
|
||||
"""
|
||||
if self.cacheValid(fn):
|
||||
if "SKIPPED" in self.depends_cache[fn]:
|
||||
return True, True
|
||||
return True, False
|
||||
|
||||
bb_data, skipped = self.load_bbfile(fn, cfgData)
|
||||
self.setData(fn, bb_data)
|
||||
return False, skipped
|
||||
|
||||
def cacheValid(self, fn):
|
||||
"""
|
||||
Is the cache valid for fn?
|
||||
Fast version, no timestamps checked.
|
||||
"""
|
||||
# Is cache enabled?
|
||||
if not self.has_cache:
|
||||
return False
|
||||
if fn in self.clean:
|
||||
return True
|
||||
return False
|
||||
|
||||
def cacheValidUpdate(self, fn):
|
||||
"""
|
||||
Is the cache valid for fn?
|
||||
Make thorough (slower) checks including timestamps.
|
||||
"""
|
||||
# Is cache enabled?
|
||||
if not self.has_cache:
|
||||
return False
|
||||
|
||||
# Check file still exists
|
||||
if self.mtime(fn) == 0:
|
||||
bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s not longer exists" % fn)
|
||||
self.remove(fn)
|
||||
return False
|
||||
|
||||
# File isn't in depends_cache
|
||||
if not fn in self.depends_cache:
|
||||
bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s is not cached" % fn)
|
||||
self.remove(fn)
|
||||
return False
|
||||
|
||||
# Check the file's timestamp
|
||||
if bb.parse.cached_mtime(fn) > self.getVar("CACHETIMESTAMP", fn, True):
|
||||
bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s changed" % fn)
|
||||
self.remove(fn)
|
||||
return False
|
||||
|
||||
# Check dependencies are still valid
|
||||
depends = self.getVar("__depends", fn, True)
|
||||
for f,old_mtime in depends:
|
||||
# Check if file still exists
|
||||
if self.mtime(f) == 0:
|
||||
return False
|
||||
|
||||
new_mtime = bb.parse.cached_mtime(f)
|
||||
if (new_mtime > old_mtime):
|
||||
bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s's dependency %s changed" % (fn, f))
|
||||
self.remove(fn)
|
||||
return False
|
||||
|
||||
bb.msg.debug(2, bb.msg.domain.Cache, "Depends Cache: %s is clean" % fn)
|
||||
if not fn in self.clean:
|
||||
self.clean[fn] = ""
|
||||
|
||||
return True
|
||||
|
||||
def skip(self, fn):
|
||||
"""
|
||||
Mark a fn as skipped
|
||||
Called from the parser
|
||||
"""
|
||||
if not fn in self.depends_cache:
|
||||
self.depends_cache[fn] = {}
|
||||
self.depends_cache[fn]["SKIPPED"] = "1"
|
||||
|
||||
def remove(self, fn):
|
||||
"""
|
||||
Remove a fn from the cache
|
||||
Called from the parser in error cases
|
||||
"""
|
||||
bb.msg.debug(1, bb.msg.domain.Cache, "Removing %s from cache" % fn)
|
||||
if fn in self.depends_cache:
|
||||
del self.depends_cache[fn]
|
||||
if fn in self.clean:
|
||||
del self.clean[fn]
|
||||
|
||||
def sync(self):
|
||||
"""
|
||||
Save the cache
|
||||
Called from the parser when complete (or exiting)
|
||||
"""
|
||||
|
||||
if not self.has_cache:
|
||||
return
|
||||
|
||||
version_data = {}
|
||||
version_data['CACHE_VER'] = __cache_version__
|
||||
version_data['BITBAKE_VER'] = bb.__version__
|
||||
|
||||
p = pickle.Pickler(file(self.cachefile, "wb" ), -1 )
|
||||
p.dump([self.depends_cache, version_data])
|
||||
|
||||
def mtime(self, cachefile):
|
||||
return bb.parse.cached_mtime_noerror(cachefile)
|
||||
|
||||
def handle_data(self, file_name, cacheData):
|
||||
"""
|
||||
Save data we need into the cache
|
||||
"""
|
||||
|
||||
pn = self.getVar('PN', file_name, True)
|
||||
pe = self.getVar('PE', file_name, True) or "0"
|
||||
pv = self.getVar('PV', file_name, True)
|
||||
pr = self.getVar('PR', file_name, True)
|
||||
dp = int(self.getVar('DEFAULT_PREFERENCE', file_name, True) or "0")
|
||||
provides = Set([pn] + (self.getVar("PROVIDES", file_name, True) or "").split())
|
||||
depends = bb.utils.explode_deps(self.getVar("DEPENDS", file_name, True) or "")
|
||||
packages = (self.getVar('PACKAGES', file_name, True) or "").split()
|
||||
packages_dynamic = (self.getVar('PACKAGES_DYNAMIC', file_name, True) or "").split()
|
||||
rprovides = (self.getVar("RPROVIDES", file_name, True) or "").split()
|
||||
|
||||
cacheData.task_queues[file_name] = self.getVar("_task_graph", file_name, True)
|
||||
cacheData.task_deps[file_name] = self.getVar("_task_deps", file_name, True)
|
||||
|
||||
# build PackageName to FileName lookup table
|
||||
if pn not in cacheData.pkg_pn:
|
||||
cacheData.pkg_pn[pn] = []
|
||||
cacheData.pkg_pn[pn].append(file_name)
|
||||
|
||||
cacheData.stamp[file_name] = self.getVar('STAMP', file_name, True)
|
||||
|
||||
# build FileName to PackageName lookup table
|
||||
cacheData.pkg_fn[file_name] = pn
|
||||
cacheData.pkg_pepvpr[file_name] = (pe,pv,pr)
|
||||
cacheData.pkg_dp[file_name] = dp
|
||||
|
||||
# Build forward and reverse provider hashes
|
||||
# Forward: virtual -> [filenames]
|
||||
# Reverse: PN -> [virtuals]
|
||||
if pn not in cacheData.pn_provides:
|
||||
cacheData.pn_provides[pn] = Set()
|
||||
cacheData.pn_provides[pn] |= provides
|
||||
|
||||
for provide in provides:
|
||||
if provide not in cacheData.providers:
|
||||
cacheData.providers[provide] = []
|
||||
cacheData.providers[provide].append(file_name)
|
||||
|
||||
cacheData.deps[file_name] = Set()
|
||||
for dep in depends:
|
||||
cacheData.all_depends.add(dep)
|
||||
cacheData.deps[file_name].add(dep)
|
||||
|
||||
# Build reverse hash for PACKAGES, so runtime dependencies
|
||||
# can be be resolved (RDEPENDS, RRECOMMENDS etc.)
|
||||
for package in packages:
|
||||
if not package in cacheData.packages:
|
||||
cacheData.packages[package] = []
|
||||
cacheData.packages[package].append(file_name)
|
||||
rprovides += (self.getVar("RPROVIDES_%s" % package, file_name, 1) or "").split()
|
||||
|
||||
for package in packages_dynamic:
|
||||
if not package in cacheData.packages_dynamic:
|
||||
cacheData.packages_dynamic[package] = []
|
||||
cacheData.packages_dynamic[package].append(file_name)
|
||||
|
||||
for rprovide in rprovides:
|
||||
if not rprovide in cacheData.rproviders:
|
||||
cacheData.rproviders[rprovide] = []
|
||||
cacheData.rproviders[rprovide].append(file_name)
|
||||
|
||||
# Build hash of runtime depends and rececommends
|
||||
|
||||
def add_dep(deplist, deps):
|
||||
for dep in deps:
|
||||
if not dep in deplist:
|
||||
deplist[dep] = ""
|
||||
|
||||
if not file_name in cacheData.rundeps:
|
||||
cacheData.rundeps[file_name] = {}
|
||||
if not file_name in cacheData.runrecs:
|
||||
cacheData.runrecs[file_name] = {}
|
||||
|
||||
for package in packages + [pn]:
|
||||
if not package in cacheData.rundeps[file_name]:
|
||||
cacheData.rundeps[file_name][package] = {}
|
||||
if not package in cacheData.runrecs[file_name]:
|
||||
cacheData.runrecs[file_name][package] = {}
|
||||
|
||||
add_dep(cacheData.rundeps[file_name][package], bb.utils.explode_deps(self.getVar('RDEPENDS', file_name, True) or ""))
|
||||
add_dep(cacheData.runrecs[file_name][package], bb.utils.explode_deps(self.getVar('RRECOMMENDS', file_name, True) or ""))
|
||||
add_dep(cacheData.rundeps[file_name][package], bb.utils.explode_deps(self.getVar("RDEPENDS_%s" % package, file_name, True) or ""))
|
||||
add_dep(cacheData.runrecs[file_name][package], bb.utils.explode_deps(self.getVar("RRECOMMENDS_%s" % package, file_name, True) or ""))
|
||||
|
||||
# Collect files we may need for possible world-dep
|
||||
# calculations
|
||||
if not self.getVar('BROKEN', file_name, True) and not self.getVar('EXCLUDE_FROM_WORLD', file_name, True):
|
||||
cacheData.possible_world.append(file_name)
|
||||
|
||||
|
||||
def load_bbfile( self, bbfile , config):
|
||||
"""
|
||||
Load and parse one .bb build file
|
||||
Return the data and whether parsing resulted in the file being skipped
|
||||
"""
|
||||
|
||||
import bb
|
||||
from bb import utils, data, parse, debug, event, fatal
|
||||
|
||||
# expand tmpdir to include this topdir
|
||||
data.setVar('TMPDIR', data.getVar('TMPDIR', config, 1) or "", config)
|
||||
bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
|
||||
oldpath = os.path.abspath(os.getcwd())
|
||||
if self.mtime(bbfile_loc):
|
||||
os.chdir(bbfile_loc)
|
||||
bb_data = data.init_db(config)
|
||||
try:
|
||||
bb_data = parse.handle(bbfile, bb_data) # read .bb data
|
||||
os.chdir(oldpath)
|
||||
return bb_data, False
|
||||
except bb.parse.SkipPackage:
|
||||
os.chdir(oldpath)
|
||||
return bb_data, True
|
||||
except:
|
||||
os.chdir(oldpath)
|
||||
raise
|
||||
|
||||
def init(cooker):
|
||||
"""
|
||||
The Objective: Cache the minimum amount of data possible yet get to the
|
||||
stage of building packages (i.e. tryBuild) without reparsing any .bb files.
|
||||
|
||||
To do this, we intercept getVar calls and only cache the variables we see
|
||||
being accessed. We rely on the cache getVar calls being made for all
|
||||
variables bitbake might need to use to reach this stage. For each cached
|
||||
file we need to track:
|
||||
|
||||
* Its mtime
|
||||
* The mtimes of all its dependencies
|
||||
* Whether it caused a parse.SkipPackage exception
|
||||
|
||||
Files causing parsing errors are evicted from the cache.
|
||||
|
||||
"""
|
||||
return Cache(cooker)
|
||||
|
||||
|
||||
|
||||
#============================================================================#
|
||||
# CacheData
|
||||
#============================================================================#
|
||||
class CacheData:
|
||||
"""
|
||||
The data structures we compile from the cached data
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Direct cache variables
|
||||
(from Cache.handle_data)
|
||||
"""
|
||||
self.providers = {}
|
||||
self.rproviders = {}
|
||||
self.packages = {}
|
||||
self.packages_dynamic = {}
|
||||
self.possible_world = []
|
||||
self.pkg_pn = {}
|
||||
self.pkg_fn = {}
|
||||
self.pkg_pepvpr = {}
|
||||
self.pkg_dp = {}
|
||||
self.pn_provides = {}
|
||||
self.all_depends = Set()
|
||||
self.deps = {}
|
||||
self.rundeps = {}
|
||||
self.runrecs = {}
|
||||
self.task_queues = {}
|
||||
self.task_deps = {}
|
||||
self.stamp = {}
|
||||
self.preferred = {}
|
||||
|
||||
"""
|
||||
Indirect Cache variables
|
||||
(set elsewhere)
|
||||
"""
|
||||
self.ignored_dependencies = []
|
||||
self.world_target = Set()
|
||||
self.bbfile_priority = {}
|
||||
self.bbfile_config_priorities = []
|
||||
657
bitbake/lib/bb/cooker.py
Normal file
657
bitbake/lib/bb/cooker.py
Normal file
@@ -0,0 +1,657 @@
|
||||
#!/usr/bin/env python
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
# Copyright (C) 2003, 2004 Phil Blundell
|
||||
# Copyright (C) 2003 - 2005 Michael 'Mickey' Lauer
|
||||
# Copyright (C) 2005 Holger Hans Peter Freyther
|
||||
# Copyright (C) 2005 ROAD GmbH
|
||||
# Copyright (C) 2006 Richard Purdie
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import sys, os, getopt, glob, copy, os.path, re, time
|
||||
import bb
|
||||
from bb import utils, data, parse, event, cache, providers, taskdata, runqueue
|
||||
from sets import Set
|
||||
import itertools, sre_constants
|
||||
|
||||
parsespin = itertools.cycle( r'|/-\\' )
|
||||
|
||||
#============================================================================#
|
||||
# BBCooker
|
||||
#============================================================================#
|
||||
class BBCooker:
|
||||
"""
|
||||
Manages one bitbake build run
|
||||
"""
|
||||
|
||||
def __init__(self, configuration):
|
||||
self.status = None
|
||||
|
||||
self.cache = None
|
||||
self.bb_cache = None
|
||||
|
||||
self.configuration = configuration
|
||||
|
||||
if self.configuration.verbose:
|
||||
bb.msg.set_verbose(True)
|
||||
|
||||
if self.configuration.debug:
|
||||
bb.msg.set_debug_level(self.configuration.debug)
|
||||
else:
|
||||
bb.msg.set_debug_level(0)
|
||||
|
||||
if self.configuration.debug_domains:
|
||||
bb.msg.set_debug_domains(self.configuration.debug_domains)
|
||||
|
||||
self.configuration.data = bb.data.init()
|
||||
|
||||
for f in self.configuration.file:
|
||||
self.parseConfigurationFile( f )
|
||||
|
||||
self.parseConfigurationFile( os.path.join( "conf", "bitbake.conf" ) )
|
||||
|
||||
if not self.configuration.cmd:
|
||||
self.configuration.cmd = bb.data.getVar("BB_DEFAULT_TASK", self.configuration.data) or "build"
|
||||
|
||||
#
|
||||
# Special updated configuration we use for firing events
|
||||
#
|
||||
self.configuration.event_data = bb.data.createCopy(self.configuration.data)
|
||||
bb.data.update_data(self.configuration.event_data)
|
||||
|
||||
def tryBuildPackage(self, fn, item, task, the_data, build_depends):
|
||||
"""
|
||||
Build one task of a package, optionally build following task depends
|
||||
"""
|
||||
bb.event.fire(bb.event.PkgStarted(item, the_data))
|
||||
try:
|
||||
if not build_depends:
|
||||
bb.data.setVarFlag('do_%s' % task, 'dontrundeps', 1, the_data)
|
||||
if not self.configuration.dry_run:
|
||||
bb.build.exec_task('do_%s' % task, the_data)
|
||||
bb.event.fire(bb.event.PkgSucceeded(item, the_data))
|
||||
return True
|
||||
except bb.build.FuncFailed:
|
||||
bb.msg.error(bb.msg.domain.Build, "task stack execution failed")
|
||||
bb.event.fire(bb.event.PkgFailed(item, the_data))
|
||||
raise
|
||||
except bb.build.EventException, e:
|
||||
event = e.args[1]
|
||||
bb.msg.error(bb.msg.domain.Build, "%s event exception, aborting" % bb.event.getName(event))
|
||||
bb.event.fire(bb.event.PkgFailed(item, the_data))
|
||||
raise
|
||||
|
||||
def tryBuild( self, fn, build_depends):
|
||||
"""
|
||||
Build a provider and its dependencies.
|
||||
build_depends is a list of previous build dependencies (not runtime)
|
||||
If build_depends is empty, we're dealing with a runtime depends
|
||||
"""
|
||||
|
||||
the_data = self.bb_cache.loadDataFull(fn, self.configuration.data)
|
||||
|
||||
item = self.status.pkg_fn[fn]
|
||||
|
||||
if bb.build.stamp_is_current('do_%s' % self.configuration.cmd, the_data):
|
||||
return True
|
||||
|
||||
return self.tryBuildPackage(fn, item, self.configuration.cmd, the_data, build_depends)
|
||||
|
||||
def showVersions(self):
|
||||
pkg_pn = self.status.pkg_pn
|
||||
preferred_versions = {}
|
||||
latest_versions = {}
|
||||
|
||||
# Sort by priority
|
||||
for pn in pkg_pn.keys():
|
||||
(last_ver,last_file,pref_ver,pref_file) = bb.providers.findBestProvider(pn, self.configuration.data, self.status)
|
||||
preferred_versions[pn] = (pref_ver, pref_file)
|
||||
latest_versions[pn] = (last_ver, last_file)
|
||||
|
||||
pkg_list = pkg_pn.keys()
|
||||
pkg_list.sort()
|
||||
|
||||
for p in pkg_list:
|
||||
pref = preferred_versions[p]
|
||||
latest = latest_versions[p]
|
||||
|
||||
if pref != latest:
|
||||
prefstr = pref[0][0] + ":" + pref[0][1] + '-' + pref[0][2]
|
||||
else:
|
||||
prefstr = ""
|
||||
|
||||
print "%-30s %20s %20s" % (p, latest[0][0] + ":" + latest[0][1] + "-" + latest[0][2],
|
||||
prefstr)
|
||||
|
||||
|
||||
def showEnvironment( self ):
|
||||
"""Show the outer or per-package environment"""
|
||||
if self.configuration.buildfile:
|
||||
self.cb = None
|
||||
self.bb_cache = bb.cache.init(self)
|
||||
try:
|
||||
self.configuration.data = self.bb_cache.loadDataFull(self.configuration.buildfile, self.configuration.data)
|
||||
except IOError, e:
|
||||
bb.msg.fatal(bb.msg.domain.Parsing, "Unable to read %s: %s" % ( self.configuration.buildfile, e ))
|
||||
except Exception, e:
|
||||
bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e)
|
||||
# emit variables and shell functions
|
||||
try:
|
||||
data.update_data( self.configuration.data )
|
||||
data.emit_env(sys.__stdout__, self.configuration.data, True)
|
||||
except Exception, e:
|
||||
bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e)
|
||||
# emit the metadata which isnt valid shell
|
||||
data.expandKeys( self.configuration.data )
|
||||
for e in self.configuration.data.keys():
|
||||
if data.getVarFlag( e, 'python', self.configuration.data ):
|
||||
sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, data.getVar(e, self.configuration.data, 1)))
|
||||
|
||||
def generateDotGraph( self, pkgs_to_build, ignore_deps ):
|
||||
"""
|
||||
Generate a task dependency graph.
|
||||
|
||||
pkgs_to_build A list of packages that needs to be built
|
||||
ignore_deps A list of names where processing of dependencies
|
||||
should be stopped. e.g. dependencies that get
|
||||
"""
|
||||
|
||||
for dep in ignore_deps:
|
||||
self.status.ignored_dependencies.add(dep)
|
||||
|
||||
localdata = data.createCopy(self.configuration.data)
|
||||
bb.data.update_data(localdata)
|
||||
bb.data.expandKeys(localdata)
|
||||
taskdata = bb.taskdata.TaskData(self.configuration.abort)
|
||||
|
||||
runlist = []
|
||||
try:
|
||||
for k in pkgs_to_build:
|
||||
taskdata.add_provider(localdata, self.status, k)
|
||||
runlist.append([k, "do_%s" % self.configuration.cmd])
|
||||
taskdata.add_unresolved(localdata, self.status)
|
||||
except bb.providers.NoProvider:
|
||||
sys.exit(1)
|
||||
rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist)
|
||||
rq.prepare_runqueue()
|
||||
|
||||
seen_fnids = []
|
||||
depends_file = file('depends.dot', 'w' )
|
||||
tdepends_file = file('task-depends.dot', 'w' )
|
||||
print >> depends_file, "digraph depends {"
|
||||
print >> tdepends_file, "digraph depends {"
|
||||
rq.prio_map.reverse()
|
||||
for task1 in range(len(rq.runq_fnid)):
|
||||
task = rq.prio_map[task1]
|
||||
taskname = rq.runq_task[task]
|
||||
fnid = rq.runq_fnid[task]
|
||||
fn = taskdata.fn_index[fnid]
|
||||
pn = self.status.pkg_fn[fn]
|
||||
version = "%s:%s-%s" % self.status.pkg_pepvpr[fn]
|
||||
print >> tdepends_file, '"%s.%s" [label="%s %s\\n%s\\n%s"]' % (pn, taskname, pn, taskname, version, fn)
|
||||
for dep in rq.runq_depends[task]:
|
||||
depfn = taskdata.fn_index[rq.runq_fnid[dep]]
|
||||
deppn = self.status.pkg_fn[depfn]
|
||||
print >> tdepends_file, '"%s.%s" -> "%s.%s"' % (pn, rq.runq_task[task], deppn, rq.runq_task[dep])
|
||||
if fnid not in seen_fnids:
|
||||
seen_fnids.append(fnid)
|
||||
packages = []
|
||||
print >> depends_file, '"%s" [label="%s %s\\n%s"]' % (pn, pn, version, fn)
|
||||
for depend in self.status.deps[fn]:
|
||||
print >> depends_file, '"%s" -> "%s"' % (pn, depend)
|
||||
rdepends = self.status.rundeps[fn]
|
||||
for package in rdepends:
|
||||
for rdepend in rdepends[package]:
|
||||
print >> depends_file, '"%s" -> "%s" [style=dashed]' % (package, rdepend)
|
||||
packages.append(package)
|
||||
rrecs = self.status.runrecs[fn]
|
||||
for package in rrecs:
|
||||
for rdepend in rrecs[package]:
|
||||
print >> depends_file, '"%s" -> "%s" [style=dashed]' % (package, rdepend)
|
||||
if not package in packages:
|
||||
packages.append(package)
|
||||
for package in packages:
|
||||
if package != pn:
|
||||
print >> depends_file, '"%s" [label="%s(%s) %s\\n%s"]' % (package, package, pn, version, fn)
|
||||
for depend in self.status.deps[fn]:
|
||||
print >> depends_file, '"%s" -> "%s"' % (package, depend)
|
||||
# Prints a flattened form of the above where subpackages of a package are merged into the main pn
|
||||
#print >> depends_file, '"%s" [label="%s %s\\n%s\\n%s"]' % (pn, pn, taskname, version, fn)
|
||||
#for rdep in taskdata.rdepids[fnid]:
|
||||
# print >> depends_file, '"%s" -> "%s" [style=dashed]' % (pn, taskdata.run_names_index[rdep])
|
||||
#for dep in taskdata.depids[fnid]:
|
||||
# print >> depends_file, '"%s" -> "%s"' % (pn, taskdata.build_names_index[dep])
|
||||
print >> depends_file, "}"
|
||||
print >> tdepends_file, "}"
|
||||
bb.msg.note(1, bb.msg.domain.Collection, "Dependencies saved to 'depends.dot'")
|
||||
bb.msg.note(1, bb.msg.domain.Collection, "Task dependencies saved to 'task-depends.dot'")
|
||||
|
||||
def buildDepgraph( self ):
|
||||
all_depends = self.status.all_depends
|
||||
pn_provides = self.status.pn_provides
|
||||
|
||||
localdata = data.createCopy(self.configuration.data)
|
||||
bb.data.update_data(localdata)
|
||||
bb.data.expandKeys(localdata)
|
||||
|
||||
def calc_bbfile_priority(filename):
|
||||
for (regex, pri) in self.status.bbfile_config_priorities:
|
||||
if regex.match(filename):
|
||||
return pri
|
||||
return 0
|
||||
|
||||
# Handle PREFERRED_PROVIDERS
|
||||
for p in (bb.data.getVar('PREFERRED_PROVIDERS', localdata, 1) or "").split():
|
||||
(providee, provider) = p.split(':')
|
||||
if providee in self.status.preferred and self.status.preferred[providee] != provider:
|
||||
bb.msg.error(bb.msg.domain.Provider, "conflicting preferences for %s: both %s and %s specified" % (providee, provider, self.status.preferred[providee]))
|
||||
self.status.preferred[providee] = provider
|
||||
|
||||
# Calculate priorities for each file
|
||||
for p in self.status.pkg_fn.keys():
|
||||
self.status.bbfile_priority[p] = calc_bbfile_priority(p)
|
||||
|
||||
def buildWorldTargetList(self):
|
||||
"""
|
||||
Build package list for "bitbake world"
|
||||
"""
|
||||
all_depends = self.status.all_depends
|
||||
pn_provides = self.status.pn_provides
|
||||
bb.msg.debug(1, bb.msg.domain.Parsing, "collating packages for \"world\"")
|
||||
for f in self.status.possible_world:
|
||||
terminal = True
|
||||
pn = self.status.pkg_fn[f]
|
||||
|
||||
for p in pn_provides[pn]:
|
||||
if p.startswith('virtual/'):
|
||||
bb.msg.debug(2, bb.msg.domain.Parsing, "World build skipping %s due to %s provider starting with virtual/" % (f, p))
|
||||
terminal = False
|
||||
break
|
||||
for pf in self.status.providers[p]:
|
||||
if self.status.pkg_fn[pf] != pn:
|
||||
bb.msg.debug(2, bb.msg.domain.Parsing, "World build skipping %s due to both us and %s providing %s" % (f, pf, p))
|
||||
terminal = False
|
||||
break
|
||||
if terminal:
|
||||
self.status.world_target.add(pn)
|
||||
|
||||
# drop reference count now
|
||||
self.status.possible_world = None
|
||||
self.status.all_depends = None
|
||||
|
||||
def myProgressCallback( self, x, y, f, from_cache ):
|
||||
"""Update any tty with the progress change"""
|
||||
if os.isatty(sys.stdout.fileno()):
|
||||
sys.stdout.write("\rNOTE: Handling BitBake files: %s (%04d/%04d) [%2d %%]" % ( parsespin.next(), x, y, x*100/y ) )
|
||||
sys.stdout.flush()
|
||||
else:
|
||||
if x == 1:
|
||||
sys.stdout.write("Parsing .bb files, please wait...")
|
||||
sys.stdout.flush()
|
||||
if x == y:
|
||||
sys.stdout.write("done.")
|
||||
sys.stdout.flush()
|
||||
|
||||
def interactiveMode( self ):
|
||||
"""Drop off into a shell"""
|
||||
try:
|
||||
from bb import shell
|
||||
except ImportError, details:
|
||||
bb.msg.fatal(bb.msg.domain.Parsing, "Sorry, shell not available (%s)" % details )
|
||||
else:
|
||||
bb.data.update_data( self.configuration.data )
|
||||
bb.data.expandKeys( self.configuration.data )
|
||||
shell.start( self )
|
||||
sys.exit( 0 )
|
||||
|
||||
def parseConfigurationFile( self, afile ):
|
||||
try:
|
||||
self.configuration.data = bb.parse.handle( afile, self.configuration.data )
|
||||
|
||||
# Add the handlers we inherited by INHERIT
|
||||
# we need to do this manually as it is not guranteed
|
||||
# we will pick up these classes... as we only INHERIT
|
||||
# on .inc and .bb files but not on .conf
|
||||
data = bb.data.createCopy( self.configuration.data )
|
||||
inherits = ["base"] + (bb.data.getVar('INHERIT', data, True ) or "").split()
|
||||
for inherit in inherits:
|
||||
data = bb.parse.handle( os.path.join('classes', '%s.bbclass' % inherit ), data, True )
|
||||
|
||||
# FIXME: This assumes that we included at least one .inc file
|
||||
for var in bb.data.keys(data):
|
||||
if bb.data.getVarFlag(var, 'handler', data):
|
||||
bb.event.register(var,bb.data.getVar(var, data))
|
||||
|
||||
except IOError:
|
||||
bb.msg.fatal(bb.msg.domain.Parsing, "Unable to open %s" % afile )
|
||||
except bb.parse.ParseError, details:
|
||||
bb.msg.fatal(bb.msg.domain.Parsing, "Unable to parse %s (%s)" % (afile, details) )
|
||||
|
||||
def handleCollections( self, collections ):
|
||||
"""Handle collections"""
|
||||
if collections:
|
||||
collection_list = collections.split()
|
||||
for c in collection_list:
|
||||
regex = bb.data.getVar("BBFILE_PATTERN_%s" % c, self.configuration.data, 1)
|
||||
if regex == None:
|
||||
bb.msg.error(bb.msg.domain.Parsing, "BBFILE_PATTERN_%s not defined" % c)
|
||||
continue
|
||||
priority = bb.data.getVar("BBFILE_PRIORITY_%s" % c, self.configuration.data, 1)
|
||||
if priority == None:
|
||||
bb.msg.error(bb.msg.domain.Parsing, "BBFILE_PRIORITY_%s not defined" % c)
|
||||
continue
|
||||
try:
|
||||
cre = re.compile(regex)
|
||||
except re.error:
|
||||
bb.msg.error(bb.msg.domain.Parsing, "BBFILE_PATTERN_%s \"%s\" is not a valid regular expression" % (c, regex))
|
||||
continue
|
||||
try:
|
||||
pri = int(priority)
|
||||
self.status.bbfile_config_priorities.append((cre, pri))
|
||||
except ValueError:
|
||||
bb.msg.error(bb.msg.domain.Parsing, "invalid value for BBFILE_PRIORITY_%s: \"%s\"" % (c, priority))
|
||||
|
||||
def buildSetVars(self):
|
||||
"""
|
||||
Setup any variables needed before starting a build
|
||||
"""
|
||||
if not bb.data.getVar("BUILDNAME", self.configuration.data):
|
||||
bb.data.setVar("BUILDNAME", os.popen('date +%Y%m%d%H%M').readline().strip(), self.configuration.data)
|
||||
bb.data.setVar("BUILDSTART", time.strftime('%m/%d/%Y %H:%M:%S',time.gmtime()),self.configuration.data)
|
||||
|
||||
def buildFile(self, buildfile):
|
||||
"""
|
||||
Build the file matching regexp buildfile
|
||||
"""
|
||||
|
||||
bf = os.path.abspath(buildfile)
|
||||
try:
|
||||
os.stat(bf)
|
||||
except OSError:
|
||||
(filelist, masked) = self.collect_bbfiles()
|
||||
regexp = re.compile(buildfile)
|
||||
matches = []
|
||||
for f in filelist:
|
||||
if regexp.search(f) and os.path.isfile(f):
|
||||
bf = f
|
||||
matches.append(f)
|
||||
if len(matches) != 1:
|
||||
bb.msg.error(bb.msg.domain.Parsing, "Unable to match %s (%s matches found):" % (buildfile, len(matches)))
|
||||
for f in matches:
|
||||
bb.msg.error(bb.msg.domain.Parsing, " %s" % f)
|
||||
sys.exit(1)
|
||||
bf = matches[0]
|
||||
|
||||
bbfile_data = bb.parse.handle(bf, self.configuration.data)
|
||||
|
||||
# Remove stamp for target if force mode active
|
||||
if self.configuration.force:
|
||||
bb.msg.note(2, bb.msg.domain.RunQueue, "Remove stamp %s, %s" % (self.configuration.cmd, bf))
|
||||
bb.build.del_stamp('do_%s' % self.configuration.cmd, bbfile_data)
|
||||
|
||||
item = bb.data.getVar('PN', bbfile_data, 1)
|
||||
try:
|
||||
self.tryBuildPackage(bf, item, self.configuration.cmd, bbfile_data, True)
|
||||
except bb.build.EventException:
|
||||
bb.msg.error(bb.msg.domain.Build, "Build of '%s' failed" % item )
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
def buildTargets(self, targets):
|
||||
"""
|
||||
Attempt to build the targets specified
|
||||
"""
|
||||
|
||||
buildname = bb.data.getVar("BUILDNAME", self.configuration.data)
|
||||
bb.event.fire(bb.event.BuildStarted(buildname, targets, self.configuration.event_data))
|
||||
|
||||
localdata = data.createCopy(self.configuration.data)
|
||||
bb.data.update_data(localdata)
|
||||
bb.data.expandKeys(localdata)
|
||||
|
||||
taskdata = bb.taskdata.TaskData(self.configuration.abort)
|
||||
|
||||
runlist = []
|
||||
try:
|
||||
for k in targets:
|
||||
taskdata.add_provider(localdata, self.status, k)
|
||||
runlist.append([k, "do_%s" % self.configuration.cmd])
|
||||
taskdata.add_unresolved(localdata, self.status)
|
||||
except bb.providers.NoProvider:
|
||||
sys.exit(1)
|
||||
|
||||
rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist)
|
||||
rq.prepare_runqueue()
|
||||
try:
|
||||
failures = rq.execute_runqueue()
|
||||
except runqueue.TaskFailure, fnids:
|
||||
for fnid in fnids:
|
||||
bb.msg.error(bb.msg.domain.Build, "'%s' failed" % taskdata.fn_index[fnid])
|
||||
sys.exit(1)
|
||||
bb.event.fire(bb.event.BuildCompleted(buildname, targets, self.configuration.event_data, failures))
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
def updateCache(self):
|
||||
# Import Psyco if available and not disabled
|
||||
if not self.configuration.disable_psyco:
|
||||
try:
|
||||
import psyco
|
||||
except ImportError:
|
||||
bb.msg.note(1, bb.msg.domain.Collection, "Psyco JIT Compiler (http://psyco.sf.net) not available. Install it to increase performance.")
|
||||
else:
|
||||
psyco.bind( self.parse_bbfiles )
|
||||
else:
|
||||
bb.msg.note(1, bb.msg.domain.Collection, "You have disabled Psyco. This decreases performance.")
|
||||
|
||||
self.status = bb.cache.CacheData()
|
||||
|
||||
ignore = bb.data.getVar("ASSUME_PROVIDED", self.configuration.data, 1) or ""
|
||||
self.status.ignored_dependencies = Set( ignore.split() )
|
||||
|
||||
self.handleCollections( bb.data.getVar("BBFILE_COLLECTIONS", self.configuration.data, 1) )
|
||||
|
||||
bb.msg.debug(1, bb.msg.domain.Collection, "collecting .bb files")
|
||||
(filelist, masked) = self.collect_bbfiles()
|
||||
self.parse_bbfiles(filelist, masked, self.myProgressCallback)
|
||||
bb.msg.debug(1, bb.msg.domain.Collection, "parsing complete")
|
||||
|
||||
self.buildDepgraph()
|
||||
|
||||
def cook(self):
|
||||
"""
|
||||
We are building stuff here. We do the building
|
||||
from here. By default we try to execute task
|
||||
build.
|
||||
"""
|
||||
|
||||
if self.configuration.show_environment:
|
||||
self.showEnvironment()
|
||||
sys.exit( 0 )
|
||||
|
||||
self.buildSetVars()
|
||||
|
||||
if self.configuration.interactive:
|
||||
self.interactiveMode()
|
||||
|
||||
if self.configuration.buildfile is not None:
|
||||
return self.buildFile(self.configuration.buildfile)
|
||||
|
||||
# initialise the parsing status now we know we will need deps
|
||||
self.updateCache()
|
||||
|
||||
if self.configuration.parse_only:
|
||||
bb.msg.note(1, bb.msg.domain.Collection, "Requested parsing .bb files only. Exiting.")
|
||||
return 0
|
||||
|
||||
pkgs_to_build = self.configuration.pkgs_to_build
|
||||
|
||||
bbpkgs = bb.data.getVar('BBPKGS', self.configuration.data, 1)
|
||||
if bbpkgs:
|
||||
pkgs_to_build.extend(bbpkgs.split())
|
||||
if len(pkgs_to_build) == 0 and not self.configuration.show_versions \
|
||||
and not self.configuration.show_environment:
|
||||
print "Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help'"
|
||||
print "for usage information."
|
||||
sys.exit(0)
|
||||
|
||||
try:
|
||||
if self.configuration.show_versions:
|
||||
self.showVersions()
|
||||
sys.exit( 0 )
|
||||
if 'world' in pkgs_to_build:
|
||||
self.buildWorldTargetList()
|
||||
pkgs_to_build.remove('world')
|
||||
for t in self.status.world_target:
|
||||
pkgs_to_build.append(t)
|
||||
|
||||
if self.configuration.dot_graph:
|
||||
self.generateDotGraph( pkgs_to_build, self.configuration.ignored_dot_deps )
|
||||
sys.exit( 0 )
|
||||
|
||||
return self.buildTargets(pkgs_to_build)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
bb.msg.note(1, bb.msg.domain.Collection, "KeyboardInterrupt - Build not completed.")
|
||||
sys.exit(1)
|
||||
|
||||
def get_bbfiles( self, path = os.getcwd() ):
|
||||
"""Get list of default .bb files by reading out the current directory"""
|
||||
contents = os.listdir(path)
|
||||
bbfiles = []
|
||||
for f in contents:
|
||||
(root, ext) = os.path.splitext(f)
|
||||
if ext == ".bb":
|
||||
bbfiles.append(os.path.abspath(os.path.join(os.getcwd(),f)))
|
||||
return bbfiles
|
||||
|
||||
def find_bbfiles( self, path ):
|
||||
"""Find all the .bb files in a directory"""
|
||||
from os.path import join
|
||||
|
||||
found = []
|
||||
for dir, dirs, files in os.walk(path):
|
||||
for ignored in ('SCCS', 'CVS', '.svn'):
|
||||
if ignored in dirs:
|
||||
dirs.remove(ignored)
|
||||
found += [join(dir,f) for f in files if f.endswith('.bb')]
|
||||
|
||||
return found
|
||||
|
||||
def collect_bbfiles( self ):
|
||||
"""Collect all available .bb build files"""
|
||||
parsed, cached, skipped, masked = 0, 0, 0, 0
|
||||
self.bb_cache = bb.cache.init(self)
|
||||
|
||||
files = (data.getVar( "BBFILES", self.configuration.data, 1 ) or "").split()
|
||||
data.setVar("BBFILES", " ".join(files), self.configuration.data)
|
||||
|
||||
if not len(files):
|
||||
files = self.get_bbfiles()
|
||||
|
||||
if not len(files):
|
||||
bb.msg.error(bb.msg.domain.Collection, "no files to build.")
|
||||
|
||||
newfiles = []
|
||||
for f in files:
|
||||
if os.path.isdir(f):
|
||||
dirfiles = self.find_bbfiles(f)
|
||||
if dirfiles:
|
||||
newfiles += dirfiles
|
||||
continue
|
||||
newfiles += glob.glob(f) or [ f ]
|
||||
|
||||
bbmask = bb.data.getVar('BBMASK', self.configuration.data, 1)
|
||||
|
||||
if not bbmask:
|
||||
return (newfiles, 0)
|
||||
|
||||
try:
|
||||
bbmask_compiled = re.compile(bbmask)
|
||||
except sre_constants.error:
|
||||
bb.msg.fatal(bb.msg.domain.Collection, "BBMASK is not a valid regular expression.")
|
||||
|
||||
finalfiles = []
|
||||
for i in xrange( len( newfiles ) ):
|
||||
f = newfiles[i]
|
||||
if bbmask and bbmask_compiled.search(f):
|
||||
bb.msg.debug(1, bb.msg.domain.Collection, "skipping masked file %s" % f)
|
||||
masked += 1
|
||||
continue
|
||||
finalfiles.append(f)
|
||||
|
||||
return (finalfiles, masked)
|
||||
|
||||
def parse_bbfiles(self, filelist, masked, progressCallback = None):
|
||||
parsed, cached, skipped, error = 0, 0, 0, 0
|
||||
for i in xrange( len( filelist ) ):
|
||||
f = filelist[i]
|
||||
|
||||
bb.msg.debug(1, bb.msg.domain.Collection, "parsing %s" % f)
|
||||
|
||||
# read a file's metadata
|
||||
try:
|
||||
fromCache, skip = self.bb_cache.loadData(f, self.configuration.data)
|
||||
if skip:
|
||||
skipped += 1
|
||||
bb.msg.debug(2, bb.msg.domain.Collection, "skipping %s" % f)
|
||||
self.bb_cache.skip(f)
|
||||
continue
|
||||
elif fromCache: cached += 1
|
||||
else: parsed += 1
|
||||
deps = None
|
||||
|
||||
# Disabled by RP as was no longer functional
|
||||
# allow metadata files to add items to BBFILES
|
||||
#data.update_data(self.pkgdata[f])
|
||||
#addbbfiles = self.bb_cache.getVar('BBFILES', f, False) or None
|
||||
#if addbbfiles:
|
||||
# for aof in addbbfiles.split():
|
||||
# if not files.count(aof):
|
||||
# if not os.path.isabs(aof):
|
||||
# aof = os.path.join(os.path.dirname(f),aof)
|
||||
# files.append(aof)
|
||||
|
||||
self.bb_cache.handle_data(f, self.status)
|
||||
|
||||
# now inform the caller
|
||||
if progressCallback is not None:
|
||||
progressCallback( i + 1, len( filelist ), f, fromCache )
|
||||
|
||||
except IOError, e:
|
||||
self.bb_cache.remove(f)
|
||||
bb.msg.error(bb.msg.domain.Collection, "opening %s: %s" % (f, e))
|
||||
pass
|
||||
except KeyboardInterrupt:
|
||||
self.bb_cache.sync()
|
||||
raise
|
||||
except Exception, e:
|
||||
error += 1
|
||||
self.bb_cache.remove(f)
|
||||
bb.msg.error(bb.msg.domain.Collection, "%s while parsing %s" % (e, f))
|
||||
except:
|
||||
self.bb_cache.remove(f)
|
||||
raise
|
||||
|
||||
if progressCallback is not None:
|
||||
print "\r" # need newline after Handling Bitbake files message
|
||||
bb.msg.note(1, bb.msg.domain.Collection, "Parsing finished. %d cached, %d parsed, %d skipped, %d masked." % ( cached, parsed, skipped, masked ))
|
||||
|
||||
self.bb_cache.sync()
|
||||
|
||||
if error > 0:
|
||||
bb.msg.fatal(bb.msg.domain.Collection, "Parsing errors found, exiting...")
|
||||
556
bitbake/lib/bb/data.py
Normal file
556
bitbake/lib/bb/data.py
Normal file
@@ -0,0 +1,556 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake 'Data' implementations
|
||||
|
||||
Functions for interacting with the data structure used by the
|
||||
BitBake build tools.
|
||||
|
||||
The expandData and update_data are the most expensive
|
||||
operations. At night the cookie monster came by and
|
||||
suggested 'give me cookies on setting the variables and
|
||||
things will work out'. Taking this suggestion into account
|
||||
applying the skills from the not yet passed 'Entwurf und
|
||||
Analyse von Algorithmen' lecture and the cookie
|
||||
monster seems to be right. We will track setVar more carefully
|
||||
to have faster update_data and expandKeys operations.
|
||||
|
||||
This is a treade-off between speed and memory again but
|
||||
the speed is more critical here.
|
||||
"""
|
||||
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
# Copyright (C) 2005 Holger Hans Peter Freyther
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
#Based on functions from the base bb module, Copyright 2003 Holger Schurig
|
||||
|
||||
import sys, os, re, time, types
|
||||
if sys.argv[0][-5:] == "pydoc":
|
||||
path = os.path.dirname(os.path.dirname(sys.argv[1]))
|
||||
else:
|
||||
path = os.path.dirname(os.path.dirname(sys.argv[0]))
|
||||
sys.path.insert(0,path)
|
||||
|
||||
from bb import data_smart
|
||||
import bb
|
||||
|
||||
_dict_type = data_smart.DataSmart
|
||||
|
||||
def init():
|
||||
return _dict_type()
|
||||
|
||||
def init_db(parent = None):
|
||||
if parent:
|
||||
return parent.createCopy()
|
||||
else:
|
||||
return _dict_type()
|
||||
|
||||
def createCopy(source):
|
||||
"""Link the source set to the destination
|
||||
If one does not find the value in the destination set,
|
||||
search will go on to the source set to get the value.
|
||||
Value from source are copy-on-write. i.e. any try to
|
||||
modify one of them will end up putting the modified value
|
||||
in the destination set.
|
||||
"""
|
||||
return source.createCopy()
|
||||
|
||||
def initVar(var, d):
|
||||
"""Non-destructive var init for data structure"""
|
||||
d.initVar(var)
|
||||
|
||||
|
||||
def setVar(var, value, d):
|
||||
"""Set a variable to a given value
|
||||
|
||||
Example:
|
||||
>>> d = init()
|
||||
>>> setVar('TEST', 'testcontents', d)
|
||||
>>> print getVar('TEST', d)
|
||||
testcontents
|
||||
"""
|
||||
d.setVar(var,value)
|
||||
|
||||
|
||||
def getVar(var, d, exp = 0):
|
||||
"""Gets the value of a variable
|
||||
|
||||
Example:
|
||||
>>> d = init()
|
||||
>>> setVar('TEST', 'testcontents', d)
|
||||
>>> print getVar('TEST', d)
|
||||
testcontents
|
||||
"""
|
||||
return d.getVar(var,exp)
|
||||
|
||||
def delVar(var, d):
|
||||
"""Removes a variable from the data set
|
||||
|
||||
Example:
|
||||
>>> d = init()
|
||||
>>> setVar('TEST', 'testcontents', d)
|
||||
>>> print getVar('TEST', d)
|
||||
testcontents
|
||||
>>> delVar('TEST', d)
|
||||
>>> print getVar('TEST', d)
|
||||
None
|
||||
"""
|
||||
d.delVar(var)
|
||||
|
||||
def setVarFlag(var, flag, flagvalue, d):
|
||||
"""Set a flag for a given variable to a given value
|
||||
|
||||
Example:
|
||||
>>> d = init()
|
||||
>>> setVarFlag('TEST', 'python', 1, d)
|
||||
>>> print getVarFlag('TEST', 'python', d)
|
||||
1
|
||||
"""
|
||||
d.setVarFlag(var,flag,flagvalue)
|
||||
|
||||
def getVarFlag(var, flag, d):
|
||||
"""Gets given flag from given var
|
||||
|
||||
Example:
|
||||
>>> d = init()
|
||||
>>> setVarFlag('TEST', 'python', 1, d)
|
||||
>>> print getVarFlag('TEST', 'python', d)
|
||||
1
|
||||
"""
|
||||
return d.getVarFlag(var,flag)
|
||||
|
||||
def delVarFlag(var, flag, d):
|
||||
"""Removes a given flag from the variable's flags
|
||||
|
||||
Example:
|
||||
>>> d = init()
|
||||
>>> setVarFlag('TEST', 'testflag', 1, d)
|
||||
>>> print getVarFlag('TEST', 'testflag', d)
|
||||
1
|
||||
>>> delVarFlag('TEST', 'testflag', d)
|
||||
>>> print getVarFlag('TEST', 'testflag', d)
|
||||
None
|
||||
|
||||
"""
|
||||
d.delVarFlag(var,flag)
|
||||
|
||||
def setVarFlags(var, flags, d):
|
||||
"""Set the flags for a given variable
|
||||
|
||||
Note:
|
||||
setVarFlags will not clear previous
|
||||
flags. Think of this method as
|
||||
addVarFlags
|
||||
|
||||
Example:
|
||||
>>> d = init()
|
||||
>>> myflags = {}
|
||||
>>> myflags['test'] = 'blah'
|
||||
>>> setVarFlags('TEST', myflags, d)
|
||||
>>> print getVarFlag('TEST', 'test', d)
|
||||
blah
|
||||
"""
|
||||
d.setVarFlags(var,flags)
|
||||
|
||||
def getVarFlags(var, d):
|
||||
"""Gets a variable's flags
|
||||
|
||||
Example:
|
||||
>>> d = init()
|
||||
>>> setVarFlag('TEST', 'test', 'blah', d)
|
||||
>>> print getVarFlags('TEST', d)['test']
|
||||
blah
|
||||
"""
|
||||
return d.getVarFlags(var)
|
||||
|
||||
def delVarFlags(var, d):
|
||||
"""Removes a variable's flags
|
||||
|
||||
Example:
|
||||
>>> data = init()
|
||||
>>> setVarFlag('TEST', 'testflag', 1, data)
|
||||
>>> print getVarFlag('TEST', 'testflag', data)
|
||||
1
|
||||
>>> delVarFlags('TEST', data)
|
||||
>>> print getVarFlags('TEST', data)
|
||||
None
|
||||
|
||||
"""
|
||||
d.delVarFlags(var)
|
||||
|
||||
def keys(d):
|
||||
"""Return a list of keys in d
|
||||
|
||||
Example:
|
||||
>>> d = init()
|
||||
>>> setVar('TEST', 1, d)
|
||||
>>> setVar('MOO' , 2, d)
|
||||
>>> setVarFlag('TEST', 'test', 1, d)
|
||||
>>> keys(d)
|
||||
['TEST', 'MOO']
|
||||
"""
|
||||
return d.keys()
|
||||
|
||||
def getData(d):
|
||||
"""Returns the data object used"""
|
||||
return d
|
||||
|
||||
def setData(newData, d):
|
||||
"""Sets the data object to the supplied value"""
|
||||
d = newData
|
||||
|
||||
|
||||
##
|
||||
## Cookie Monsters' query functions
|
||||
##
|
||||
def _get_override_vars(d, override):
|
||||
"""
|
||||
Internal!!!
|
||||
|
||||
Get the Names of Variables that have a specific
|
||||
override. This function returns a iterable
|
||||
Set or an empty list
|
||||
"""
|
||||
return []
|
||||
|
||||
def _get_var_flags_triple(d):
|
||||
"""
|
||||
Internal!!!
|
||||
|
||||
"""
|
||||
return []
|
||||
|
||||
__expand_var_regexp__ = re.compile(r"\${[^{}]+}")
|
||||
__expand_python_regexp__ = re.compile(r"\${@.+?}")
|
||||
|
||||
def expand(s, d, varname = None):
|
||||
"""Variable expansion using the data store.
|
||||
|
||||
Example:
|
||||
Standard expansion:
|
||||
>>> d = init()
|
||||
>>> setVar('A', 'sshd', d)
|
||||
>>> print expand('/usr/bin/${A}', d)
|
||||
/usr/bin/sshd
|
||||
|
||||
Python expansion:
|
||||
>>> d = init()
|
||||
>>> print expand('result: ${@37 * 72}', d)
|
||||
result: 2664
|
||||
|
||||
Shell expansion:
|
||||
>>> d = init()
|
||||
>>> print expand('${TARGET_MOO}', d)
|
||||
${TARGET_MOO}
|
||||
>>> setVar('TARGET_MOO', 'yupp', d)
|
||||
>>> print expand('${TARGET_MOO}',d)
|
||||
yupp
|
||||
>>> setVar('SRC_URI', 'http://somebug.${TARGET_MOO}', d)
|
||||
>>> delVar('TARGET_MOO', d)
|
||||
>>> print expand('${SRC_URI}', d)
|
||||
http://somebug.${TARGET_MOO}
|
||||
"""
|
||||
return d.expand(s, varname)
|
||||
|
||||
def expandKeys(alterdata, readdata = None):
|
||||
if readdata == None:
|
||||
readdata = alterdata
|
||||
|
||||
for key in keys(alterdata):
|
||||
if not '${' in key:
|
||||
continue
|
||||
|
||||
ekey = expand(key, readdata)
|
||||
if key == ekey:
|
||||
continue
|
||||
val = getVar(key, alterdata)
|
||||
if val is None:
|
||||
continue
|
||||
# import copy
|
||||
# setVarFlags(ekey, copy.copy(getVarFlags(key, readdata)), alterdata)
|
||||
setVar(ekey, val, alterdata)
|
||||
|
||||
for i in ('_append', '_prepend'):
|
||||
dest = getVarFlag(ekey, i, alterdata) or []
|
||||
src = getVarFlag(key, i, readdata) or []
|
||||
dest.extend(src)
|
||||
setVarFlag(ekey, i, dest, alterdata)
|
||||
|
||||
delVar(key, alterdata)
|
||||
|
||||
def expandData(alterdata, readdata = None):
|
||||
"""For each variable in alterdata, expand it, and update the var contents.
|
||||
Replacements use data from readdata.
|
||||
|
||||
Example:
|
||||
>>> a=init()
|
||||
>>> b=init()
|
||||
>>> setVar("dlmsg", "dl_dir is ${DL_DIR}", a)
|
||||
>>> setVar("DL_DIR", "/path/to/whatever", b)
|
||||
>>> expandData(a, b)
|
||||
>>> print getVar("dlmsg", a)
|
||||
dl_dir is /path/to/whatever
|
||||
"""
|
||||
if readdata == None:
|
||||
readdata = alterdata
|
||||
|
||||
for key in keys(alterdata):
|
||||
val = getVar(key, alterdata)
|
||||
if type(val) is not types.StringType:
|
||||
continue
|
||||
expanded = expand(val, readdata)
|
||||
# print "key is %s, val is %s, expanded is %s" % (key, val, expanded)
|
||||
if val != expanded:
|
||||
setVar(key, expanded, alterdata)
|
||||
|
||||
import os
|
||||
|
||||
def inheritFromOS(d):
|
||||
"""Inherit variables from the environment."""
|
||||
# fakeroot needs to be able to set these
|
||||
non_inherit_vars = [ "LD_LIBRARY_PATH", "LD_PRELOAD" ]
|
||||
for s in os.environ.keys():
|
||||
if not s in non_inherit_vars:
|
||||
try:
|
||||
setVar(s, os.environ[s], d)
|
||||
setVarFlag(s, 'matchesenv', '1', d)
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
import sys
|
||||
|
||||
def emit_var(var, o=sys.__stdout__, d = init(), all=False):
|
||||
"""Emit a variable to be sourced by a shell."""
|
||||
if getVarFlag(var, "python", d):
|
||||
return 0
|
||||
|
||||
try:
|
||||
if all:
|
||||
oval = getVar(var, d, 0)
|
||||
val = getVar(var, d, 1)
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except:
|
||||
excname = str(sys.exc_info()[0])
|
||||
if excname == "bb.build.FuncFailed":
|
||||
raise
|
||||
o.write('# expansion of %s threw %s\n' % (var, excname))
|
||||
return 0
|
||||
|
||||
if all:
|
||||
o.write('# %s=%s\n' % (var, oval))
|
||||
|
||||
if type(val) is not types.StringType:
|
||||
return 0
|
||||
|
||||
if getVarFlag(var, 'matchesenv', d):
|
||||
return 0
|
||||
|
||||
if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all:
|
||||
return 0
|
||||
|
||||
val.rstrip()
|
||||
if not val:
|
||||
return 0
|
||||
|
||||
varExpanded = expand(var, d)
|
||||
|
||||
if getVarFlag(var, "func", d):
|
||||
# NOTE: should probably check for unbalanced {} within the var
|
||||
o.write("%s() {\n%s\n}\n" % (varExpanded, val))
|
||||
else:
|
||||
if getVarFlag(var, "unexport", d):
|
||||
o.write('unset %s\n' % varExpanded)
|
||||
return 1
|
||||
if getVarFlag(var, "export", d):
|
||||
o.write('export ')
|
||||
else:
|
||||
if not all:
|
||||
return 0
|
||||
# if we're going to output this within doublequotes,
|
||||
# to a shell, we need to escape the quotes in the var
|
||||
alter = re.sub('"', '\\"', val.strip())
|
||||
o.write('%s="%s"\n' % (varExpanded, alter))
|
||||
return 1
|
||||
|
||||
|
||||
def emit_env(o=sys.__stdout__, d = init(), all=False):
|
||||
"""Emits all items in the data store in a format such that it can be sourced by a shell."""
|
||||
|
||||
env = keys(d)
|
||||
|
||||
for e in env:
|
||||
if getVarFlag(e, "func", d):
|
||||
continue
|
||||
emit_var(e, o, d, all) and o.write('\n')
|
||||
|
||||
for e in env:
|
||||
if not getVarFlag(e, "func", d):
|
||||
continue
|
||||
emit_var(e, o, d) and o.write('\n')
|
||||
|
||||
def update_data(d):
|
||||
"""Modifies the environment vars according to local overrides and commands.
|
||||
Examples:
|
||||
Appending to a variable:
|
||||
>>> d = init()
|
||||
>>> setVar('TEST', 'this is a', d)
|
||||
>>> setVar('TEST_append', ' test', d)
|
||||
>>> setVar('TEST_append', ' of the emergency broadcast system.', d)
|
||||
>>> update_data(d)
|
||||
>>> print getVar('TEST', d)
|
||||
this is a test of the emergency broadcast system.
|
||||
|
||||
Prepending to a variable:
|
||||
>>> setVar('TEST', 'virtual/libc', d)
|
||||
>>> setVar('TEST_prepend', 'virtual/tmake ', d)
|
||||
>>> setVar('TEST_prepend', 'virtual/patcher ', d)
|
||||
>>> update_data(d)
|
||||
>>> print getVar('TEST', d)
|
||||
virtual/patcher virtual/tmake virtual/libc
|
||||
|
||||
Overrides:
|
||||
>>> setVar('TEST_arm', 'target', d)
|
||||
>>> setVar('TEST_ramses', 'machine', d)
|
||||
>>> setVar('TEST_local', 'local', d)
|
||||
>>> setVar('OVERRIDES', 'arm', d)
|
||||
|
||||
>>> setVar('TEST', 'original', d)
|
||||
>>> update_data(d)
|
||||
>>> print getVar('TEST', d)
|
||||
target
|
||||
|
||||
>>> setVar('OVERRIDES', 'arm:ramses:local', d)
|
||||
>>> setVar('TEST', 'original', d)
|
||||
>>> update_data(d)
|
||||
>>> print getVar('TEST', d)
|
||||
local
|
||||
|
||||
CopyMonster:
|
||||
>>> e = d.createCopy()
|
||||
>>> setVar('TEST_foo', 'foo', e)
|
||||
>>> update_data(e)
|
||||
>>> print getVar('TEST', e)
|
||||
local
|
||||
|
||||
>>> setVar('OVERRIDES', 'arm:ramses:local:foo', e)
|
||||
>>> update_data(e)
|
||||
>>> print getVar('TEST', e)
|
||||
foo
|
||||
|
||||
>>> f = d.createCopy()
|
||||
>>> setVar('TEST_moo', 'something', f)
|
||||
>>> setVar('OVERRIDES', 'moo:arm:ramses:local:foo', e)
|
||||
>>> update_data(e)
|
||||
>>> print getVar('TEST', e)
|
||||
foo
|
||||
|
||||
|
||||
>>> h = init()
|
||||
>>> setVar('SRC_URI', 'file://append.foo;patch=1 ', h)
|
||||
>>> g = h.createCopy()
|
||||
>>> setVar('SRC_URI_append_arm', 'file://other.foo;patch=1', g)
|
||||
>>> setVar('OVERRIDES', 'arm:moo', g)
|
||||
>>> update_data(g)
|
||||
>>> print getVar('SRC_URI', g)
|
||||
file://append.foo;patch=1 file://other.foo;patch=1
|
||||
|
||||
"""
|
||||
bb.msg.debug(2, bb.msg.domain.Data, "update_data()")
|
||||
|
||||
# now ask the cookie monster for help
|
||||
#print "Cookie Monster"
|
||||
#print "Append/Prepend %s" % d._special_values
|
||||
#print "Overrides %s" % d._seen_overrides
|
||||
|
||||
overrides = (getVar('OVERRIDES', d, 1) or "").split(':') or []
|
||||
|
||||
#
|
||||
# Well let us see what breaks here. We used to iterate
|
||||
# over each variable and apply the override and then
|
||||
# do the line expanding.
|
||||
# If we have bad luck - which we will have - the keys
|
||||
# where in some order that is so important for this
|
||||
# method which we don't have anymore.
|
||||
# Anyway we will fix that and write test cases this
|
||||
# time.
|
||||
|
||||
#
|
||||
# First we apply all overrides
|
||||
# Then we will handle _append and _prepend
|
||||
#
|
||||
|
||||
for o in overrides:
|
||||
# calculate '_'+override
|
||||
l = len(o)+1
|
||||
|
||||
# see if one should even try
|
||||
if not d._seen_overrides.has_key(o):
|
||||
continue
|
||||
|
||||
vars = d._seen_overrides[o]
|
||||
for var in vars:
|
||||
name = var[:-l]
|
||||
try:
|
||||
d[name] = d[var]
|
||||
except:
|
||||
bb.msg.note(1, bb.msg.domain.Data, "Untracked delVar")
|
||||
|
||||
# now on to the appends and prepends
|
||||
if d._special_values.has_key('_append'):
|
||||
appends = d._special_values['_append'] or []
|
||||
for append in appends:
|
||||
for (a, o) in getVarFlag(append, '_append', d) or []:
|
||||
# maybe the OVERRIDE was not yet added so keep the append
|
||||
if (o and o in overrides) or not o:
|
||||
delVarFlag(append, '_append', d)
|
||||
if o and not o in overrides:
|
||||
continue
|
||||
|
||||
sval = getVar(append,d) or ""
|
||||
sval+=a
|
||||
setVar(append, sval, d)
|
||||
|
||||
|
||||
if d._special_values.has_key('_prepend'):
|
||||
prepends = d._special_values['_prepend'] or []
|
||||
|
||||
for prepend in prepends:
|
||||
for (a, o) in getVarFlag(prepend, '_prepend', d) or []:
|
||||
# maybe the OVERRIDE was not yet added so keep the prepend
|
||||
if (o and o in overrides) or not o:
|
||||
delVarFlag(prepend, '_prepend', d)
|
||||
if o and not o in overrides:
|
||||
continue
|
||||
|
||||
sval = a + (getVar(prepend,d) or "")
|
||||
setVar(prepend, sval, d)
|
||||
|
||||
|
||||
def inherits_class(klass, d):
|
||||
val = getVar('__inherit_cache', d) or []
|
||||
if os.path.join('classes', '%s.bbclass' % klass) in val:
|
||||
return True
|
||||
return False
|
||||
|
||||
def _test():
|
||||
"""Start a doctest run on this module"""
|
||||
import doctest
|
||||
from bb import data
|
||||
doctest.testmod(data)
|
||||
|
||||
if __name__ == "__main__":
|
||||
_test()
|
||||
270
bitbake/lib/bb/data_smart.py
Normal file
270
bitbake/lib/bb/data_smart.py
Normal file
@@ -0,0 +1,270 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake Smart Dictionary Implementation
|
||||
|
||||
Functions for interacting with the data structure used by the
|
||||
BitBake build tools.
|
||||
|
||||
"""
|
||||
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
# Copyright (C) 2004, 2005 Seb Frankengul
|
||||
# Copyright (C) 2005, 2006 Holger Hans Peter Freyther
|
||||
# Copyright (C) 2005 Uli Luckas
|
||||
# Copyright (C) 2005 ROAD GmbH
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
# Based on functions from the base bb module, Copyright 2003 Holger Schurig
|
||||
|
||||
import copy, os, re, sys, time, types
|
||||
import bb
|
||||
from bb import utils, methodpool
|
||||
from COW import COWDictBase
|
||||
from sets import Set
|
||||
from new import classobj
|
||||
|
||||
|
||||
__setvar_keyword__ = ["_append","_prepend"]
|
||||
__setvar_regexp__ = re.compile('(?P<base>.*?)(?P<keyword>_append|_prepend)(_(?P<add>.*))?')
|
||||
__expand_var_regexp__ = re.compile(r"\${[^{}]+}")
|
||||
__expand_python_regexp__ = re.compile(r"\${@.+?}")
|
||||
|
||||
|
||||
class DataSmart:
|
||||
def __init__(self, special = COWDictBase.copy(), seen = COWDictBase.copy() ):
|
||||
self.dict = {}
|
||||
|
||||
# cookie monster tribute
|
||||
self._special_values = special
|
||||
self._seen_overrides = seen
|
||||
|
||||
self.expand_cache = {}
|
||||
|
||||
def expand(self,s, varname):
|
||||
def var_sub(match):
|
||||
key = match.group()[2:-1]
|
||||
if varname and key:
|
||||
if varname == key:
|
||||
raise Exception("variable %s references itself!" % varname)
|
||||
var = self.getVar(key, 1)
|
||||
if var is not None:
|
||||
return var
|
||||
else:
|
||||
return match.group()
|
||||
|
||||
def python_sub(match):
|
||||
import bb
|
||||
code = match.group()[3:-1]
|
||||
locals()['d'] = self
|
||||
s = eval(code)
|
||||
if type(s) == types.IntType: s = str(s)
|
||||
return s
|
||||
|
||||
if type(s) is not types.StringType: # sanity check
|
||||
return s
|
||||
|
||||
if varname and varname in self.expand_cache:
|
||||
return self.expand_cache[varname]
|
||||
|
||||
while s.find('${') != -1:
|
||||
olds = s
|
||||
try:
|
||||
s = __expand_var_regexp__.sub(var_sub, s)
|
||||
s = __expand_python_regexp__.sub(python_sub, s)
|
||||
if s == olds: break
|
||||
if type(s) is not types.StringType: # sanity check
|
||||
bb.msg.error(bb.msg.domain.Data, 'expansion of %s returned non-string %s' % (olds, s))
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except:
|
||||
bb.msg.note(1, bb.msg.domain.Data, "%s:%s while evaluating:\n%s" % (sys.exc_info()[0], sys.exc_info()[1], s))
|
||||
raise
|
||||
|
||||
if varname:
|
||||
self.expand_cache[varname] = s
|
||||
|
||||
return s
|
||||
|
||||
def initVar(self, var):
|
||||
self.expand_cache = {}
|
||||
if not var in self.dict:
|
||||
self.dict[var] = {}
|
||||
|
||||
def _findVar(self,var):
|
||||
_dest = self.dict
|
||||
|
||||
while (_dest and var not in _dest):
|
||||
if not "_data" in _dest:
|
||||
_dest = None
|
||||
break
|
||||
_dest = _dest["_data"]
|
||||
|
||||
if _dest and var in _dest:
|
||||
return _dest[var]
|
||||
return None
|
||||
|
||||
def _makeShadowCopy(self, var):
|
||||
if var in self.dict:
|
||||
return
|
||||
|
||||
local_var = self._findVar(var)
|
||||
|
||||
if local_var:
|
||||
self.dict[var] = copy.copy(local_var)
|
||||
else:
|
||||
self.initVar(var)
|
||||
|
||||
def setVar(self,var,value):
|
||||
self.expand_cache = {}
|
||||
match = __setvar_regexp__.match(var)
|
||||
if match and match.group("keyword") in __setvar_keyword__:
|
||||
base = match.group('base')
|
||||
keyword = match.group("keyword")
|
||||
override = match.group('add')
|
||||
l = self.getVarFlag(base, keyword) or []
|
||||
l.append([value, override])
|
||||
self.setVarFlag(base, keyword, l)
|
||||
|
||||
# todo make sure keyword is not __doc__ or __module__
|
||||
# pay the cookie monster
|
||||
try:
|
||||
self._special_values[keyword].add( base )
|
||||
except:
|
||||
self._special_values[keyword] = Set()
|
||||
self._special_values[keyword].add( base )
|
||||
|
||||
return
|
||||
|
||||
if not var in self.dict:
|
||||
self._makeShadowCopy(var)
|
||||
if self.getVarFlag(var, 'matchesenv'):
|
||||
self.delVarFlag(var, 'matchesenv')
|
||||
self.setVarFlag(var, 'export', 1)
|
||||
|
||||
# more cookies for the cookie monster
|
||||
if '_' in var:
|
||||
override = var[var.rfind('_')+1:]
|
||||
if not self._seen_overrides.has_key(override):
|
||||
self._seen_overrides[override] = Set()
|
||||
self._seen_overrides[override].add( var )
|
||||
|
||||
# setting var
|
||||
self.dict[var]["content"] = value
|
||||
|
||||
def getVar(self,var,exp):
|
||||
value = self.getVarFlag(var,"content")
|
||||
|
||||
if exp and value:
|
||||
return self.expand(value,var)
|
||||
return value
|
||||
|
||||
def delVar(self,var):
|
||||
self.expand_cache = {}
|
||||
self.dict[var] = {}
|
||||
|
||||
def setVarFlag(self,var,flag,flagvalue):
|
||||
if not var in self.dict:
|
||||
self._makeShadowCopy(var)
|
||||
self.dict[var][flag] = flagvalue
|
||||
|
||||
def getVarFlag(self,var,flag):
|
||||
local_var = self._findVar(var)
|
||||
if local_var:
|
||||
if flag in local_var:
|
||||
return copy.copy(local_var[flag])
|
||||
return None
|
||||
|
||||
def delVarFlag(self,var,flag):
|
||||
local_var = self._findVar(var)
|
||||
if not local_var:
|
||||
return
|
||||
if not var in self.dict:
|
||||
self._makeShadowCopy(var)
|
||||
|
||||
if var in self.dict and flag in self.dict[var]:
|
||||
del self.dict[var][flag]
|
||||
|
||||
def setVarFlags(self,var,flags):
|
||||
if not var in self.dict:
|
||||
self._makeShadowCopy(var)
|
||||
|
||||
for i in flags.keys():
|
||||
if i == "content":
|
||||
continue
|
||||
self.dict[var][i] = flags[i]
|
||||
|
||||
def getVarFlags(self,var):
|
||||
local_var = self._findVar(var)
|
||||
flags = {}
|
||||
|
||||
if local_var:
|
||||
for i in self.dict[var].keys():
|
||||
if i == "content":
|
||||
continue
|
||||
flags[i] = self.dict[var][i]
|
||||
|
||||
if len(flags) == 0:
|
||||
return None
|
||||
return flags
|
||||
|
||||
|
||||
def delVarFlags(self,var):
|
||||
if not var in self.dict:
|
||||
self._makeShadowCopy(var)
|
||||
|
||||
if var in self.dict:
|
||||
content = None
|
||||
|
||||
# try to save the content
|
||||
if "content" in self.dict[var]:
|
||||
content = self.dict[var]["content"]
|
||||
self.dict[var] = {}
|
||||
self.dict[var]["content"] = content
|
||||
else:
|
||||
del self.dict[var]
|
||||
|
||||
|
||||
def createCopy(self):
|
||||
"""
|
||||
Create a copy of self by setting _data to self
|
||||
"""
|
||||
# we really want this to be a DataSmart...
|
||||
data = DataSmart(seen=self._seen_overrides.copy(), special=self._special_values.copy())
|
||||
data.dict["_data"] = self.dict
|
||||
|
||||
return data
|
||||
|
||||
# Dictionary Methods
|
||||
def keys(self):
|
||||
def _keys(d, mykey):
|
||||
if "_data" in d:
|
||||
_keys(d["_data"],mykey)
|
||||
|
||||
for key in d.keys():
|
||||
if key != "_data":
|
||||
mykey[key] = None
|
||||
keytab = {}
|
||||
_keys(self.dict,keytab)
|
||||
return keytab.keys()
|
||||
|
||||
def __getitem__(self,item):
|
||||
#print "Warning deprecated"
|
||||
return self.getVar(item, False)
|
||||
|
||||
def __setitem__(self,var,data):
|
||||
#print "Warning deprecated"
|
||||
self.setVar(var,data)
|
||||
|
||||
|
||||
264
bitbake/lib/bb/event.py
Normal file
264
bitbake/lib/bb/event.py
Normal file
@@ -0,0 +1,264 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake 'Event' implementation
|
||||
|
||||
Classes and functions for manipulating 'events' in the
|
||||
BitBake build tools.
|
||||
"""
|
||||
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import os, re
|
||||
import bb.utils
|
||||
|
||||
class Event:
|
||||
"""Base class for events"""
|
||||
type = "Event"
|
||||
|
||||
def __init__(self, d):
|
||||
self._data = d
|
||||
|
||||
def getData(self):
|
||||
return self._data
|
||||
|
||||
def setData(self, data):
|
||||
self._data = data
|
||||
|
||||
data = property(getData, setData, None, "data property")
|
||||
|
||||
NotHandled = 0
|
||||
Handled = 1
|
||||
|
||||
Registered = 10
|
||||
AlreadyRegistered = 14
|
||||
|
||||
# Internal
|
||||
_handlers = []
|
||||
_handlers_dict = {}
|
||||
|
||||
def tmpHandler(event):
|
||||
"""Default handler for code events"""
|
||||
return NotHandled
|
||||
|
||||
def defaultTmpHandler():
|
||||
tmp = "def tmpHandler(e):\n\t\"\"\"heh\"\"\"\n\treturn NotHandled"
|
||||
comp = bb.utils.better_compile(tmp, "tmpHandler(e)", "bb.event.defaultTmpHandler")
|
||||
return comp
|
||||
|
||||
def fire(event):
|
||||
"""Fire off an Event"""
|
||||
for h in _handlers:
|
||||
if type(h).__name__ == "code":
|
||||
exec(h)
|
||||
if tmpHandler(event) == Handled:
|
||||
return Handled
|
||||
else:
|
||||
if h(event) == Handled:
|
||||
return Handled
|
||||
return NotHandled
|
||||
|
||||
def register(name, handler):
|
||||
"""Register an Event handler"""
|
||||
|
||||
# already registered
|
||||
if name in _handlers_dict:
|
||||
return AlreadyRegistered
|
||||
|
||||
if handler is not None:
|
||||
# handle string containing python code
|
||||
if type(handler).__name__ == "str":
|
||||
_registerCode(handler)
|
||||
else:
|
||||
_handlers.append(handler)
|
||||
|
||||
_handlers_dict[name] = 1
|
||||
return Registered
|
||||
|
||||
def _registerCode(handlerStr):
|
||||
"""Register a 'code' Event.
|
||||
Deprecated interface; call register instead.
|
||||
|
||||
Expects to be passed python code as a string, which will
|
||||
be passed in turn to compile() and then exec(). Note that
|
||||
the code will be within a function, so should have had
|
||||
appropriate tabbing put in place."""
|
||||
tmp = "def tmpHandler(e):\n%s" % handlerStr
|
||||
comp = bb.utils.better_compile(tmp, "tmpHandler(e)", "bb.event._registerCode")
|
||||
# prevent duplicate registration
|
||||
_handlers.append(comp)
|
||||
|
||||
def remove(name, handler):
|
||||
"""Remove an Event handler"""
|
||||
|
||||
_handlers_dict.pop(name)
|
||||
if type(handler).__name__ == "str":
|
||||
return _removeCode(handler)
|
||||
else:
|
||||
_handlers.remove(handler)
|
||||
|
||||
def _removeCode(handlerStr):
|
||||
"""Remove a 'code' Event handler
|
||||
Deprecated interface; call remove instead."""
|
||||
tmp = "def tmpHandler(e):\n%s" % handlerStr
|
||||
comp = bb.utils.better_compile(tmp, "tmpHandler(e)", "bb.event._removeCode")
|
||||
_handlers.remove(comp)
|
||||
|
||||
def getName(e):
|
||||
"""Returns the name of a class or class instance"""
|
||||
if getattr(e, "__name__", None) == None:
|
||||
return e.__class__.__name__
|
||||
else:
|
||||
return e.__name__
|
||||
|
||||
|
||||
class PkgBase(Event):
|
||||
"""Base class for package events"""
|
||||
|
||||
def __init__(self, t, d):
|
||||
self._pkg = t
|
||||
Event.__init__(self, d)
|
||||
|
||||
def getPkg(self):
|
||||
return self._pkg
|
||||
|
||||
def setPkg(self, pkg):
|
||||
self._pkg = pkg
|
||||
|
||||
pkg = property(getPkg, setPkg, None, "pkg property")
|
||||
|
||||
|
||||
class BuildBase(Event):
|
||||
"""Base class for bbmake run events"""
|
||||
|
||||
def __init__(self, n, p, c, failures = 0):
|
||||
self._name = n
|
||||
self._pkgs = p
|
||||
Event.__init__(self, c)
|
||||
self._failures = failures
|
||||
|
||||
def getPkgs(self):
|
||||
return self._pkgs
|
||||
|
||||
def setPkgs(self, pkgs):
|
||||
self._pkgs = pkgs
|
||||
|
||||
def getName(self):
|
||||
return self._name
|
||||
|
||||
def setName(self, name):
|
||||
self._name = name
|
||||
|
||||
def getCfg(self):
|
||||
return self.data
|
||||
|
||||
def setCfg(self, cfg):
|
||||
self.data = cfg
|
||||
|
||||
def getFailures(self):
|
||||
"""
|
||||
Return the number of failed packages
|
||||
"""
|
||||
return self._failures
|
||||
|
||||
pkgs = property(getPkgs, setPkgs, None, "pkgs property")
|
||||
name = property(getName, setName, None, "name property")
|
||||
cfg = property(getCfg, setCfg, None, "cfg property")
|
||||
|
||||
|
||||
class DepBase(PkgBase):
|
||||
"""Base class for dependency events"""
|
||||
|
||||
def __init__(self, t, data, d):
|
||||
self._dep = d
|
||||
PkgBase.__init__(self, t, data)
|
||||
|
||||
def getDep(self):
|
||||
return self._dep
|
||||
|
||||
def setDep(self, dep):
|
||||
self._dep = dep
|
||||
|
||||
dep = property(getDep, setDep, None, "dep property")
|
||||
|
||||
|
||||
class PkgStarted(PkgBase):
|
||||
"""Package build started"""
|
||||
|
||||
|
||||
class PkgFailed(PkgBase):
|
||||
"""Package build failed"""
|
||||
|
||||
|
||||
class PkgSucceeded(PkgBase):
|
||||
"""Package build completed"""
|
||||
|
||||
|
||||
class BuildStarted(BuildBase):
|
||||
"""bbmake build run started"""
|
||||
|
||||
|
||||
class BuildCompleted(BuildBase):
|
||||
"""bbmake build run completed"""
|
||||
|
||||
|
||||
class UnsatisfiedDep(DepBase):
|
||||
"""Unsatisfied Dependency"""
|
||||
|
||||
|
||||
class RecursiveDep(DepBase):
|
||||
"""Recursive Dependency"""
|
||||
|
||||
class NoProvider(Event):
|
||||
"""No Provider for an Event"""
|
||||
|
||||
def __init__(self, item, data,runtime=False):
|
||||
Event.__init__(self, data)
|
||||
self._item = item
|
||||
self._runtime = runtime
|
||||
|
||||
def getItem(self):
|
||||
return self._item
|
||||
|
||||
def isRuntime(self):
|
||||
return self._runtime
|
||||
|
||||
class MultipleProviders(Event):
|
||||
"""Multiple Providers"""
|
||||
|
||||
def __init__(self, item, candidates, data, runtime = False):
|
||||
Event.__init__(self, data)
|
||||
self._item = item
|
||||
self._candidates = candidates
|
||||
self._is_runtime = runtime
|
||||
|
||||
def isRuntime(self):
|
||||
"""
|
||||
Is this a runtime issue?
|
||||
"""
|
||||
return self._is_runtime
|
||||
|
||||
def getItem(self):
|
||||
"""
|
||||
The name for the to be build item
|
||||
"""
|
||||
return self._item
|
||||
|
||||
def getCandidates(self):
|
||||
"""
|
||||
Get the possible Candidates for a PROVIDER.
|
||||
"""
|
||||
return self._candidates
|
||||
288
bitbake/lib/bb/fetch/__init__.py
Normal file
288
bitbake/lib/bb/fetch/__init__.py
Normal file
@@ -0,0 +1,288 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake 'Fetch' implementations
|
||||
|
||||
Classes for obtaining upstream sources for the
|
||||
BitBake build tools.
|
||||
"""
|
||||
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Based on functions from the base bb module, Copyright 2003 Holger Schurig
|
||||
|
||||
import os, re
|
||||
import bb
|
||||
from bb import data
|
||||
|
||||
class FetchError(Exception):
|
||||
"""Exception raised when a download fails"""
|
||||
|
||||
class NoMethodError(Exception):
|
||||
"""Exception raised when there is no method to obtain a supplied url or set of urls"""
|
||||
|
||||
class MissingParameterError(Exception):
|
||||
"""Exception raised when a fetch method is missing a critical parameter in the url"""
|
||||
|
||||
class ParameterError(Exception):
|
||||
"""Exception raised when a url cannot be proccessed due to invalid parameters."""
|
||||
|
||||
class MD5SumError(Exception):
|
||||
"""Exception raised when a MD5SUM of a file does not match the expected one"""
|
||||
|
||||
def uri_replace(uri, uri_find, uri_replace, d):
|
||||
# bb.msg.note(1, bb.msg.domain.Fetcher, "uri_replace: operating on %s" % uri)
|
||||
if not uri or not uri_find or not uri_replace:
|
||||
bb.msg.debug(1, bb.msg.domain.Fetcher, "uri_replace: passed an undefined value, not replacing")
|
||||
uri_decoded = list(bb.decodeurl(uri))
|
||||
uri_find_decoded = list(bb.decodeurl(uri_find))
|
||||
uri_replace_decoded = list(bb.decodeurl(uri_replace))
|
||||
result_decoded = ['','','','','',{}]
|
||||
for i in uri_find_decoded:
|
||||
loc = uri_find_decoded.index(i)
|
||||
result_decoded[loc] = uri_decoded[loc]
|
||||
import types
|
||||
if type(i) == types.StringType:
|
||||
import re
|
||||
if (re.match(i, uri_decoded[loc])):
|
||||
result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc])
|
||||
if uri_find_decoded.index(i) == 2:
|
||||
if d:
|
||||
localfn = bb.fetch.localpath(uri, d)
|
||||
if localfn:
|
||||
result_decoded[loc] = os.path.dirname(result_decoded[loc]) + "/" + os.path.basename(bb.fetch.localpath(uri, d))
|
||||
# bb.msg.note(1, bb.msg.domain.Fetcher, "uri_replace: matching %s against %s and replacing with %s" % (i, uri_decoded[loc], uri_replace_decoded[loc]))
|
||||
else:
|
||||
# bb.msg.note(1, bb.msg.domain.Fetcher, "uri_replace: no match")
|
||||
return uri
|
||||
# else:
|
||||
# for j in i.keys():
|
||||
# FIXME: apply replacements against options
|
||||
return bb.encodeurl(result_decoded)
|
||||
|
||||
methods = []
|
||||
urldata = {}
|
||||
|
||||
def init(urls = [], d = None):
|
||||
if d == None:
|
||||
bb.msg.debug(2, bb.msg.domain.Fetcher, "BUG init called with None as data object!!!")
|
||||
return
|
||||
|
||||
for m in methods:
|
||||
m.urls = []
|
||||
|
||||
for u in urls:
|
||||
ud = initdata(u, d)
|
||||
if ud.method:
|
||||
ud.method.urls.append(u)
|
||||
|
||||
def initdata(url, d):
|
||||
fn = bb.data.getVar('FILE', d, 1)
|
||||
if fn not in urldata:
|
||||
urldata[fn] = {}
|
||||
if url not in urldata[fn]:
|
||||
ud = FetchData()
|
||||
(ud.type, ud.host, ud.path, ud.user, ud.pswd, ud.parm) = bb.decodeurl(data.expand(url, d))
|
||||
ud.date = Fetch.getSRCDate(ud, d)
|
||||
for m in methods:
|
||||
if m.supports(url, ud, d):
|
||||
ud.localpath = m.localpath(url, ud, d)
|
||||
ud.md5 = ud.localpath + '.md5'
|
||||
# if user sets localpath for file, use it instead.
|
||||
if "localpath" in ud.parm:
|
||||
ud.localpath = ud.parm["localpath"]
|
||||
ud.method = m
|
||||
break
|
||||
urldata[fn][url] = ud
|
||||
return urldata[fn][url]
|
||||
|
||||
def go(d):
|
||||
"""Fetch all urls"""
|
||||
fn = bb.data.getVar('FILE', d, 1)
|
||||
for m in methods:
|
||||
for u in m.urls:
|
||||
ud = urldata[fn][u]
|
||||
if ud.localfile and not m.forcefetch(u, ud, d) and os.path.exists(urldata[fn][u].md5):
|
||||
# File already present along with md5 stamp file
|
||||
# Touch md5 file to show activity
|
||||
os.utime(ud.md5, None)
|
||||
continue
|
||||
# RP - is olddir needed?
|
||||
# olddir = os.path.abspath(os.getcwd())
|
||||
m.go(u, ud , d)
|
||||
# os.chdir(olddir)
|
||||
if ud.localfile and not m.forcefetch(u, ud, d):
|
||||
Fetch.write_md5sum(u, ud, d)
|
||||
|
||||
def localpaths(d):
|
||||
"""Return a list of the local filenames, assuming successful fetch"""
|
||||
local = []
|
||||
fn = bb.data.getVar('FILE', d, 1)
|
||||
for m in methods:
|
||||
for u in m.urls:
|
||||
local.append(urldata[fn][u].localpath)
|
||||
return local
|
||||
|
||||
def localpath(url, d):
|
||||
ud = initdata(url, d)
|
||||
if ud.method:
|
||||
return ud.localpath
|
||||
return url
|
||||
|
||||
class FetchData(object):
|
||||
"""Class for fetcher variable store"""
|
||||
def __init__(self):
|
||||
self.localfile = ""
|
||||
|
||||
|
||||
class Fetch(object):
|
||||
"""Base class for 'fetch'ing data"""
|
||||
|
||||
def __init__(self, urls = []):
|
||||
self.urls = []
|
||||
|
||||
def supports(self, url, urldata, d):
|
||||
"""
|
||||
Check to see if this fetch class supports a given url.
|
||||
"""
|
||||
return 0
|
||||
|
||||
def localpath(self, url, urldata, d):
|
||||
"""
|
||||
Return the local filename of a given url assuming a successful fetch.
|
||||
Can also setup variables in urldata for use in go (saving code duplication
|
||||
and duplicate code execution)
|
||||
"""
|
||||
return url
|
||||
|
||||
def setUrls(self, urls):
|
||||
self.__urls = urls
|
||||
|
||||
def getUrls(self):
|
||||
return self.__urls
|
||||
|
||||
urls = property(getUrls, setUrls, None, "Urls property")
|
||||
|
||||
def forcefetch(self, url, urldata, d):
|
||||
"""
|
||||
Force a fetch, even if localpath exists?
|
||||
"""
|
||||
return False
|
||||
|
||||
def go(self, url, urldata, d):
|
||||
"""
|
||||
Fetch urls
|
||||
Assumes localpath was called first
|
||||
"""
|
||||
raise NoMethodError("Missing implementation for url")
|
||||
|
||||
def getSRCDate(urldata, d):
|
||||
"""
|
||||
Return the SRC Date for the component
|
||||
|
||||
d the bb.data module
|
||||
"""
|
||||
if "srcdate" in urldata.parm:
|
||||
return urldata.parm['srcdate']
|
||||
|
||||
pn = data.getVar("PN", d, 1)
|
||||
|
||||
if pn:
|
||||
return data.getVar("SRCDATE_%s" % pn, d, 1) or data.getVar("CVSDATE_%s" % pn, d, 1) or data.getVar("DATE", d, 1)
|
||||
|
||||
return data.getVar("SRCDATE", d, 1) or data.getVar("CVSDATE", d, 1) or data.getVar("DATE", d, 1)
|
||||
getSRCDate = staticmethod(getSRCDate)
|
||||
|
||||
def try_mirror(d, tarfn):
|
||||
"""
|
||||
Try to use a mirrored version of the sources. We do this
|
||||
to avoid massive loads on foreign cvs and svn servers.
|
||||
This method will be used by the different fetcher
|
||||
implementations.
|
||||
|
||||
d Is a bb.data instance
|
||||
tarfn is the name of the tarball
|
||||
"""
|
||||
tarpath = os.path.join(data.getVar("DL_DIR", d, 1), tarfn)
|
||||
if os.access(tarpath, os.R_OK):
|
||||
bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists, skipping checkout." % tarfn)
|
||||
return True
|
||||
|
||||
pn = data.getVar('PN', d, True)
|
||||
src_tarball_stash = None
|
||||
if pn:
|
||||
src_tarball_stash = (data.getVar('SRC_TARBALL_STASH_%s' % pn, d, True) or data.getVar('CVS_TARBALL_STASH_%s' % pn, d, True) or data.getVar('SRC_TARBALL_STASH', d, True) or data.getVar('CVS_TARBALL_STASH', d, True) or "").split()
|
||||
|
||||
for stash in src_tarball_stash:
|
||||
fetchcmd = data.getVar("FETCHCOMMAND_mirror", d, True) or data.getVar("FETCHCOMMAND_wget", d, True)
|
||||
uri = stash + tarfn
|
||||
bb.msg.note(1, bb.msg.domain.Fetcher, "fetch " + uri)
|
||||
fetchcmd = fetchcmd.replace("${URI}", uri)
|
||||
ret = os.system(fetchcmd)
|
||||
if ret == 0:
|
||||
bb.msg.note(1, bb.msg.domain.Fetcher, "Fetched %s from tarball stash, skipping checkout" % tarfn)
|
||||
return True
|
||||
return False
|
||||
try_mirror = staticmethod(try_mirror)
|
||||
|
||||
def verify_md5sum(ud, got_sum):
|
||||
"""
|
||||
Verify the md5sum we wanted with the one we got
|
||||
"""
|
||||
wanted_sum = None
|
||||
if 'md5sum' in ud.parm:
|
||||
wanted_sum = ud.parm['md5sum']
|
||||
if not wanted_sum:
|
||||
return True
|
||||
|
||||
return wanted_sum == got_sum
|
||||
verify_md5sum = staticmethod(verify_md5sum)
|
||||
|
||||
def write_md5sum(url, ud, d):
|
||||
if bb.which(data.getVar('PATH', d), 'md5sum'):
|
||||
try:
|
||||
md5pipe = os.popen('md5sum ' + ud.localpath)
|
||||
md5data = (md5pipe.readline().split() or [ "" ])[0]
|
||||
md5pipe.close()
|
||||
except OSError:
|
||||
md5data = ""
|
||||
|
||||
# verify the md5sum
|
||||
if not Fetch.verify_md5sum(ud, md5data):
|
||||
raise MD5SumError(url)
|
||||
|
||||
md5out = file(ud.md5, 'w')
|
||||
md5out.write(md5data)
|
||||
md5out.close()
|
||||
write_md5sum = staticmethod(write_md5sum)
|
||||
|
||||
import cvs
|
||||
import git
|
||||
import local
|
||||
import svn
|
||||
import wget
|
||||
import svk
|
||||
import ssh
|
||||
import perforce
|
||||
|
||||
methods.append(cvs.Cvs())
|
||||
methods.append(git.Git())
|
||||
methods.append(local.Local())
|
||||
methods.append(svn.Svn())
|
||||
methods.append(wget.Wget())
|
||||
methods.append(svk.Svk())
|
||||
methods.append(ssh.SSH())
|
||||
methods.append(perforce.Perforce())
|
||||
156
bitbake/lib/bb/fetch/cvs.py
Normal file
156
bitbake/lib/bb/fetch/cvs.py
Normal file
@@ -0,0 +1,156 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake 'Fetch' implementations
|
||||
|
||||
Classes for obtaining upstream sources for the
|
||||
BitBake build tools.
|
||||
|
||||
"""
|
||||
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
#Based on functions from the base bb module, Copyright 2003 Holger Schurig
|
||||
#
|
||||
|
||||
import os, re
|
||||
import bb
|
||||
from bb import data
|
||||
from bb.fetch import Fetch
|
||||
from bb.fetch import FetchError
|
||||
from bb.fetch import MissingParameterError
|
||||
|
||||
class Cvs(Fetch):
|
||||
"""
|
||||
Class to fetch a module or modules from cvs repositories
|
||||
"""
|
||||
def supports(self, url, ud, d):
|
||||
"""
|
||||
Check to see if a given url can be fetched with cvs.
|
||||
"""
|
||||
return ud.type in ['cvs', 'pserver']
|
||||
|
||||
def localpath(self, url, ud, d):
|
||||
if not "module" in ud.parm:
|
||||
raise MissingParameterError("cvs method needs a 'module' parameter")
|
||||
ud.module = ud.parm["module"]
|
||||
|
||||
ud.tag = ""
|
||||
if 'tag' in ud.parm:
|
||||
ud.tag = ud.parm['tag']
|
||||
|
||||
# Override the default date in certain cases
|
||||
if 'date' in ud.parm:
|
||||
ud.date = ud.parm['date']
|
||||
elif ud.tag:
|
||||
ud.date = ""
|
||||
|
||||
ud.localfile = data.expand('%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.tag, ud.date), d)
|
||||
|
||||
return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
|
||||
|
||||
def forcefetch(self, url, ud, d):
|
||||
if (ud.date == "now"):
|
||||
return True
|
||||
return False
|
||||
|
||||
def go(self, loc, ud, d):
|
||||
|
||||
# try to use the tarball stash
|
||||
if not self.forcefetch(loc, ud, d) and Fetch.try_mirror(d, ud.localfile):
|
||||
bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping cvs checkout." % ud.localpath)
|
||||
return
|
||||
|
||||
method = "pserver"
|
||||
if "method" in ud.parm:
|
||||
method = ud.parm["method"]
|
||||
|
||||
localdir = ud.module
|
||||
if "localdir" in ud.parm:
|
||||
localdir = ud.parm["localdir"]
|
||||
|
||||
cvs_port = ""
|
||||
if "port" in ud.parm:
|
||||
cvs_port = ud.parm["port"]
|
||||
|
||||
cvs_rsh = None
|
||||
if method == "ext":
|
||||
if "rsh" in ud.parm:
|
||||
cvs_rsh = ud.parm["rsh"]
|
||||
|
||||
if method == "dir":
|
||||
cvsroot = ud.path
|
||||
else:
|
||||
cvsroot = ":" + method + ":" + ud.user
|
||||
if ud.pswd:
|
||||
cvsroot += ":" + ud.pswd
|
||||
cvsroot += "@" + ud.host + ":" + cvs_port + ud.path
|
||||
|
||||
options = []
|
||||
if ud.date:
|
||||
options.append("-D %s" % ud.date)
|
||||
if ud.tag:
|
||||
options.append("-r %s" % ud.tag)
|
||||
|
||||
localdata = data.createCopy(d)
|
||||
data.setVar('OVERRIDES', "cvs:%s" % data.getVar('OVERRIDES', localdata), localdata)
|
||||
data.update_data(localdata)
|
||||
|
||||
data.setVar('CVSROOT', cvsroot, localdata)
|
||||
data.setVar('CVSCOOPTS', " ".join(options), localdata)
|
||||
data.setVar('CVSMODULE', ud.module, localdata)
|
||||
cvscmd = data.getVar('FETCHCOMMAND', localdata, 1)
|
||||
cvsupdatecmd = data.getVar('UPDATECOMMAND', localdata, 1)
|
||||
|
||||
if cvs_rsh:
|
||||
cvscmd = "CVS_RSH=\"%s\" %s" % (cvs_rsh, cvscmd)
|
||||
cvsupdatecmd = "CVS_RSH=\"%s\" %s" % (cvs_rsh, cvsupdatecmd)
|
||||
|
||||
# create module directory
|
||||
bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: checking for module directory")
|
||||
pkg = data.expand('${PN}', d)
|
||||
pkgdir = os.path.join(data.expand('${CVSDIR}', localdata), pkg)
|
||||
moddir = os.path.join(pkgdir,localdir)
|
||||
if os.access(os.path.join(moddir,'CVS'), os.R_OK):
|
||||
bb.msg.note(1, bb.msg.domain.Fetcher, "Update " + loc)
|
||||
# update sources there
|
||||
os.chdir(moddir)
|
||||
myret = os.system(cvsupdatecmd)
|
||||
else:
|
||||
bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc)
|
||||
# check out sources there
|
||||
bb.mkdirhier(pkgdir)
|
||||
os.chdir(pkgdir)
|
||||
bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % cvscmd)
|
||||
myret = os.system(cvscmd)
|
||||
|
||||
if myret != 0 or not os.access(moddir, os.R_OK):
|
||||
try:
|
||||
os.rmdir(moddir)
|
||||
except OSError:
|
||||
pass
|
||||
raise FetchError(ud.module)
|
||||
|
||||
os.chdir(moddir)
|
||||
os.chdir('..')
|
||||
# tar them up to a defined filename
|
||||
myret = os.system("tar -czf %s %s" % (ud.localpath, os.path.basename(moddir)))
|
||||
if myret != 0:
|
||||
try:
|
||||
os.unlink(ud.localpath)
|
||||
except OSError:
|
||||
pass
|
||||
raise FetchError(ud.module)
|
||||
127
bitbake/lib/bb/fetch/git.py
Normal file
127
bitbake/lib/bb/fetch/git.py
Normal file
@@ -0,0 +1,127 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake 'Fetch' git implementation
|
||||
|
||||
"""
|
||||
|
||||
#Copyright (C) 2005 Richard Purdie
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import os, re
|
||||
import bb
|
||||
from bb import data
|
||||
from bb.fetch import Fetch
|
||||
from bb.fetch import FetchError
|
||||
|
||||
def prunedir(topdir):
|
||||
# Delete everything reachable from the directory named in 'topdir'.
|
||||
# CAUTION: This is dangerous!
|
||||
for root, dirs, files in os.walk(topdir, topdown=False):
|
||||
for name in files:
|
||||
os.remove(os.path.join(root, name))
|
||||
for name in dirs:
|
||||
os.rmdir(os.path.join(root, name))
|
||||
|
||||
def rungitcmd(cmd,d):
|
||||
|
||||
bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % cmd)
|
||||
|
||||
# Need to export PATH as git is likely to be in metadata paths
|
||||
# rather than host provided
|
||||
pathcmd = 'export PATH=%s; %s' % (data.expand('${PATH}', d), cmd)
|
||||
|
||||
myret = os.system(pathcmd)
|
||||
|
||||
if myret != 0:
|
||||
raise FetchError("Git: %s failed" % pathcmd)
|
||||
|
||||
class Git(Fetch):
|
||||
"""Class to fetch a module or modules from git repositories"""
|
||||
def supports(self, url, ud, d):
|
||||
"""
|
||||
Check to see if a given url can be fetched with git.
|
||||
"""
|
||||
return ud.type in ['git']
|
||||
|
||||
def localpath(self, url, ud, d):
|
||||
|
||||
ud.proto = "rsync"
|
||||
if 'protocol' in ud.parm:
|
||||
ud.proto = ud.parm['protocol']
|
||||
|
||||
ud.tag = "master"
|
||||
if 'tag' in ud.parm:
|
||||
ud.tag = ud.parm['tag']
|
||||
|
||||
ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.tag), d)
|
||||
|
||||
return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
|
||||
|
||||
def forcefetch(self, url, ud, d):
|
||||
# tag=="master" must always update
|
||||
if (ud.tag == "master"):
|
||||
return True
|
||||
return False
|
||||
|
||||
def go(self, loc, ud, d):
|
||||
"""Fetch url"""
|
||||
|
||||
if not self.forcefetch(loc, ud, d) and Fetch.try_mirror(d, ud.localfile):
|
||||
bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists (or was stashed). Skipping git checkout." % ud.localpath)
|
||||
return
|
||||
|
||||
gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.'))
|
||||
|
||||
repofilename = 'git_%s.tar.gz' % (gitsrcname)
|
||||
repofile = os.path.join(data.getVar("DL_DIR", d, 1), repofilename)
|
||||
repodir = os.path.join(data.expand('${GITDIR}', d), gitsrcname)
|
||||
|
||||
coname = '%s' % (ud.tag)
|
||||
codir = os.path.join(repodir, coname)
|
||||
|
||||
if not os.path.exists(repodir):
|
||||
if Fetch.try_mirror(d, repofilename):
|
||||
bb.mkdirhier(repodir)
|
||||
os.chdir(repodir)
|
||||
rungitcmd("tar -xzf %s" % (repofile),d)
|
||||
else:
|
||||
rungitcmd("git clone -n %s://%s%s %s" % (ud.proto, ud.host, ud.path, repodir),d)
|
||||
|
||||
os.chdir(repodir)
|
||||
rungitcmd("git pull %s://%s%s" % (ud.proto, ud.host, ud.path),d)
|
||||
rungitcmd("git pull --tags %s://%s%s" % (ud.proto, ud.host, ud.path),d)
|
||||
rungitcmd("git prune-packed", d)
|
||||
rungitcmd("git pack-redundant --all | xargs -r rm", d)
|
||||
# Remove all but the .git directory
|
||||
rungitcmd("rm * -Rf", d)
|
||||
# old method of downloading tags
|
||||
#rungitcmd("rsync -a --verbose --stats --progress rsync://%s%s/ %s" % (ud.host, ud.path, os.path.join(repodir, ".git", "")),d)
|
||||
|
||||
os.chdir(repodir)
|
||||
bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git repository")
|
||||
rungitcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ),d)
|
||||
|
||||
if os.path.exists(codir):
|
||||
prunedir(codir)
|
||||
|
||||
bb.mkdirhier(codir)
|
||||
os.chdir(repodir)
|
||||
rungitcmd("git read-tree %s" % (ud.tag),d)
|
||||
rungitcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")),d)
|
||||
|
||||
os.chdir(codir)
|
||||
bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git checkout")
|
||||
rungitcmd("tar -czf %s %s" % (ud.localpath, os.path.join(".", "*") ),d)
|
||||
59
bitbake/lib/bb/fetch/local.py
Normal file
59
bitbake/lib/bb/fetch/local.py
Normal file
@@ -0,0 +1,59 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake 'Fetch' implementations
|
||||
|
||||
Classes for obtaining upstream sources for the
|
||||
BitBake build tools.
|
||||
|
||||
"""
|
||||
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Based on functions from the base bb module, Copyright 2003 Holger Schurig
|
||||
|
||||
import os, re
|
||||
import bb
|
||||
from bb import data
|
||||
from bb.fetch import Fetch
|
||||
|
||||
class Local(Fetch):
|
||||
def supports(self, url, urldata, d):
|
||||
"""
|
||||
Check to see if a given url can be fetched with cvs.
|
||||
"""
|
||||
return urldata.type in ['file','patch']
|
||||
|
||||
def localpath(self, url, urldata, d):
|
||||
"""Return the local filename of a given url assuming a successful fetch.
|
||||
"""
|
||||
path = url.split("://")[1]
|
||||
newpath = path
|
||||
if path[0] != "/":
|
||||
filespath = data.getVar('FILESPATH', d, 1)
|
||||
if filespath:
|
||||
newpath = bb.which(filespath, path)
|
||||
if not newpath:
|
||||
filesdir = data.getVar('FILESDIR', d, 1)
|
||||
if filesdir:
|
||||
newpath = os.path.join(filesdir, path)
|
||||
# We don't set localfile as for this fetcher the file is already local!
|
||||
return newpath
|
||||
|
||||
def go(self, url, urldata, d):
|
||||
"""Fetch urls (no-op for Local method)"""
|
||||
# no need to fetch local files, we'll deal with them in place.
|
||||
return 1
|
||||
213
bitbake/lib/bb/fetch/perforce.py
Normal file
213
bitbake/lib/bb/fetch/perforce.py
Normal file
@@ -0,0 +1,213 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake 'Fetch' implementations
|
||||
|
||||
Classes for obtaining upstream sources for the
|
||||
BitBake build tools.
|
||||
|
||||
"""
|
||||
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Based on functions from the base bb module, Copyright 2003 Holger Schurig
|
||||
|
||||
import os, re
|
||||
import bb
|
||||
from bb import data
|
||||
from bb.fetch import Fetch
|
||||
from bb.fetch import FetchError
|
||||
from bb.fetch import MissingParameterError
|
||||
|
||||
class Perforce(Fetch):
|
||||
def supports(self, url, ud, d):
|
||||
return ud.type in ['p4']
|
||||
|
||||
def doparse(url,d):
|
||||
parm=[]
|
||||
path = url.split("://")[1]
|
||||
delim = path.find("@");
|
||||
if delim != -1:
|
||||
(user,pswd,host,port) = path.split('@')[0].split(":")
|
||||
path = path.split('@')[1]
|
||||
else:
|
||||
(host,port) = data.getVar('P4PORT', d).split(':')
|
||||
user = ""
|
||||
pswd = ""
|
||||
|
||||
if path.find(";") != -1:
|
||||
keys=[]
|
||||
values=[]
|
||||
plist = path.split(';')
|
||||
for item in plist:
|
||||
if item.count('='):
|
||||
(key,value) = item.split('=')
|
||||
keys.append(key)
|
||||
values.append(value)
|
||||
|
||||
parm = dict(zip(keys,values))
|
||||
path = "//" + path.split(';')[0]
|
||||
host += ":%s" % (port)
|
||||
parm["cset"] = Perforce.getcset(d, path, host, user, pswd, parm)
|
||||
|
||||
return host,path,user,pswd,parm
|
||||
doparse = staticmethod(doparse)
|
||||
|
||||
def getcset(d, depot,host,user,pswd,parm):
|
||||
if "cset" in parm:
|
||||
return parm["cset"];
|
||||
if user:
|
||||
data.setVar('P4USER', user, d)
|
||||
if pswd:
|
||||
data.setVar('P4PASSWD', pswd, d)
|
||||
if host:
|
||||
data.setVar('P4PORT', host, d)
|
||||
|
||||
p4date = data.getVar("P4DATE", d, 1)
|
||||
if "revision" in parm:
|
||||
depot += "#%s" % (parm["revision"])
|
||||
elif "label" in parm:
|
||||
depot += "@%s" % (parm["label"])
|
||||
elif p4date:
|
||||
depot += "@%s" % (p4date)
|
||||
|
||||
p4cmd = data.getVar('FETCHCOMMAND_p4', d, 1)
|
||||
bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s changes -m 1 %s" % (p4cmd, depot))
|
||||
p4file = os.popen("%s changes -m 1 %s" % (p4cmd,depot))
|
||||
cset = p4file.readline().strip()
|
||||
bb.msg.debug(1, bb.msg.domain.Fetcher, "READ %s" % (cset))
|
||||
if not cset:
|
||||
return -1
|
||||
|
||||
return cset.split(' ')[1]
|
||||
getcset = staticmethod(getcset)
|
||||
|
||||
def localpath(self, url, ud, d):
|
||||
|
||||
(host,path,user,pswd,parm) = Perforce.doparse(url,d)
|
||||
|
||||
# If a label is specified, we use that as our filename
|
||||
|
||||
if "label" in parm:
|
||||
ud.localfile = "%s.tar.gz" % (parm["label"])
|
||||
return os.path.join(data.getVar("DL_DIR", d, 1), ud.localfile)
|
||||
|
||||
base = path
|
||||
which = path.find('/...')
|
||||
if which != -1:
|
||||
base = path[:which]
|
||||
|
||||
if base[0] == "/":
|
||||
base = base[1:]
|
||||
|
||||
cset = Perforce.getcset(d, path, host, user, pswd, parm)
|
||||
|
||||
ud.localfile = data.expand('%s+%s+%s.tar.gz' % (host,base.replace('/', '.'), cset), d)
|
||||
|
||||
return os.path.join(data.getVar("DL_DIR", d, 1), ud.localfile)
|
||||
|
||||
def go(self, loc, ud, d):
|
||||
"""
|
||||
Fetch urls
|
||||
"""
|
||||
|
||||
# try to use the tarball stash
|
||||
if not self.forcefetch(loc, ud, d) and Fetch.try_mirror(d, ud.localfile):
|
||||
bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping perforce checkout." % ud.localpath)
|
||||
return
|
||||
|
||||
(host,depot,user,pswd,parm) = Perforce.doparse(loc, d)
|
||||
|
||||
if depot.find('/...') != -1:
|
||||
path = depot[:depot.find('/...')]
|
||||
else:
|
||||
path = depot
|
||||
|
||||
if "module" in parm:
|
||||
module = parm["module"]
|
||||
else:
|
||||
module = os.path.basename(path)
|
||||
|
||||
localdata = data.createCopy(d)
|
||||
data.setVar('OVERRIDES', "p4:%s" % data.getVar('OVERRIDES', localdata), localdata)
|
||||
data.update_data(localdata)
|
||||
|
||||
# Get the p4 command
|
||||
if user:
|
||||
data.setVar('P4USER', user, localdata)
|
||||
|
||||
if pswd:
|
||||
data.setVar('P4PASSWD', pswd, localdata)
|
||||
|
||||
if host:
|
||||
data.setVar('P4PORT', host, localdata)
|
||||
|
||||
p4cmd = data.getVar('FETCHCOMMAND', localdata, 1)
|
||||
|
||||
# create temp directory
|
||||
bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: creating temporary directory")
|
||||
bb.mkdirhier(data.expand('${WORKDIR}', localdata))
|
||||
data.setVar('TMPBASE', data.expand('${WORKDIR}/oep4.XXXXXX', localdata), localdata)
|
||||
tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false")
|
||||
tmpfile = tmppipe.readline().strip()
|
||||
if not tmpfile:
|
||||
bb.error("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.")
|
||||
raise FetchError(module)
|
||||
|
||||
if "label" in parm:
|
||||
depot = "%s@%s" % (depot,parm["label"])
|
||||
else:
|
||||
cset = Perforce.getcset(d, depot, host, user, pswd, parm)
|
||||
depot = "%s@%s" % (depot,cset)
|
||||
|
||||
os.chdir(tmpfile)
|
||||
bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc)
|
||||
bb.msg.note(1, bb.msg.domain.Fetcher, "%s files %s" % (p4cmd, depot))
|
||||
p4file = os.popen("%s files %s" % (p4cmd, depot))
|
||||
|
||||
if not p4file:
|
||||
bb.error("Fetch: unable to get the P4 files from %s" % (depot))
|
||||
raise FetchError(module)
|
||||
|
||||
count = 0
|
||||
|
||||
for file in p4file:
|
||||
list = file.split()
|
||||
|
||||
if list[2] == "delete":
|
||||
continue
|
||||
|
||||
dest = list[0][len(path)+1:]
|
||||
where = dest.find("#")
|
||||
|
||||
os.system("%s print -o %s/%s %s" % (p4cmd, module,dest[:where],list[0]))
|
||||
count = count + 1
|
||||
|
||||
if count == 0:
|
||||
bb.error("Fetch: No files gathered from the P4 fetch")
|
||||
raise FetchError(module)
|
||||
|
||||
myret = os.system("tar -czf %s %s" % (ud.localpath, module))
|
||||
if myret != 0:
|
||||
try:
|
||||
os.unlink(ud.localpath)
|
||||
except OSError:
|
||||
pass
|
||||
raise FetchError(module)
|
||||
# cleanup
|
||||
os.system('rm -rf %s' % tmpfile)
|
||||
|
||||
|
||||
120
bitbake/lib/bb/fetch/ssh.py
Normal file
120
bitbake/lib/bb/fetch/ssh.py
Normal file
@@ -0,0 +1,120 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
'''
|
||||
BitBake 'Fetch' implementations
|
||||
|
||||
This implementation is for Secure Shell (SSH), and attempts to comply with the
|
||||
IETF secsh internet draft:
|
||||
http://tools.ietf.org/wg/secsh/draft-ietf-secsh-scp-sftp-ssh-uri/
|
||||
|
||||
Currently does not support the sftp parameters, as this uses scp
|
||||
Also does not support the 'fingerprint' connection parameter.
|
||||
|
||||
'''
|
||||
|
||||
# Copyright (C) 2006 OpenedHand Ltd.
|
||||
#
|
||||
#
|
||||
# Based in part on svk.py:
|
||||
# Copyright (C) 2006 Holger Hans Peter Freyther
|
||||
# Based on svn.py:
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
# Based on functions from the base bb module:
|
||||
# Copyright 2003 Holger Schurig
|
||||
#
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import re, os
|
||||
import bb
|
||||
from bb import data
|
||||
from bb.fetch import Fetch
|
||||
from bb.fetch import FetchError
|
||||
from bb.fetch import MissingParameterError
|
||||
|
||||
|
||||
__pattern__ = re.compile(r'''
|
||||
\s* # Skip leading whitespace
|
||||
ssh:// # scheme
|
||||
( # Optional username/password block
|
||||
(?P<user>\S+) # username
|
||||
(:(?P<pass>\S+))? # colon followed by the password (optional)
|
||||
)?
|
||||
(?P<cparam>(;[^;]+)*)? # connection parameters block (optional)
|
||||
@
|
||||
(?P<host>\S+?) # non-greedy match of the host
|
||||
(:(?P<port>[0-9]+))? # colon followed by the port (optional)
|
||||
/
|
||||
(?P<path>[^;]+) # path on the remote system, may be absolute or relative,
|
||||
# and may include the use of '~' to reference the remote home
|
||||
# directory
|
||||
(?P<sparam>(;[^;]+)*)? # parameters block (optional)
|
||||
$
|
||||
''', re.VERBOSE)
|
||||
|
||||
class SSH(Fetch):
|
||||
'''Class to fetch a module or modules via Secure Shell'''
|
||||
|
||||
def supports(self, url, urldata, d):
|
||||
return __pattern__.match(url) != None
|
||||
|
||||
def localpath(self, url, urldata, d):
|
||||
m = __pattern__.match(url)
|
||||
path = m.group('path')
|
||||
host = m.group('host')
|
||||
lpath = os.path.join(data.getVar('DL_DIR', d, True), host, os.path.basename(path))
|
||||
return lpath
|
||||
|
||||
def go(self, url, urldata, d):
|
||||
dldir = data.getVar('DL_DIR', d, 1)
|
||||
|
||||
m = __pattern__.match(url)
|
||||
path = m.group('path')
|
||||
host = m.group('host')
|
||||
port = m.group('port')
|
||||
user = m.group('user')
|
||||
password = m.group('pass')
|
||||
|
||||
ldir = os.path.join(dldir, host)
|
||||
lpath = os.path.join(ldir, os.path.basename(path))
|
||||
|
||||
if not os.path.exists(ldir):
|
||||
os.makedirs(ldir)
|
||||
|
||||
if port:
|
||||
port = '-P %s' % port
|
||||
else:
|
||||
port = ''
|
||||
|
||||
if user:
|
||||
fr = user
|
||||
if password:
|
||||
fr += ':%s' % password
|
||||
fr += '@%s' % host
|
||||
else:
|
||||
fr = host
|
||||
fr += ':%s' % path
|
||||
|
||||
|
||||
import commands
|
||||
cmd = 'scp -B -r %s %s %s/' % (
|
||||
port,
|
||||
commands.mkarg(fr),
|
||||
commands.mkarg(ldir)
|
||||
)
|
||||
|
||||
(exitstatus, output) = commands.getstatusoutput(cmd)
|
||||
if exitstatus != 0:
|
||||
print output
|
||||
raise FetchError('Unable to fetch %s' % url)
|
||||
109
bitbake/lib/bb/fetch/svk.py
Normal file
109
bitbake/lib/bb/fetch/svk.py
Normal file
@@ -0,0 +1,109 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake 'Fetch' implementations
|
||||
|
||||
This implementation is for svk. It is based on the svn implementation
|
||||
|
||||
"""
|
||||
|
||||
# Copyright (C) 2006 Holger Hans Peter Freyther
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Based on functions from the base bb module, Copyright 2003 Holger Schurig
|
||||
|
||||
import os, re
|
||||
import bb
|
||||
from bb import data
|
||||
from bb.fetch import Fetch
|
||||
from bb.fetch import FetchError
|
||||
from bb.fetch import MissingParameterError
|
||||
|
||||
class Svk(Fetch):
|
||||
"""Class to fetch a module or modules from svk repositories"""
|
||||
def supports(self, url, ud, d):
|
||||
"""
|
||||
Check to see if a given url can be fetched with cvs.
|
||||
"""
|
||||
return ud.type in ['svk']
|
||||
|
||||
def localpath(self, url, ud, d):
|
||||
if not "module" in ud.parm:
|
||||
raise MissingParameterError("svk method needs a 'module' parameter")
|
||||
else:
|
||||
ud.module = ud.parm["module"]
|
||||
|
||||
ud.revision = ""
|
||||
if 'rev' in ud.parm:
|
||||
ud.revision = ud.parm['rev']
|
||||
|
||||
ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d)
|
||||
|
||||
return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
|
||||
|
||||
def forcefetch(self, url, ud, d):
|
||||
if (ud.date == "now"):
|
||||
return True
|
||||
return False
|
||||
|
||||
def go(self, loc, ud, d):
|
||||
"""Fetch urls"""
|
||||
|
||||
if not self.forcefetch(loc, ud, d) and Fetch.try_mirror(d, ud.localfile):
|
||||
return
|
||||
|
||||
svkroot = ud.host + ud.path
|
||||
|
||||
svkcmd = "svk co -r {%s} %s/%s" % (date, svkroot, ud.module)
|
||||
|
||||
if ud.revision:
|
||||
svkcmd = "svk co -r %s/%s" % (ud.revision, svkroot, ud.module)
|
||||
|
||||
# create temp directory
|
||||
localdata = data.createCopy(d)
|
||||
data.update_data(localdata)
|
||||
bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: creating temporary directory")
|
||||
bb.mkdirhier(data.expand('${WORKDIR}', localdata))
|
||||
data.setVar('TMPBASE', data.expand('${WORKDIR}/oesvk.XXXXXX', localdata), localdata)
|
||||
tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false")
|
||||
tmpfile = tmppipe.readline().strip()
|
||||
if not tmpfile:
|
||||
bb.msg.error(bb.msg.domain.Fetcher, "Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.")
|
||||
raise FetchError(ud.module)
|
||||
|
||||
# check out sources there
|
||||
os.chdir(tmpfile)
|
||||
bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc)
|
||||
bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svkcmd)
|
||||
myret = os.system(svkcmd)
|
||||
if myret != 0:
|
||||
try:
|
||||
os.rmdir(tmpfile)
|
||||
except OSError:
|
||||
pass
|
||||
raise FetchError(ud.module)
|
||||
|
||||
os.chdir(os.path.join(tmpfile, os.path.dirname(ud.module)))
|
||||
# tar them up to a defined filename
|
||||
myret = os.system("tar -czf %s %s" % (ud.localpath, os.path.basename(ud.module)))
|
||||
if myret != 0:
|
||||
try:
|
||||
os.unlink(ud.localpath)
|
||||
except OSError:
|
||||
pass
|
||||
raise FetchError(ud.module)
|
||||
# cleanup
|
||||
os.system('rm -rf %s' % tmpfile)
|
||||
144
bitbake/lib/bb/fetch/svn.py
Normal file
144
bitbake/lib/bb/fetch/svn.py
Normal file
@@ -0,0 +1,144 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake 'Fetch' implementations
|
||||
|
||||
This implementation is for svn. It is based on the cvs implementation.
|
||||
|
||||
"""
|
||||
|
||||
# Copyright (C) 2004 Marcin Juszkiewicz
|
||||
#
|
||||
# Classes for obtaining upstream sources for the
|
||||
# BitBake build tools.
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Based on functions from the base bb module, Copyright 2003 Holger Schurig
|
||||
|
||||
import os, re
|
||||
import sys
|
||||
import bb
|
||||
from bb import data
|
||||
from bb.fetch import Fetch
|
||||
from bb.fetch import FetchError
|
||||
from bb.fetch import MissingParameterError
|
||||
|
||||
class Svn(Fetch):
|
||||
"""Class to fetch a module or modules from svn repositories"""
|
||||
def supports(self, url, ud, d):
|
||||
"""
|
||||
Check to see if a given url can be fetched with svn.
|
||||
"""
|
||||
return ud.type in ['svn']
|
||||
|
||||
def localpath(self, url, ud, d):
|
||||
if not "module" in ud.parm:
|
||||
raise MissingParameterError("svn method needs a 'module' parameter")
|
||||
else:
|
||||
ud.module = ud.parm["module"]
|
||||
|
||||
ud.revision = ""
|
||||
if 'rev' in ud.parm:
|
||||
ud.revision = ud.parm['rev']
|
||||
|
||||
if ud.revision:
|
||||
ud.date = ""
|
||||
|
||||
ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d)
|
||||
|
||||
return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
|
||||
|
||||
def forcefetch(self, url, ud, d):
|
||||
if (ud.date == "now"):
|
||||
return True
|
||||
return False
|
||||
|
||||
def go(self, loc, ud, d):
|
||||
"""Fetch url"""
|
||||
|
||||
# try to use the tarball stash
|
||||
if not self.forcefetch(loc, ud, d) and Fetch.try_mirror(d, ud.localfile):
|
||||
bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping svn checkout." % ud.localpath)
|
||||
return
|
||||
|
||||
proto = "svn"
|
||||
if "proto" in ud.parm:
|
||||
proto = ud.parm["proto"]
|
||||
|
||||
svn_rsh = None
|
||||
if proto == "svn+ssh" and "rsh" in ud.parm:
|
||||
svn_rsh = ud.parm["rsh"]
|
||||
|
||||
svnroot = ud.host + ud.path
|
||||
|
||||
# either use the revision, or SRCDATE in braces, or nothing for SRCDATE = "now"
|
||||
options = []
|
||||
if ud.revision:
|
||||
options.append("-r %s" % ud.revision)
|
||||
elif ud.date != "now":
|
||||
options.append("-r {%s}" % ud.date)
|
||||
|
||||
if ud.user:
|
||||
options.append("--username %s" % ud.user)
|
||||
|
||||
if ud.pswd:
|
||||
options.append("--password %s" % ud.pswd)
|
||||
|
||||
localdata = data.createCopy(d)
|
||||
data.setVar('OVERRIDES', "svn:%s" % data.getVar('OVERRIDES', localdata), localdata)
|
||||
data.update_data(localdata)
|
||||
|
||||
data.setVar('SVNROOT', "%s://%s/%s" % (proto, svnroot, ud.module), localdata)
|
||||
data.setVar('SVNCOOPTS', " ".join(options), localdata)
|
||||
data.setVar('SVNMODULE', ud.module, localdata)
|
||||
svncmd = data.getVar('FETCHCOMMAND', localdata, 1)
|
||||
svnupcmd = data.getVar('UPDATECOMMAND', localdata, 1)
|
||||
|
||||
if svn_rsh:
|
||||
svncmd = "svn_RSH=\"%s\" %s" % (svn_rsh, svncmd)
|
||||
svnupcmd = "svn_RSH=\"%s\" %s" % (svn_rsh, svnupcmd)
|
||||
|
||||
pkg = data.expand('${PN}', d)
|
||||
pkgdir = os.path.join(data.expand('${SVNDIR}', localdata), pkg)
|
||||
moddir = os.path.join(pkgdir, ud.module)
|
||||
bb.msg.debug(2, bb.msg.domain.Fetcher, "Fetch: checking for module directory '" + moddir + "'")
|
||||
|
||||
if os.access(os.path.join(moddir, '.svn'), os.R_OK):
|
||||
bb.msg.note(1, bb.msg.domain.Fetcher, "Update " + loc)
|
||||
# update sources there
|
||||
os.chdir(moddir)
|
||||
bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svnupcmd)
|
||||
myret = os.system(svnupcmd)
|
||||
else:
|
||||
bb.msg.note(1, bb.msg.domain.Fetcher, "Fetch " + loc)
|
||||
# check out sources there
|
||||
bb.mkdirhier(pkgdir)
|
||||
os.chdir(pkgdir)
|
||||
bb.msg.debug(1, bb.msg.domain.Fetcher, "Running %s" % svncmd)
|
||||
myret = os.system(svncmd)
|
||||
|
||||
if myret != 0:
|
||||
raise FetchError(ud.module)
|
||||
|
||||
os.chdir(pkgdir)
|
||||
# tar them up to a defined filename
|
||||
myret = os.system("tar -czf %s %s" % (ud.localpath, os.path.basename(ud.module)))
|
||||
if myret != 0:
|
||||
try:
|
||||
os.unlink(ud.localpath)
|
||||
except OSError:
|
||||
pass
|
||||
raise FetchError(ud.module)
|
||||
99
bitbake/lib/bb/fetch/wget.py
Normal file
99
bitbake/lib/bb/fetch/wget.py
Normal file
@@ -0,0 +1,99 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake 'Fetch' implementations
|
||||
|
||||
Classes for obtaining upstream sources for the
|
||||
BitBake build tools.
|
||||
|
||||
"""
|
||||
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Based on functions from the base bb module, Copyright 2003 Holger Schurig
|
||||
|
||||
import os, re
|
||||
import bb
|
||||
from bb import data
|
||||
from bb.fetch import Fetch
|
||||
from bb.fetch import FetchError
|
||||
from bb.fetch import uri_replace
|
||||
|
||||
class Wget(Fetch):
|
||||
"""Class to fetch urls via 'wget'"""
|
||||
def supports(self, url, ud, d):
|
||||
"""
|
||||
Check to see if a given url can be fetched with cvs.
|
||||
"""
|
||||
return ud.type in ['http','https','ftp']
|
||||
|
||||
def localpath(self, url, ud, d):
|
||||
|
||||
url = bb.encodeurl([ud.type, ud.host, ud.path, ud.user, ud.pswd, {}])
|
||||
ud.basename = os.path.basename(ud.path)
|
||||
ud.localfile = data.expand(os.path.basename(url), d)
|
||||
|
||||
return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
|
||||
|
||||
def go(self, uri, ud, d):
|
||||
"""Fetch urls"""
|
||||
|
||||
def fetch_uri(uri, ud, d):
|
||||
if os.path.exists(ud.localpath):
|
||||
# file exists, but we didnt complete it.. trying again..
|
||||
fetchcmd = data.getVar("RESUMECOMMAND", d, 1)
|
||||
else:
|
||||
fetchcmd = data.getVar("FETCHCOMMAND", d, 1)
|
||||
|
||||
bb.msg.note(1, bb.msg.domain.Fetcher, "fetch " + uri)
|
||||
fetchcmd = fetchcmd.replace("${URI}", uri)
|
||||
fetchcmd = fetchcmd.replace("${FILE}", ud.basename)
|
||||
bb.msg.debug(2, bb.msg.domain.Fetcher, "executing " + fetchcmd)
|
||||
ret = os.system(fetchcmd)
|
||||
if ret != 0:
|
||||
return False
|
||||
|
||||
# check if sourceforge did send us to the mirror page
|
||||
if not os.path.exists(ud.localpath):
|
||||
os.system("rm %s*" % ud.localpath) # FIXME shell quote it
|
||||
bb.msg.debug(2, bb.msg.domain.Fetcher, "sourceforge.net send us to the mirror on %s" % ud.basename)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
localdata = data.createCopy(d)
|
||||
data.setVar('OVERRIDES', "wget:" + data.getVar('OVERRIDES', localdata), localdata)
|
||||
data.update_data(localdata)
|
||||
|
||||
premirrors = [ i.split() for i in (data.getVar('PREMIRRORS', localdata, 1) or "").split('\n') if i ]
|
||||
for (find, replace) in premirrors:
|
||||
newuri = uri_replace(uri, find, replace, d)
|
||||
if newuri != uri:
|
||||
if fetch_uri(newuri, ud, localdata):
|
||||
return
|
||||
|
||||
if fetch_uri(uri, ud, localdata):
|
||||
return
|
||||
|
||||
# try mirrors
|
||||
mirrors = [ i.split() for i in (data.getVar('MIRRORS', localdata, 1) or "").split('\n') if i ]
|
||||
for (find, replace) in mirrors:
|
||||
newuri = uri_replace(uri, find, replace, d)
|
||||
if newuri != uri:
|
||||
if fetch_uri(newuri, ud, localdata):
|
||||
return
|
||||
|
||||
raise FetchError(uri)
|
||||
144
bitbake/lib/bb/manifest.py
Normal file
144
bitbake/lib/bb/manifest.py
Normal file
@@ -0,0 +1,144 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import os, sys
|
||||
import bb, bb.data
|
||||
|
||||
def getfields(line):
|
||||
fields = {}
|
||||
fieldmap = ( "pkg", "src", "dest", "type", "mode", "uid", "gid", "major", "minor", "start", "inc", "count" )
|
||||
for f in xrange(len(fieldmap)):
|
||||
fields[fieldmap[f]] = None
|
||||
|
||||
if not line:
|
||||
return None
|
||||
|
||||
splitline = line.split()
|
||||
if not len(splitline):
|
||||
return None
|
||||
|
||||
try:
|
||||
for f in xrange(len(fieldmap)):
|
||||
if splitline[f] == '-':
|
||||
continue
|
||||
fields[fieldmap[f]] = splitline[f]
|
||||
except IndexError:
|
||||
pass
|
||||
return fields
|
||||
|
||||
def parse (mfile, d):
|
||||
manifest = []
|
||||
while 1:
|
||||
line = mfile.readline()
|
||||
if not line:
|
||||
break
|
||||
if line.startswith("#"):
|
||||
continue
|
||||
fields = getfields(line)
|
||||
if not fields:
|
||||
continue
|
||||
manifest.append(fields)
|
||||
return manifest
|
||||
|
||||
def emit (func, manifest, d):
|
||||
#str = "%s () {\n" % func
|
||||
str = ""
|
||||
for line in manifest:
|
||||
emittedline = emit_line(func, line, d)
|
||||
if not emittedline:
|
||||
continue
|
||||
str += emittedline + "\n"
|
||||
# str += "}\n"
|
||||
return str
|
||||
|
||||
def mangle (func, line, d):
|
||||
import copy
|
||||
newline = copy.copy(line)
|
||||
src = bb.data.expand(newline["src"], d)
|
||||
|
||||
if src:
|
||||
if not os.path.isabs(src):
|
||||
src = "${WORKDIR}/" + src
|
||||
|
||||
dest = newline["dest"]
|
||||
if not dest:
|
||||
return
|
||||
|
||||
if dest.startswith("/"):
|
||||
dest = dest[1:]
|
||||
|
||||
if func is "do_install":
|
||||
dest = "${D}/" + dest
|
||||
|
||||
elif func is "do_populate":
|
||||
dest = "${WORKDIR}/install/" + newline["pkg"] + "/" + dest
|
||||
|
||||
elif func is "do_stage":
|
||||
varmap = {}
|
||||
varmap["${bindir}"] = "${STAGING_DIR}/${HOST_SYS}/bin"
|
||||
varmap["${libdir}"] = "${STAGING_DIR}/${HOST_SYS}/lib"
|
||||
varmap["${includedir}"] = "${STAGING_DIR}/${HOST_SYS}/include"
|
||||
varmap["${datadir}"] = "${STAGING_DATADIR}"
|
||||
|
||||
matched = 0
|
||||
for key in varmap.keys():
|
||||
if dest.startswith(key):
|
||||
dest = varmap[key] + "/" + dest[len(key):]
|
||||
matched = 1
|
||||
if not matched:
|
||||
newline = None
|
||||
return
|
||||
else:
|
||||
newline = None
|
||||
return
|
||||
|
||||
newline["src"] = src
|
||||
newline["dest"] = dest
|
||||
return newline
|
||||
|
||||
def emit_line (func, line, d):
|
||||
import copy
|
||||
newline = copy.deepcopy(line)
|
||||
newline = mangle(func, newline, d)
|
||||
if not newline:
|
||||
return None
|
||||
|
||||
str = ""
|
||||
type = newline["type"]
|
||||
mode = newline["mode"]
|
||||
src = newline["src"]
|
||||
dest = newline["dest"]
|
||||
if type is "d":
|
||||
str = "install -d "
|
||||
if mode:
|
||||
str += "-m %s " % mode
|
||||
str += dest
|
||||
elif type is "f":
|
||||
if not src:
|
||||
return None
|
||||
if dest.endswith("/"):
|
||||
str = "install -d "
|
||||
str += dest + "\n"
|
||||
str += "install "
|
||||
else:
|
||||
str = "install -D "
|
||||
if mode:
|
||||
str += "-m %s " % mode
|
||||
str += src + " " + dest
|
||||
del newline
|
||||
return str
|
||||
84
bitbake/lib/bb/methodpool.py
Normal file
84
bitbake/lib/bb/methodpool.py
Normal file
@@ -0,0 +1,84 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
#
|
||||
#
|
||||
# Copyright (C) 2006 Holger Hans Peter Freyther
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
|
||||
"""
|
||||
What is a method pool?
|
||||
|
||||
BitBake has a global method scope where .bb, .inc and .bbclass
|
||||
files can install methods. These methods are parsed from strings.
|
||||
To avoid recompiling and executing these string we introduce
|
||||
a method pool to do this task.
|
||||
|
||||
This pool will be used to compile and execute the functions. It
|
||||
will be smart enough to
|
||||
"""
|
||||
|
||||
from bb.utils import better_compile, better_exec
|
||||
from bb import error
|
||||
|
||||
# A dict of modules we have handled
|
||||
# it is the number of .bbclasses + x in size
|
||||
_parsed_methods = { }
|
||||
_parsed_fns = { }
|
||||
|
||||
def insert_method(modulename, code, fn):
|
||||
"""
|
||||
Add code of a module should be added. The methods
|
||||
will be simply added, no checking will be done
|
||||
"""
|
||||
comp = better_compile(code, "<bb>", fn )
|
||||
better_exec(comp, __builtins__, code, fn)
|
||||
|
||||
# now some instrumentation
|
||||
code = comp.co_names
|
||||
for name in code:
|
||||
if name in ['None', 'False']:
|
||||
continue
|
||||
elif name in _parsed_fns and not _parsed_fns[name] == modulename:
|
||||
error( "Error Method already seen: %s in' %s' now in '%s'" % (name, _parsed_fns[name], modulename))
|
||||
else:
|
||||
_parsed_fns[name] = modulename
|
||||
|
||||
def check_insert_method(modulename, code, fn):
|
||||
"""
|
||||
Add the code if it wasnt added before. The module
|
||||
name will be used for that
|
||||
|
||||
Variables:
|
||||
@modulename a short name e.g. base.bbclass
|
||||
@code The actual python code
|
||||
@fn The filename from the outer file
|
||||
"""
|
||||
if not modulename in _parsed_methods:
|
||||
return insert_method(modulename, code, fn)
|
||||
_parsed_methods[modulename] = 1
|
||||
|
||||
def parsed_module(modulename):
|
||||
"""
|
||||
Inform me file xyz was parsed
|
||||
"""
|
||||
return modulename in _parsed_methods
|
||||
|
||||
|
||||
def get_parsed_dict():
|
||||
"""
|
||||
shortcut
|
||||
"""
|
||||
return _parsed_methods
|
||||
136
bitbake/lib/bb/msg.py
Normal file
136
bitbake/lib/bb/msg.py
Normal file
@@ -0,0 +1,136 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake 'msg' implementation
|
||||
|
||||
Message handling infrastructure for bitbake
|
||||
|
||||
"""
|
||||
|
||||
# Copyright (C) 2006 Richard Purdie
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import sys, os, re, bb
|
||||
from bb import utils, event
|
||||
|
||||
debug_level = {}
|
||||
|
||||
verbose = False
|
||||
|
||||
domain = bb.utils.Enum(
|
||||
'Build',
|
||||
'Cache',
|
||||
'Collection',
|
||||
'Data',
|
||||
'Depends',
|
||||
'Fetcher',
|
||||
'Parsing',
|
||||
'Provider',
|
||||
'RunQueue',
|
||||
'TaskData',
|
||||
'Util')
|
||||
|
||||
|
||||
class MsgBase(bb.event.Event):
|
||||
"""Base class for messages"""
|
||||
|
||||
def __init__(self, msg, d ):
|
||||
self._message = msg
|
||||
event.Event.__init__(self, d)
|
||||
|
||||
class MsgDebug(MsgBase):
|
||||
"""Debug Message"""
|
||||
|
||||
class MsgNote(MsgBase):
|
||||
"""Note Message"""
|
||||
|
||||
class MsgWarn(MsgBase):
|
||||
"""Warning Message"""
|
||||
|
||||
class MsgError(MsgBase):
|
||||
"""Error Message"""
|
||||
|
||||
class MsgFatal(MsgBase):
|
||||
"""Fatal Message"""
|
||||
|
||||
#
|
||||
# Message control functions
|
||||
#
|
||||
|
||||
def set_debug_level(level):
|
||||
bb.msg.debug_level = {}
|
||||
for domain in bb.msg.domain:
|
||||
bb.msg.debug_level[domain] = level
|
||||
bb.msg.debug_level['default'] = level
|
||||
|
||||
def set_verbose(level):
|
||||
bb.msg.verbose = level
|
||||
|
||||
def set_debug_domains(domains):
|
||||
for domain in domains:
|
||||
found = False
|
||||
for ddomain in bb.msg.domain:
|
||||
if domain == str(ddomain):
|
||||
bb.msg.debug_level[ddomain] = bb.msg.debug_level[ddomain] + 1
|
||||
found = True
|
||||
if not found:
|
||||
std_warn("Logging domain %s is not valid, ignoring" % domain)
|
||||
|
||||
#
|
||||
# Message handling functions
|
||||
#
|
||||
|
||||
def debug(level, domain, msg, fn = None):
|
||||
if debug_level[domain] >= level:
|
||||
bb.event.fire(MsgDebug(msg, None))
|
||||
print 'DEBUG: ' + msg
|
||||
|
||||
def note(level, domain, msg, fn = None):
|
||||
if level == 1 or verbose or debug_level[domain] >= 1:
|
||||
std_note(msg)
|
||||
|
||||
def warn(domain, msg, fn = None):
|
||||
std_warn(msg)
|
||||
|
||||
def error(domain, msg, fn = None):
|
||||
std_error(msg)
|
||||
|
||||
def fatal(domain, msg, fn = None):
|
||||
std_fatal(msg)
|
||||
|
||||
#
|
||||
# Compatibility functions for the original message interface
|
||||
#
|
||||
def std_debug(lvl, msg):
|
||||
if debug_level['default'] >= lvl:
|
||||
bb.event.fire(MsgDebug(msg, None))
|
||||
print 'DEBUG: ' + msg
|
||||
|
||||
def std_note(msg):
|
||||
bb.event.fire(MsgNote(msg, None))
|
||||
print 'NOTE: ' + msg
|
||||
|
||||
def std_warn(msg):
|
||||
bb.event.fire(MsgWarn(msg, None))
|
||||
print 'WARNING: ' + msg
|
||||
|
||||
def std_error(msg):
|
||||
bb.event.fire(MsgError(msg, None))
|
||||
print 'ERROR: ' + msg
|
||||
|
||||
def std_fatal(msg):
|
||||
bb.event.fire(MsgFatal(msg, None))
|
||||
print 'ERROR: ' + msg
|
||||
sys.exit(1)
|
||||
80
bitbake/lib/bb/parse/__init__.py
Normal file
80
bitbake/lib/bb/parse/__init__.py
Normal file
@@ -0,0 +1,80 @@
|
||||
"""
|
||||
BitBake Parsers
|
||||
|
||||
File parsers for the BitBake build tools.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
# Copyright (C) 2003, 2004 Phil Blundell
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Based on functions from the base bb module, Copyright 2003 Holger Schurig
|
||||
|
||||
__all__ = [ 'ParseError', 'SkipPackage', 'cached_mtime', 'mark_dependency',
|
||||
'supports', 'handle', 'init' ]
|
||||
handlers = []
|
||||
|
||||
import bb, os
|
||||
|
||||
class ParseError(Exception):
|
||||
"""Exception raised when parsing fails"""
|
||||
|
||||
class SkipPackage(Exception):
|
||||
"""Exception raised to skip this package"""
|
||||
|
||||
__mtime_cache = {}
|
||||
def cached_mtime(f):
|
||||
if not __mtime_cache.has_key(f):
|
||||
__mtime_cache[f] = os.stat(f)[8]
|
||||
return __mtime_cache[f]
|
||||
|
||||
def cached_mtime_noerror(f):
|
||||
if not __mtime_cache.has_key(f):
|
||||
try:
|
||||
__mtime_cache[f] = os.stat(f)[8]
|
||||
except OSError:
|
||||
return 0
|
||||
return __mtime_cache[f]
|
||||
|
||||
def mark_dependency(d, f):
|
||||
if f.startswith('./'):
|
||||
f = "%s/%s" % (os.getcwd(), f[2:])
|
||||
deps = bb.data.getVar('__depends', d) or []
|
||||
deps.append( (f, cached_mtime(f)) )
|
||||
bb.data.setVar('__depends', deps, d)
|
||||
|
||||
def supports(fn, data):
|
||||
"""Returns true if we have a handler for this file, false otherwise"""
|
||||
for h in handlers:
|
||||
if h['supports'](fn, data):
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def handle(fn, data, include = 0):
|
||||
"""Call the handler that is appropriate for this file"""
|
||||
for h in handlers:
|
||||
if h['supports'](fn, data):
|
||||
return h['handle'](fn, data, include)
|
||||
raise ParseError("%s is not a BitBake file" % fn)
|
||||
|
||||
def init(fn, data):
|
||||
for h in handlers:
|
||||
if h['supports'](fn):
|
||||
return h['init'](data)
|
||||
|
||||
|
||||
from parse_py import __version__, ConfHandler, BBHandler
|
||||
188
bitbake/lib/bb/parse/parse_c/BBHandler.py
Normal file
188
bitbake/lib/bb/parse/parse_c/BBHandler.py
Normal file
@@ -0,0 +1,188 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""class for handling .bb files (using a C++ parser)
|
||||
|
||||
Reads a .bb file and obtains its metadata (using a C++ parser)
|
||||
|
||||
Copyright (C) 2006 Tim Robert Ansell
|
||||
Copyright (C) 2006 Holger Hans Peter Freyther
|
||||
|
||||
This program 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.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
"""
|
||||
|
||||
import os, sys
|
||||
|
||||
# The Module we will use here
|
||||
import bb
|
||||
|
||||
from bitbakec import parsefile
|
||||
|
||||
#
|
||||
# This is the Python Part of the Native Parser Implementation.
|
||||
# We will only parse .bbclass, .inc and .bb files but no
|
||||
# configuration files.
|
||||
# supports, init and handle are the public methods used by
|
||||
# parser module
|
||||
#
|
||||
# The rest of the methods are internal implementation details.
|
||||
|
||||
def _init(fn, d):
|
||||
"""
|
||||
Initialize the data implementation with values of
|
||||
the environment and data from the file.
|
||||
"""
|
||||
pass
|
||||
|
||||
#
|
||||
# public
|
||||
#
|
||||
def supports(fn, data):
|
||||
return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" or fn[-5:] == ".conf"
|
||||
|
||||
def init(fn, data):
|
||||
if not bb.data.getVar('TOPDIR', data):
|
||||
bb.data.setVar('TOPDIR', os.getcwd(), data)
|
||||
if not bb.data.getVar('BBPATH', data):
|
||||
bb.data.setVar('BBPATH', os.path.join(sys.prefix, 'share', 'bitbake'), data)
|
||||
|
||||
def handle_inherit(d):
|
||||
"""
|
||||
Handle inheriting of classes. This will load all default classes.
|
||||
It could be faster, it could detect infinite loops but this is todo
|
||||
Also this delayed loading of bb.parse could impose a penalty
|
||||
"""
|
||||
from bb.parse import handle
|
||||
|
||||
files = (data.getVar('INHERIT', d, True) or "").split()
|
||||
if not "base" in i:
|
||||
files[0:0] = ["base"]
|
||||
|
||||
__inherit_cache = data.getVar('__inherit_cache', d) or []
|
||||
for f in files:
|
||||
file = data.expand(f, d)
|
||||
if file[0] != "/" and file[-8:] != ".bbclass":
|
||||
file = os.path.join('classes', '%s.bbclass' % file)
|
||||
|
||||
if not file in __inherit_cache:
|
||||
debug(2, "BB %s:%d: inheriting %s" % (fn, lineno, file))
|
||||
__inherit_cache.append( file )
|
||||
|
||||
try:
|
||||
handle(file, d, True)
|
||||
except IOError:
|
||||
print "Failed to inherit %s" % file
|
||||
data.setVar('__inherit_cache', __inherit_cache, d)
|
||||
|
||||
|
||||
def handle(fn, d, include):
|
||||
from bb import data, parse
|
||||
|
||||
(root, ext) = os.path.splitext(os.path.basename(fn))
|
||||
base_name = "%s%s" % (root,ext)
|
||||
|
||||
# initialize with some data
|
||||
init(fn,d)
|
||||
|
||||
# check if we include or are the beginning
|
||||
oldfile = None
|
||||
if include:
|
||||
oldfile = d.getVar('FILE', False)
|
||||
is_conf = False
|
||||
elif ext == ".conf":
|
||||
is_conf = True
|
||||
data.inheritFromOS(d)
|
||||
|
||||
# find the file
|
||||
if not os.path.isabs(fn):
|
||||
abs_fn = bb.which(d.getVar('BBPATH', True), fn)
|
||||
else:
|
||||
abs_fn = fn
|
||||
|
||||
# check if the file exists
|
||||
if not os.path.exists(abs_fn):
|
||||
raise IOError("file '%(fn)s' not found" % locals() )
|
||||
|
||||
# now we know the file is around mark it as dep
|
||||
if include:
|
||||
parse.mark_dependency(d, abs_fn)
|
||||
|
||||
# manipulate the bbpath
|
||||
if ext != ".bbclass" and ext != ".conf":
|
||||
old_bb_path = data.getVar('BBPATH', d)
|
||||
data.setVar('BBPATH', os.path.dirname(abs_fn) + (":%s" %old_bb_path) , d)
|
||||
|
||||
# handle INHERITS and base inherit
|
||||
if ext != ".bbclass" and ext != ".conf":
|
||||
data.setVar('FILE', fn, d)
|
||||
handle_interit(d)
|
||||
|
||||
# now parse this file - by defering it to C++
|
||||
parsefile(abs_fn, d, is_conf)
|
||||
|
||||
# Finish it up
|
||||
if include == 0:
|
||||
data.expandKeys(d)
|
||||
data.update_data(d)
|
||||
#### !!! XXX Finish it up by executing the anonfunc
|
||||
|
||||
|
||||
# restore the original FILE
|
||||
if oldfile:
|
||||
d.setVar('FILE', oldfile)
|
||||
|
||||
# restore bbpath
|
||||
if ext != ".bbclass" and ext != ".conf":
|
||||
data.setVar('BBPATH', old_bb_path, d )
|
||||
|
||||
|
||||
return d
|
||||
|
||||
|
||||
# Needed for BitBake files...
|
||||
__pkgsplit_cache__={}
|
||||
def vars_from_file(mypkg, d):
|
||||
if not mypkg:
|
||||
return (None, None, None)
|
||||
if mypkg in __pkgsplit_cache__:
|
||||
return __pkgsplit_cache__[mypkg]
|
||||
|
||||
myfile = os.path.splitext(os.path.basename(mypkg))
|
||||
parts = myfile[0].split('_')
|
||||
__pkgsplit_cache__[mypkg] = parts
|
||||
exp = 3 - len(parts)
|
||||
tmplist = []
|
||||
while exp != 0:
|
||||
exp -= 1
|
||||
tmplist.append(None)
|
||||
parts.extend(tmplist)
|
||||
return parts
|
||||
|
||||
|
||||
|
||||
|
||||
# Inform bitbake that we are a parser
|
||||
# We need to define all three
|
||||
from bb.parse import handlers
|
||||
handlers.append( {'supports' : supports, 'handle': handle, 'init' : init})
|
||||
del handlers
|
||||
36
bitbake/lib/bb/parse/parse_c/Makefile
Normal file
36
bitbake/lib/bb/parse/parse_c/Makefile
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
buil: bitbakec.so
|
||||
echo "Done"
|
||||
|
||||
bitbakescanner.cc: bitbakescanner.l
|
||||
flex -t bitbakescanner.l > bitbakescanner.cc
|
||||
|
||||
bitbakeparser.cc: bitbakeparser.y python_output.h
|
||||
lemon bitbakeparser.y
|
||||
mv bitbakeparser.c bitbakeparser.cc
|
||||
|
||||
bitbakec.c: bitbakec.pyx
|
||||
pyrexc bitbakec.pyx
|
||||
|
||||
bitbakec-processed.c: bitbakec.c
|
||||
cat bitbakec.c | sed -e"s/__pyx_f_8bitbakec_//" > bitbakec-processed.c
|
||||
|
||||
bitbakec.o: bitbakec-processed.c
|
||||
gcc -c bitbakec-processed.c -o bitbakec.o -fPIC -I/usr/include/python2.4
|
||||
|
||||
bitbakeparser.o: bitbakeparser.cc
|
||||
g++ -c bitbakeparser.cc -fPIC -I/usr/include/python2.4
|
||||
|
||||
bitbakescanner.o: bitbakescanner.cc
|
||||
g++ -c bitbakescanner.cc -fPIC -I/usr/include/python2.4
|
||||
|
||||
bitbakec.so: bitbakec.o bitbakeparser.o bitbakescanner.o
|
||||
g++ -shared -fPIC bitbakeparser.o bitbakescanner.o bitbakec.o -o bitbakec.so
|
||||
|
||||
clean:
|
||||
rm -f *.out
|
||||
rm -f *.cc
|
||||
rm -f bitbakec.c
|
||||
rm -f bitbakec-processed.c
|
||||
rm -f *.o
|
||||
rm -f *.so
|
||||
12
bitbake/lib/bb/parse/parse_c/README.build
Normal file
12
bitbake/lib/bb/parse/parse_c/README.build
Normal file
@@ -0,0 +1,12 @@
|
||||
To ease portability (lemon, flex, etc) we keep the
|
||||
result of flex and lemon in the source code. We agree
|
||||
to not manually change the scanner and parser.
|
||||
|
||||
|
||||
|
||||
How we create the files:
|
||||
flex -t bitbakescanner.l > bitbakescanner.cc
|
||||
lemon bitbakeparser.y
|
||||
mv bitbakeparser.c bitbakeparser.cc
|
||||
|
||||
Now manually create two files
|
||||
28
bitbake/lib/bb/parse/parse_c/__init__.py
Normal file
28
bitbake/lib/bb/parse/parse_c/__init__.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# Copyright (C) 2006 Holger Hans Peter Freyther
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
# THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
__version__ = '0.1'
|
||||
__all__ = [ 'BBHandler' ]
|
||||
|
||||
import BBHandler
|
||||
253
bitbake/lib/bb/parse/parse_c/bitbakec.pyx
Normal file
253
bitbake/lib/bb/parse/parse_c/bitbakec.pyx
Normal file
@@ -0,0 +1,253 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
|
||||
cdef extern from "stdio.h":
|
||||
ctypedef int FILE
|
||||
FILE *fopen(char*, char*)
|
||||
int fclose(FILE *fp)
|
||||
|
||||
cdef extern from "string.h":
|
||||
int strlen(char*)
|
||||
|
||||
cdef extern from "lexerc.h":
|
||||
ctypedef struct lex_t:
|
||||
void* parser
|
||||
void* scanner
|
||||
char* name
|
||||
FILE* file
|
||||
int config
|
||||
void* data
|
||||
|
||||
int lineError
|
||||
int errorParse
|
||||
|
||||
cdef extern int parse(FILE*, char*, object, int)
|
||||
|
||||
def parsefile(object file, object data, object config):
|
||||
#print "parsefile: 1", file, data
|
||||
|
||||
# Open the file
|
||||
cdef FILE* f
|
||||
|
||||
f = fopen(file, "r")
|
||||
#print "parsefile: 2 opening file"
|
||||
if (f == NULL):
|
||||
raise IOError("No such file %s." % file)
|
||||
|
||||
#print "parsefile: 3 parse"
|
||||
parse(f, file, data, config)
|
||||
|
||||
# Close the file
|
||||
fclose(f)
|
||||
|
||||
|
||||
cdef public void e_assign(lex_t* container, char* key, char* what):
|
||||
#print "e_assign", key, what
|
||||
if what == NULL:
|
||||
print "FUTURE Warning empty string: use \"\""
|
||||
what = ""
|
||||
|
||||
d = <object>container.data
|
||||
d.setVar(key, what)
|
||||
|
||||
cdef public void e_export(lex_t* c, char* what):
|
||||
#print "e_export", what
|
||||
#exp:
|
||||
# bb.data.setVarFlag(key, "export", 1, data)
|
||||
d = <object>c.data
|
||||
d.setVarFlag(what, "export", 1)
|
||||
|
||||
cdef public void e_immediate(lex_t* c, char* key, char* what):
|
||||
#print "e_immediate", key, what
|
||||
#colon:
|
||||
# val = bb.data.expand(groupd["value"], data)
|
||||
d = <object>c.data
|
||||
d.setVar(key, d.expand(what,d))
|
||||
|
||||
cdef public void e_cond(lex_t* c, char* key, char* what):
|
||||
#print "e_cond", key, what
|
||||
#ques:
|
||||
# val = bb.data.getVar(key, data)
|
||||
# if val == None:
|
||||
# val = groupd["value"]
|
||||
if what == NULL:
|
||||
print "FUTURE warning: Use \"\" for", key
|
||||
what = ""
|
||||
|
||||
d = <object>c.data
|
||||
d.setVar(key, (d.getVar(key,False) or what))
|
||||
|
||||
cdef public void e_prepend(lex_t* c, char* key, char* what):
|
||||
#print "e_prepend", key, what
|
||||
#prepend:
|
||||
# val = "%s %s" % (groupd["value"], (bb.data.getVar(key, data) or ""))
|
||||
d = <object>c.data
|
||||
d.setVar(key, what + " " + (d.getVar(key,0) or ""))
|
||||
|
||||
cdef public void e_append(lex_t* c, char* key, char* what):
|
||||
#print "e_append", key, what
|
||||
#append:
|
||||
# val = "%s %s" % ((bb.data.getVar(key, data) or ""), groupd["value"])
|
||||
d = <object>c.data
|
||||
d.setVar(key, (d.getVar(key,0) or "") + " " + what)
|
||||
|
||||
cdef public void e_precat(lex_t* c, char* key, char* what):
|
||||
#print "e_precat", key, what
|
||||
#predot:
|
||||
# val = "%s%s" % (groupd["value"], (bb.data.getVar(key, data) or ""))
|
||||
d = <object>c.data
|
||||
d.setVar(key, what + (d.getVar(key,0) or ""))
|
||||
|
||||
cdef public void e_postcat(lex_t* c, char* key, char* what):
|
||||
#print "e_postcat", key, what
|
||||
#postdot:
|
||||
# val = "%s%s" % ((bb.data.getVar(key, data) or ""), groupd["value"])
|
||||
d = <object>c.data
|
||||
d.setVar(key, (d.getVar(key,0) or "") + what)
|
||||
|
||||
cdef public int e_addtask(lex_t* c, char* name, char* before, char* after) except -1:
|
||||
#print "e_addtask", name
|
||||
# func = m.group("func")
|
||||
# before = m.group("before")
|
||||
# after = m.group("after")
|
||||
# if func is None:
|
||||
# return
|
||||
# var = "do_" + func
|
||||
#
|
||||
# data.setVarFlag(var, "task", 1, d)
|
||||
#
|
||||
# if after is not None:
|
||||
# # set up deps for function
|
||||
# data.setVarFlag(var, "deps", after.split(), d)
|
||||
# if before is not None:
|
||||
# # set up things that depend on this func
|
||||
# data.setVarFlag(var, "postdeps", before.split(), d)
|
||||
# return
|
||||
|
||||
if c.config == 1:
|
||||
from bb.parse import ParseError
|
||||
raise ParseError("No tasks allowed in config files")
|
||||
return -1
|
||||
|
||||
d = <object>c.data
|
||||
do = "do_%s" % name
|
||||
d.setVarFlag(do, "task", 1)
|
||||
|
||||
if before != NULL and strlen(before) > 0:
|
||||
#print "Before", before
|
||||
d.setVarFlag(do, "postdeps", ("%s" % before).split())
|
||||
if after != NULL and strlen(after) > 0:
|
||||
#print "After", after
|
||||
d.setVarFlag(do, "deps", ("%s" % after).split())
|
||||
|
||||
return 0
|
||||
|
||||
cdef public int e_addhandler(lex_t* c, char* h) except -1:
|
||||
#print "e_addhandler", h
|
||||
# data.setVarFlag(h, "handler", 1, d)
|
||||
if c.config == 1:
|
||||
from bb.parse import ParseError
|
||||
raise ParseError("No handlers allowed in config files")
|
||||
return -1
|
||||
|
||||
d = <object>c.data
|
||||
d.setVarFlag(h, "handler", 1)
|
||||
return 0
|
||||
|
||||
cdef public int e_export_func(lex_t* c, char* function) except -1:
|
||||
#print "e_export_func", function
|
||||
if c.config == 1:
|
||||
from bb.parse import ParseError
|
||||
raise ParseError("No functions allowed in config files")
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
cdef public int e_inherit(lex_t* c, char* file) except -1:
|
||||
#print "e_inherit", file
|
||||
|
||||
if c.config == 1:
|
||||
from bb.parse import ParseError
|
||||
raise ParseError("No inherits allowed in config files")
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
cdef public void e_include(lex_t* c, char* file):
|
||||
from bb.parse import handle
|
||||
d = <object>c.data
|
||||
|
||||
try:
|
||||
handle(d.expand(file,d), d, True)
|
||||
except IOError:
|
||||
print "Could not include file", file
|
||||
|
||||
|
||||
cdef public int e_require(lex_t* c, char* file) except -1:
|
||||
#print "e_require", file
|
||||
from bb.parse import handle
|
||||
d = <object>c.data
|
||||
|
||||
try:
|
||||
handle(d.expand(file,d), d, True)
|
||||
except IOError:
|
||||
print "ParseError", file
|
||||
from bb.parse import ParseError
|
||||
raise ParseError("Could not include required file %s" % file)
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
cdef public int e_proc(lex_t* c, char* key, char* what) except -1:
|
||||
#print "e_proc", key, what
|
||||
if c.config == 1:
|
||||
from bb.parse import ParseError
|
||||
raise ParseError("No inherits allowed in config files")
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
cdef public int e_proc_python(lex_t* c, char* key, char* what) except -1:
|
||||
#print "e_proc_python"
|
||||
if c.config == 1:
|
||||
from bb.parse import ParseError
|
||||
raise ParseError("No pythin allowed in config files")
|
||||
return -1
|
||||
|
||||
if key != NULL:
|
||||
pass
|
||||
#print "Key", key
|
||||
if what != NULL:
|
||||
pass
|
||||
#print "What", what
|
||||
|
||||
return 0
|
||||
|
||||
cdef public int e_proc_fakeroot(lex_t* c, char* key, char* what) except -1:
|
||||
#print "e_fakeroot", key, what
|
||||
|
||||
if c.config == 1:
|
||||
from bb.parse import ParseError
|
||||
raise ParseError("No fakeroot allowed in config files")
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
cdef public int e_def(lex_t* c, char* a, char* b, char* d) except -1:
|
||||
#print "e_def", a, b, d
|
||||
|
||||
if c.config == 1:
|
||||
from bb.parse import ParseError
|
||||
raise ParseError("No defs allowed in config files")
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
cdef public int e_parse_error(lex_t* c) except -1:
|
||||
print "e_parse_error", c.name, "line:", lineError, "parse:", errorParse
|
||||
|
||||
|
||||
from bb.parse import ParseError
|
||||
raise ParseError("There was an parse error, sorry unable to give more information at the current time. File: %s Line: %d" % (c.name,lineError) )
|
||||
return -1
|
||||
|
||||
1157
bitbake/lib/bb/parse/parse_c/bitbakeparser.cc
Normal file
1157
bitbake/lib/bb/parse/parse_c/bitbakeparser.cc
Normal file
File diff suppressed because it is too large
Load Diff
29
bitbake/lib/bb/parse/parse_c/bitbakeparser.h
Normal file
29
bitbake/lib/bb/parse/parse_c/bitbakeparser.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#define T_SYMBOL 1
|
||||
#define T_VARIABLE 2
|
||||
#define T_EXPORT 3
|
||||
#define T_OP_ASSIGN 4
|
||||
#define T_STRING 5
|
||||
#define T_OP_PREDOT 6
|
||||
#define T_OP_POSTDOT 7
|
||||
#define T_OP_IMMEDIATE 8
|
||||
#define T_OP_COND 9
|
||||
#define T_OP_PREPEND 10
|
||||
#define T_OP_APPEND 11
|
||||
#define T_TSYMBOL 12
|
||||
#define T_BEFORE 13
|
||||
#define T_AFTER 14
|
||||
#define T_ADDTASK 15
|
||||
#define T_ADDHANDLER 16
|
||||
#define T_FSYMBOL 17
|
||||
#define T_EXPORT_FUNC 18
|
||||
#define T_ISYMBOL 19
|
||||
#define T_INHERIT 20
|
||||
#define T_INCLUDE 21
|
||||
#define T_REQUIRE 22
|
||||
#define T_PROC_BODY 23
|
||||
#define T_PROC_OPEN 24
|
||||
#define T_PROC_CLOSE 25
|
||||
#define T_PYTHON 26
|
||||
#define T_FAKEROOT 27
|
||||
#define T_DEF_BODY 28
|
||||
#define T_DEF_ARGS 29
|
||||
179
bitbake/lib/bb/parse/parse_c/bitbakeparser.y
Normal file
179
bitbake/lib/bb/parse/parse_c/bitbakeparser.y
Normal file
@@ -0,0 +1,179 @@
|
||||
/* bbp.lemon
|
||||
|
||||
written by Marc Singer
|
||||
6 January 2005
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
USA.
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
lemon parser specification file for a BitBake input file parser.
|
||||
|
||||
Most of the interesting shenanigans are done in the lexer. The
|
||||
BitBake grammar is not regular. In order to emit tokens that
|
||||
the parser can properly interpret in LALR fashion, the lexer
|
||||
manages the interpretation state. This is why there are ISYMBOLs,
|
||||
SYMBOLS, and TSYMBOLS.
|
||||
|
||||
This parser was developed by reading the limited available
|
||||
documentation for BitBake and by analyzing the available BB files.
|
||||
There is no assertion of correctness to be made about this parser.
|
||||
|
||||
*/
|
||||
|
||||
%token_type {token_t}
|
||||
%name bbparse
|
||||
%token_prefix T_
|
||||
%extra_argument {lex_t* lex}
|
||||
|
||||
%include {
|
||||
#include "token.h"
|
||||
#include "lexer.h"
|
||||
#include "python_output.h"
|
||||
}
|
||||
|
||||
|
||||
%token_destructor { $$.release_this (); }
|
||||
|
||||
%syntax_error { e_parse_error( lex ); }
|
||||
|
||||
program ::= statements.
|
||||
|
||||
statements ::= statements statement.
|
||||
statements ::= .
|
||||
|
||||
variable(r) ::= SYMBOL(s).
|
||||
{ r.assignString( (char*)s.string() );
|
||||
s.assignString( 0 );
|
||||
s.release_this(); }
|
||||
variable(r) ::= VARIABLE(v).
|
||||
{
|
||||
r.assignString( (char*)v.string() );
|
||||
v.assignString( 0 );
|
||||
v.release_this(); }
|
||||
|
||||
statement ::= EXPORT variable(s) OP_ASSIGN STRING(v).
|
||||
{ e_assign( lex, s.string(), v.string() );
|
||||
e_export( lex, s.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= EXPORT variable(s) OP_PREDOT STRING(v).
|
||||
{ e_precat( lex, s.string(), v.string() );
|
||||
e_export( lex, s.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= EXPORT variable(s) OP_POSTDOT STRING(v).
|
||||
{ e_postcat( lex, s.string(), v.string() );
|
||||
e_export( lex, s.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= EXPORT variable(s) OP_IMMEDIATE STRING(v).
|
||||
{ e_immediate ( lex, s.string(), v.string() );
|
||||
e_export( lex, s.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= EXPORT variable(s) OP_COND STRING(v).
|
||||
{ e_cond( lex, s.string(), v.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
|
||||
statement ::= variable(s) OP_ASSIGN STRING(v).
|
||||
{ e_assign( lex, s.string(), v.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= variable(s) OP_PREDOT STRING(v).
|
||||
{ e_precat( lex, s.string(), v.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= variable(s) OP_POSTDOT STRING(v).
|
||||
{ e_postcat( lex, s.string(), v.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= variable(s) OP_PREPEND STRING(v).
|
||||
{ e_prepend( lex, s.string(), v.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= variable(s) OP_APPEND STRING(v).
|
||||
{ e_append( lex, s.string() , v.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= variable(s) OP_IMMEDIATE STRING(v).
|
||||
{ e_immediate( lex, s.string(), v.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
statement ::= variable(s) OP_COND STRING(v).
|
||||
{ e_cond( lex, s.string(), v.string() );
|
||||
s.release_this(); v.release_this(); }
|
||||
|
||||
task ::= TSYMBOL(t) BEFORE TSYMBOL(b) AFTER TSYMBOL(a).
|
||||
{ e_addtask( lex, t.string(), b.string(), a.string() );
|
||||
t.release_this(); b.release_this(); a.release_this(); }
|
||||
task ::= TSYMBOL(t) AFTER TSYMBOL(a) BEFORE TSYMBOL(b).
|
||||
{ e_addtask( lex, t.string(), b.string(), a.string());
|
||||
t.release_this(); a.release_this(); b.release_this(); }
|
||||
task ::= TSYMBOL(t).
|
||||
{ e_addtask( lex, t.string(), NULL, NULL);
|
||||
t.release_this();}
|
||||
task ::= TSYMBOL(t) BEFORE TSYMBOL(b).
|
||||
{ e_addtask( lex, t.string(), b.string(), NULL);
|
||||
t.release_this(); b.release_this(); }
|
||||
task ::= TSYMBOL(t) AFTER TSYMBOL(a).
|
||||
{ e_addtask( lex, t.string(), NULL, a.string());
|
||||
t.release_this(); a.release_this(); }
|
||||
tasks ::= tasks task.
|
||||
tasks ::= task.
|
||||
statement ::= ADDTASK tasks.
|
||||
|
||||
statement ::= ADDHANDLER SYMBOL(s).
|
||||
{ e_addhandler( lex, s.string()); s.release_this (); }
|
||||
|
||||
func ::= FSYMBOL(f). { e_export_func( lex, f.string()); f.release_this(); }
|
||||
funcs ::= funcs func.
|
||||
funcs ::= func.
|
||||
statement ::= EXPORT_FUNC funcs.
|
||||
|
||||
inherit ::= ISYMBOL(i). { e_inherit( lex, i.string() ); i.release_this (); }
|
||||
inherits ::= inherits inherit.
|
||||
inherits ::= inherit.
|
||||
statement ::= INHERIT inherits.
|
||||
|
||||
statement ::= INCLUDE ISYMBOL(i).
|
||||
{ e_include( lex, i.string() ); i.release_this(); }
|
||||
|
||||
statement ::= REQUIRE ISYMBOL(i).
|
||||
{ e_require( lex, i.string() ); i.release_this(); }
|
||||
|
||||
proc_body(r) ::= proc_body(l) PROC_BODY(b).
|
||||
{ /* concatenate body lines */
|
||||
r.assignString( token_t::concatString(l.string(), b.string()) );
|
||||
l.release_this ();
|
||||
b.release_this ();
|
||||
}
|
||||
proc_body(b) ::= . { b.assignString(0); }
|
||||
statement ::= variable(p) PROC_OPEN proc_body(b) PROC_CLOSE.
|
||||
{ e_proc( lex, p.string(), b.string() );
|
||||
p.release_this(); b.release_this(); }
|
||||
statement ::= PYTHON SYMBOL(p) PROC_OPEN proc_body(b) PROC_CLOSE.
|
||||
{ e_proc_python ( lex, p.string(), b.string() );
|
||||
p.release_this(); b.release_this(); }
|
||||
statement ::= PYTHON PROC_OPEN proc_body(b) PROC_CLOSE.
|
||||
{ e_proc_python( lex, NULL, b.string());
|
||||
b.release_this (); }
|
||||
|
||||
statement ::= FAKEROOT SYMBOL(p) PROC_OPEN proc_body(b) PROC_CLOSE.
|
||||
{ e_proc_fakeroot( lex, p.string(), b.string() );
|
||||
p.release_this (); b.release_this (); }
|
||||
|
||||
def_body(r) ::= def_body(l) DEF_BODY(b).
|
||||
{ /* concatenate body lines */
|
||||
r.assignString( token_t::concatString(l.string(), b.string()) );
|
||||
l.release_this (); b.release_this ();
|
||||
}
|
||||
def_body(b) ::= . { b.assignString( 0 ); }
|
||||
statement ::= SYMBOL(p) DEF_ARGS(a) def_body(b).
|
||||
{ e_def( lex, p.string(), a.string(), b.string());
|
||||
p.release_this(); a.release_this(); b.release_this(); }
|
||||
|
||||
3209
bitbake/lib/bb/parse/parse_c/bitbakescanner.cc
Normal file
3209
bitbake/lib/bb/parse/parse_c/bitbakescanner.cc
Normal file
File diff suppressed because it is too large
Load Diff
319
bitbake/lib/bb/parse/parse_c/bitbakescanner.l
Normal file
319
bitbake/lib/bb/parse/parse_c/bitbakescanner.l
Normal file
@@ -0,0 +1,319 @@
|
||||
/* bbf.flex
|
||||
|
||||
written by Marc Singer
|
||||
6 January 2005
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
USA.
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
flex lexer specification for a BitBake input file parser.
|
||||
|
||||
Unfortunately, flex doesn't welcome comments within the rule sets.
|
||||
I say unfortunately because this lexer is unreasonably complex and
|
||||
comments would make the code much easier to comprehend.
|
||||
|
||||
The BitBake grammar is not regular. In order to interpret all
|
||||
of the available input files, the lexer maintains much state as it
|
||||
parses. There are places where this lexer will emit tokens that
|
||||
are invalid. The parser will tend to catch these.
|
||||
|
||||
The lexer requires C++ at the moment. The only reason for this has
|
||||
to do with a very small amount of managed state. Producing a C
|
||||
lexer should be a reasonably easy task as long as the %reentrant
|
||||
option is used.
|
||||
|
||||
|
||||
NOTES
|
||||
-----
|
||||
|
||||
o RVALUES. There are three kinds of RVALUES. There are unquoted
|
||||
values, double quote enclosed strings, and single quote
|
||||
strings. Quoted strings may contain unescaped quotes (of either
|
||||
type), *and* any type may span more than one line by using a
|
||||
continuation '\' at the end of the line. This requires us to
|
||||
recognize all types of values with a single expression.
|
||||
Moreover, the only reason to quote a value is to include
|
||||
trailing or leading whitespace. Whitespace within a value is
|
||||
preserved, ugh.
|
||||
|
||||
o CLASSES. C_ patterns define classes. Classes ought not include
|
||||
a repitition operator, instead letting the reference to the class
|
||||
define the repitition count.
|
||||
|
||||
C_SS - symbol start
|
||||
C_SB - symbol body
|
||||
C_SP - whitespace
|
||||
|
||||
*/
|
||||
|
||||
%option never-interactive
|
||||
%option yylineno
|
||||
%option noyywrap
|
||||
%option reentrant stack
|
||||
|
||||
|
||||
%{
|
||||
|
||||
#include "token.h"
|
||||
#include "lexer.h"
|
||||
#include "bitbakeparser.h"
|
||||
#include <ctype.h>
|
||||
|
||||
extern void *bbparseAlloc(void *(*mallocProc)(size_t));
|
||||
extern void bbparseFree(void *p, void (*freeProc)(void*));
|
||||
extern void *bbparseAlloc(void *(*mallocProc)(size_t));
|
||||
extern void *bbparse(void*, int, token_t, lex_t*);
|
||||
extern void bbparseTrace(FILE *TraceFILE, char *zTracePrompt);
|
||||
|
||||
//static const char* rgbInput;
|
||||
//static size_t cbInput;
|
||||
|
||||
extern "C" {
|
||||
|
||||
int lineError;
|
||||
int errorParse;
|
||||
|
||||
enum {
|
||||
errorNone = 0,
|
||||
errorUnexpectedInput,
|
||||
errorUnsupportedFeature,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#define YY_EXTRA_TYPE lex_t*
|
||||
|
||||
/* Read from buffer */
|
||||
#define YY_INPUT(buf,result,max_size) \
|
||||
{ yyextra->input(buf, &result, max_size); }
|
||||
|
||||
//#define YY_DECL static size_t yylex ()
|
||||
|
||||
#define ERROR(e) \
|
||||
do { lineError = yylineno; errorParse = e; yyterminate (); } while (0)
|
||||
|
||||
static const char* fixup_escapes (const char* sz);
|
||||
|
||||
%}
|
||||
|
||||
|
||||
C_SP [ \t]
|
||||
COMMENT #.*\n
|
||||
OP_ASSIGN "="
|
||||
OP_PREDOT ".="
|
||||
OP_POSTDOT "=."
|
||||
OP_IMMEDIATE ":="
|
||||
OP_PREPEND "=+"
|
||||
OP_APPEND "+="
|
||||
OP_COND "?="
|
||||
B_OPEN "{"
|
||||
B_CLOSE "}"
|
||||
|
||||
K_ADDTASK "addtask"
|
||||
K_ADDHANDLER "addhandler"
|
||||
K_AFTER "after"
|
||||
K_BEFORE "before"
|
||||
K_DEF "def"
|
||||
K_INCLUDE "include"
|
||||
K_REQUIRE "require"
|
||||
K_INHERIT "inherit"
|
||||
K_PYTHON "python"
|
||||
K_FAKEROOT "fakeroot"
|
||||
K_EXPORT "export"
|
||||
K_EXPORT_FUNC "EXPORT_FUNCTIONS"
|
||||
|
||||
STRING \"([^\n\r]|"\\\n")*\"
|
||||
SSTRING \'([^\n\r]|"\\\n")*\'
|
||||
VALUE ([^'" \t\n])|([^'" \t\n]([^\n]|(\\\n))*[^'" \t\n])
|
||||
|
||||
C_SS [a-zA-Z_]
|
||||
C_SB [a-zA-Z0-9_+-./]
|
||||
REF $\{{C_SS}{C_SB}*\}
|
||||
SYMBOL {C_SS}{C_SB}*
|
||||
VARIABLE $?{C_SS}({C_SB}*|{REF})*(\[[a-zA-Z0-9_]*\])?
|
||||
FILENAME ([a-zA-Z_./]|{REF})(([-+a-zA-Z0-9_./]*)|{REF})*
|
||||
|
||||
PROC \({C_SP}*\)
|
||||
|
||||
%s S_DEF
|
||||
%s S_DEF_ARGS
|
||||
%s S_DEF_BODY
|
||||
%s S_FUNC
|
||||
%s S_INCLUDE
|
||||
%s S_INHERIT
|
||||
%s S_REQUIRE
|
||||
%s S_PROC
|
||||
%s S_RVALUE
|
||||
%s S_TASK
|
||||
|
||||
%%
|
||||
|
||||
{OP_APPEND} { BEGIN S_RVALUE;
|
||||
yyextra->accept (T_OP_APPEND); }
|
||||
{OP_PREPEND} { BEGIN S_RVALUE;
|
||||
yyextra->accept (T_OP_PREPEND); }
|
||||
{OP_IMMEDIATE} { BEGIN S_RVALUE;
|
||||
yyextra->accept (T_OP_IMMEDIATE); }
|
||||
{OP_ASSIGN} { BEGIN S_RVALUE;
|
||||
yyextra->accept (T_OP_ASSIGN); }
|
||||
{OP_PREDOT} { BEGIN S_RVALUE;
|
||||
yyextra->accept (T_OP_PREDOT); }
|
||||
{OP_POSTDOT} { BEGIN S_RVALUE;
|
||||
yyextra->accept (T_OP_POSTDOT); }
|
||||
{OP_COND} { BEGIN S_RVALUE;
|
||||
yyextra->accept (T_OP_COND); }
|
||||
|
||||
<S_RVALUE>\\\n{C_SP}* { }
|
||||
<S_RVALUE>{STRING} { BEGIN INITIAL;
|
||||
size_t cb = yyleng;
|
||||
while (cb && isspace (yytext[cb - 1]))
|
||||
--cb;
|
||||
yytext[cb - 1] = 0;
|
||||
yyextra->accept (T_STRING, yytext + 1); }
|
||||
<S_RVALUE>{SSTRING} { BEGIN INITIAL;
|
||||
size_t cb = yyleng;
|
||||
while (cb && isspace (yytext[cb - 1]))
|
||||
--cb;
|
||||
yytext[cb - 1] = 0;
|
||||
yyextra->accept (T_STRING, yytext + 1); }
|
||||
|
||||
<S_RVALUE>{VALUE} { ERROR (errorUnexpectedInput); }
|
||||
<S_RVALUE>{C_SP}*\n+ { BEGIN INITIAL;
|
||||
yyextra->accept (T_STRING, NULL); }
|
||||
|
||||
{K_INCLUDE} { BEGIN S_INCLUDE;
|
||||
yyextra->accept (T_INCLUDE); }
|
||||
{K_REQUIRE} { BEGIN S_REQUIRE;
|
||||
yyextra->accept (T_REQUIRE); }
|
||||
{K_INHERIT} { BEGIN S_INHERIT;
|
||||
yyextra->accept (T_INHERIT); }
|
||||
{K_ADDTASK} { BEGIN S_TASK;
|
||||
yyextra->accept (T_ADDTASK); }
|
||||
{K_ADDHANDLER} { yyextra->accept (T_ADDHANDLER); }
|
||||
{K_EXPORT_FUNC} { BEGIN S_FUNC;
|
||||
yyextra->accept (T_EXPORT_FUNC); }
|
||||
<S_TASK>{K_BEFORE} { yyextra->accept (T_BEFORE); }
|
||||
<S_TASK>{K_AFTER} { yyextra->accept (T_AFTER); }
|
||||
<INITIAL>{K_EXPORT} { yyextra->accept (T_EXPORT); }
|
||||
|
||||
<INITIAL>{K_FAKEROOT} { yyextra->accept (T_FAKEROOT); }
|
||||
<INITIAL>{K_PYTHON} { yyextra->accept (T_PYTHON); }
|
||||
{PROC}{C_SP}*{B_OPEN}{C_SP}*\n* { BEGIN S_PROC;
|
||||
yyextra->accept (T_PROC_OPEN); }
|
||||
<S_PROC>{B_CLOSE}{C_SP}*\n* { BEGIN INITIAL;
|
||||
yyextra->accept (T_PROC_CLOSE); }
|
||||
<S_PROC>([^}][^\n]*)?\n* { yyextra->accept (T_PROC_BODY, yytext); }
|
||||
|
||||
{K_DEF} { BEGIN S_DEF; }
|
||||
<S_DEF>{SYMBOL} { BEGIN S_DEF_ARGS;
|
||||
yyextra->accept (T_SYMBOL, yytext); }
|
||||
<S_DEF_ARGS>[^\n:]*: { yyextra->accept (T_DEF_ARGS, yytext); }
|
||||
<S_DEF_ARGS>{C_SP}*\n { BEGIN S_DEF_BODY; }
|
||||
<S_DEF_BODY>{C_SP}+[^\n]*\n { yyextra->accept (T_DEF_BODY, yytext); }
|
||||
<S_DEF_BODY>\n { yyextra->accept (T_DEF_BODY, yytext); }
|
||||
<S_DEF_BODY>. { BEGIN INITIAL; unput (yytext[0]); }
|
||||
|
||||
{COMMENT} { }
|
||||
|
||||
<INITIAL>{SYMBOL} { yyextra->accept (T_SYMBOL, yytext); }
|
||||
<INITIAL>{VARIABLE} { yyextra->accept (T_VARIABLE, yytext); }
|
||||
|
||||
<S_TASK>{SYMBOL} { yyextra->accept (T_TSYMBOL, yytext); }
|
||||
<S_FUNC>{SYMBOL} { yyextra->accept (T_FSYMBOL, yytext); }
|
||||
<S_INHERIT>{SYMBOL} { yyextra->accept (T_ISYMBOL, yytext); }
|
||||
<S_INCLUDE>{FILENAME} { BEGIN INITIAL;
|
||||
yyextra->accept (T_ISYMBOL, yytext); }
|
||||
<S_REQUIRE>{FILENAME} { BEGIN INITIAL;
|
||||
yyextra->accept (T_ISYMBOL, yytext); }
|
||||
<S_TASK>\n { BEGIN INITIAL; }
|
||||
<S_FUNC>\n { BEGIN INITIAL; }
|
||||
<S_INHERIT>\n { BEGIN INITIAL; }
|
||||
|
||||
[ \t\r\n] /* Insignificant whitespace */
|
||||
|
||||
. { ERROR (errorUnexpectedInput); }
|
||||
|
||||
/* Check for premature termination */
|
||||
<<EOF>> { return T_EOF; }
|
||||
|
||||
%%
|
||||
|
||||
void lex_t::accept (int token, const char* sz)
|
||||
{
|
||||
token_t t;
|
||||
memset (&t, 0, sizeof (t));
|
||||
t.copyString(sz);
|
||||
|
||||
/* tell lemon to parse the token */
|
||||
parse (parser, token, t, this);
|
||||
}
|
||||
|
||||
void lex_t::input (char *buf, int *result, int max_size)
|
||||
{
|
||||
/* printf("lex_t::input %p %d\n", buf, max_size); */
|
||||
*result = fread(buf, 1, max_size, file);
|
||||
/* printf("lex_t::input result %d\n", *result); */
|
||||
}
|
||||
|
||||
int lex_t::line ()const
|
||||
{
|
||||
/* printf("lex_t::line\n"); */
|
||||
return yyget_lineno (scanner);
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
void parse (FILE* file, char* name, PyObject* data, int config)
|
||||
{
|
||||
/* printf("parse bbparseAlloc\n"); */
|
||||
void* parser = bbparseAlloc (malloc);
|
||||
yyscan_t scanner;
|
||||
lex_t lex;
|
||||
|
||||
/* printf("parse yylex_init\n"); */
|
||||
yylex_init (&scanner);
|
||||
|
||||
lex.parser = parser;
|
||||
lex.scanner = scanner;
|
||||
lex.file = file;
|
||||
lex.name = name;
|
||||
lex.data = data;
|
||||
lex.config = config;
|
||||
lex.parse = bbparse;
|
||||
/*printf("parse yyset_extra\n"); */
|
||||
yyset_extra (&lex, scanner);
|
||||
|
||||
/* printf("parse yylex\n"); */
|
||||
int result = yylex (scanner);
|
||||
|
||||
/* printf("parse result %d\n", result); */
|
||||
|
||||
lex.accept (0);
|
||||
/* printf("parse lex.accept\n"); */
|
||||
bbparseTrace (NULL, NULL);
|
||||
/* printf("parse bbparseTrace\n"); */
|
||||
|
||||
if (result != T_EOF)
|
||||
printf ("premature end of file\n");
|
||||
|
||||
yylex_destroy (scanner);
|
||||
bbparseFree (parser, free);
|
||||
}
|
||||
|
||||
}
|
||||
48
bitbake/lib/bb/parse/parse_c/lexer.h
Normal file
48
bitbake/lib/bb/parse/parse_c/lexer.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright (C) 2005 Holger Hans Peter Freyther
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef LEXER_H
|
||||
#define LEXER_H
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
struct lex_t {
|
||||
void* parser;
|
||||
void* scanner;
|
||||
FILE* file;
|
||||
char *name;
|
||||
PyObject *data;
|
||||
int config;
|
||||
|
||||
void* (*parse)(void*, int, token_t, lex_t*);
|
||||
|
||||
void accept(int token, const char* sz = NULL);
|
||||
void input(char *buf, int *result, int max_size);
|
||||
int line()const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
19
bitbake/lib/bb/parse/parse_c/lexerc.h
Normal file
19
bitbake/lib/bb/parse/parse_c/lexerc.h
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
#ifndef LEXERC_H
|
||||
#define LEXERC_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
extern int lineError;
|
||||
extern int errorParse;
|
||||
|
||||
typedef struct {
|
||||
void *parser;
|
||||
void *scanner;
|
||||
FILE *file;
|
||||
char *name;
|
||||
PyObject *data;
|
||||
int config;
|
||||
} lex_t;
|
||||
|
||||
#endif
|
||||
56
bitbake/lib/bb/parse/parse_c/python_output.h
Normal file
56
bitbake/lib/bb/parse/parse_c/python_output.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef PYTHON_OUTPUT_H
|
||||
#define PYTHON_OUTPUT_H
|
||||
/*
|
||||
Copyright (C) 2006 Holger Hans Peter Freyther
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
This is the glue:
|
||||
It will be called from the lemon grammar and will call into
|
||||
python to set certain things.
|
||||
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
|
||||
struct lex_t;
|
||||
|
||||
extern void e_assign(lex_t*, const char*, const char*);
|
||||
extern void e_export(lex_t*, const char*);
|
||||
extern void e_immediate(lex_t*, const char*, const char*);
|
||||
extern void e_cond(lex_t*, const char*, const char*);
|
||||
extern void e_prepend(lex_t*, const char*, const char*);
|
||||
extern void e_append(lex_t*, const char*, const char*);
|
||||
extern void e_precat(lex_t*, const char*, const char*);
|
||||
extern void e_postcat(lex_t*, const char*, const char*);
|
||||
|
||||
extern void e_addtask(lex_t*, const char*, const char*, const char*);
|
||||
extern void e_addhandler(lex_t*,const char*);
|
||||
extern void e_export_func(lex_t*, const char*);
|
||||
extern void e_inherit(lex_t*, const char*);
|
||||
extern void e_include(lex_t*, const char*);
|
||||
extern void e_require(lex_t*, const char*);
|
||||
extern void e_proc(lex_t*, const char*, const char*);
|
||||
extern void e_proc_python(lex_t*, const char*, const char*);
|
||||
extern void e_proc_fakeroot(lex_t*, const char*, const char*);
|
||||
extern void e_def(lex_t*, const char*, const char*, const char*);
|
||||
extern void e_parse_error(lex_t*);
|
||||
|
||||
}
|
||||
#endif // PYTHON_OUTPUT_H
|
||||
96
bitbake/lib/bb/parse/parse_c/token.h
Normal file
96
bitbake/lib/bb/parse/parse_c/token.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
Copyright (C) 2005 Holger Hans Peter Freyther
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef TOKEN_H
|
||||
#define TOKEN_H
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#define PURE_METHOD
|
||||
|
||||
|
||||
/**
|
||||
* Special Value for End Of File Handling. We set it to
|
||||
* 1001 so we can have up to 1000 Terminal Symbols on
|
||||
* grammar. Currenlty we have around 20
|
||||
*/
|
||||
#define T_EOF 1001
|
||||
|
||||
struct token_t {
|
||||
const char* string()const PURE_METHOD;
|
||||
|
||||
static char* concatString(const char* l, const char* r);
|
||||
void assignString(char* str);
|
||||
void copyString(const char* str);
|
||||
|
||||
void release_this();
|
||||
|
||||
private:
|
||||
char *m_string;
|
||||
size_t m_stringLen;
|
||||
};
|
||||
|
||||
inline const char* token_t::string()const
|
||||
{
|
||||
return m_string;
|
||||
}
|
||||
|
||||
/*
|
||||
* append str to the current string
|
||||
*/
|
||||
inline char* token_t::concatString(const char* l, const char* r)
|
||||
{
|
||||
size_t cb = (l ? strlen (l) : 0) + strlen (r) + 1;
|
||||
char *r_sz = new char[cb];
|
||||
*r_sz = 0;
|
||||
|
||||
if (l)
|
||||
strcat (r_sz, l);
|
||||
strcat (r_sz, r);
|
||||
|
||||
return r_sz;
|
||||
}
|
||||
|
||||
inline void token_t::assignString(char* str)
|
||||
{
|
||||
m_string = str;
|
||||
m_stringLen = str ? strlen(str) : 0;
|
||||
}
|
||||
|
||||
inline void token_t::copyString(const char* str)
|
||||
{
|
||||
if( str ) {
|
||||
m_stringLen = strlen(str);
|
||||
m_string = new char[m_stringLen+1];
|
||||
strcpy(m_string, str);
|
||||
}
|
||||
}
|
||||
|
||||
inline void token_t::release_this()
|
||||
{
|
||||
delete m_string;
|
||||
m_string = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
417
bitbake/lib/bb/parse/parse_py/BBHandler.py
Normal file
417
bitbake/lib/bb/parse/parse_py/BBHandler.py
Normal file
@@ -0,0 +1,417 @@
|
||||
#!/usr/bin/env python
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
class for handling .bb files
|
||||
|
||||
Reads a .bb file and obtains its metadata
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
# Copyright (C) 2003, 2004 Phil Blundell
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import re, bb, os, sys, time
|
||||
import bb.fetch, bb.build, bb.utils
|
||||
from bb import data, fetch, methodpool
|
||||
|
||||
from ConfHandler import include, localpath, obtain, init
|
||||
from bb.parse import ParseError
|
||||
|
||||
__func_start_regexp__ = re.compile( r"(((?P<py>python)|(?P<fr>fakeroot))\s*)*(?P<func>[\w\.\-\+\{\}\$]+)?\s*\(\s*\)\s*{$" )
|
||||
__inherit_regexp__ = re.compile( r"inherit\s+(.+)" )
|
||||
__export_func_regexp__ = re.compile( r"EXPORT_FUNCTIONS\s+(.+)" )
|
||||
__addtask_regexp__ = re.compile("addtask\s+(?P<func>\w+)\s*((before\s*(?P<before>((.*(?=after))|(.*))))|(after\s*(?P<after>((.*(?=before))|(.*)))))*")
|
||||
__addhandler_regexp__ = re.compile( r"addhandler\s+(.+)" )
|
||||
__def_regexp__ = re.compile( r"def\s+(\w+).*:" )
|
||||
__python_func_regexp__ = re.compile( r"(\s+.*)|(^$)" )
|
||||
__word__ = re.compile(r"\S+")
|
||||
|
||||
__infunc__ = ""
|
||||
__inpython__ = False
|
||||
__body__ = []
|
||||
__classname__ = ""
|
||||
classes = [ None, ]
|
||||
|
||||
# We need to indicate EOF to the feeder. This code is so messy that
|
||||
# factoring it out to a close_parse_file method is out of question.
|
||||
# We will use the IN_PYTHON_EOF as an indicator to just close the method
|
||||
#
|
||||
# The two parts using it are tightly integrated anyway
|
||||
IN_PYTHON_EOF = -9999999999999
|
||||
|
||||
__parsed_methods__ = methodpool.get_parsed_dict()
|
||||
|
||||
def supports(fn, d):
|
||||
localfn = localpath(fn, d)
|
||||
return localfn[-3:] == ".bb" or localfn[-8:] == ".bbclass" or localfn[-4:] == ".inc"
|
||||
|
||||
def inherit(files, d):
|
||||
__inherit_cache = data.getVar('__inherit_cache', d) or []
|
||||
fn = ""
|
||||
lineno = 0
|
||||
files = data.expand(files, d)
|
||||
for file in files:
|
||||
if file[0] != "/" and file[-8:] != ".bbclass":
|
||||
file = os.path.join('classes', '%s.bbclass' % file)
|
||||
|
||||
if not file in __inherit_cache:
|
||||
bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s:%d: inheriting %s" % (fn, lineno, file))
|
||||
__inherit_cache.append( file )
|
||||
data.setVar('__inherit_cache', __inherit_cache, d)
|
||||
include(fn, file, d, "inherit")
|
||||
__inherit_cache = data.getVar('__inherit_cache', d) or []
|
||||
|
||||
def handle(fn, d, include = 0):
|
||||
global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __residue__
|
||||
__body__ = []
|
||||
__infunc__ = ""
|
||||
__classname__ = ""
|
||||
__residue__ = []
|
||||
|
||||
if include == 0:
|
||||
bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data)")
|
||||
else:
|
||||
bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data, include)")
|
||||
|
||||
(root, ext) = os.path.splitext(os.path.basename(fn))
|
||||
base_name = "%s%s" % (root,ext)
|
||||
init(d)
|
||||
|
||||
if ext == ".bbclass":
|
||||
__classname__ = root
|
||||
classes.append(__classname__)
|
||||
|
||||
if include != 0:
|
||||
oldfile = data.getVar('FILE', d)
|
||||
else:
|
||||
oldfile = None
|
||||
|
||||
fn = obtain(fn, d)
|
||||
bbpath = (data.getVar('BBPATH', d, 1) or '').split(':')
|
||||
if not os.path.isabs(fn):
|
||||
f = None
|
||||
for p in bbpath:
|
||||
j = os.path.join(p, fn)
|
||||
if os.access(j, os.R_OK):
|
||||
abs_fn = j
|
||||
f = open(j, 'r')
|
||||
break
|
||||
if f is None:
|
||||
raise IOError("file not found")
|
||||
else:
|
||||
f = open(fn,'r')
|
||||
abs_fn = fn
|
||||
|
||||
if ext != ".bbclass":
|
||||
bbpath.insert(0, os.path.dirname(abs_fn))
|
||||
data.setVar('BBPATH', ":".join(bbpath), d)
|
||||
|
||||
if include:
|
||||
bb.parse.mark_dependency(d, abs_fn)
|
||||
|
||||
if ext != ".bbclass":
|
||||
data.setVar('FILE', fn, d)
|
||||
i = (data.getVar("INHERIT", d, 1) or "").split()
|
||||
if not "base" in i and __classname__ != "base":
|
||||
i[0:0] = ["base"]
|
||||
inherit(i, d)
|
||||
|
||||
lineno = 0
|
||||
while 1:
|
||||
lineno = lineno + 1
|
||||
s = f.readline()
|
||||
if not s: break
|
||||
s = s.rstrip()
|
||||
feeder(lineno, s, fn, base_name, d)
|
||||
if __inpython__:
|
||||
# add a blank line to close out any python definition
|
||||
feeder(IN_PYTHON_EOF, "", fn, base_name, d)
|
||||
if ext == ".bbclass":
|
||||
classes.remove(__classname__)
|
||||
else:
|
||||
if include == 0:
|
||||
data.expandKeys(d)
|
||||
data.update_data(d)
|
||||
anonqueue = data.getVar("__anonqueue", d, 1) or []
|
||||
body = [x['content'] for x in anonqueue]
|
||||
flag = { 'python' : 1, 'func' : 1 }
|
||||
data.setVar("__anonfunc", "\n".join(body), d)
|
||||
data.setVarFlags("__anonfunc", flag, d)
|
||||
from bb import build
|
||||
try:
|
||||
t = data.getVar('T', d)
|
||||
data.setVar('T', '${TMPDIR}/', d)
|
||||
build.exec_func("__anonfunc", d)
|
||||
data.delVar('T', d)
|
||||
if t:
|
||||
data.setVar('T', t, d)
|
||||
except Exception, e:
|
||||
bb.msg.debug(1, bb.msg.domain.Parsing, "executing anonymous function: %s" % e)
|
||||
raise
|
||||
data.delVar("__anonqueue", d)
|
||||
data.delVar("__anonfunc", d)
|
||||
set_additional_vars(fn, d, include)
|
||||
data.update_data(d)
|
||||
|
||||
all_handlers = {}
|
||||
for var in data.getVar('__BBHANDLERS', d) or []:
|
||||
# try to add the handler
|
||||
# if we added it remember the choiche
|
||||
handler = data.getVar(var,d)
|
||||
if bb.event.register(var,handler) == bb.event.Registered:
|
||||
all_handlers[var] = handler
|
||||
|
||||
for var in data.getVar('__BBTASKS', d) or []:
|
||||
deps = data.getVarFlag(var, 'deps', d) or []
|
||||
postdeps = data.getVarFlag(var, 'postdeps', d) or []
|
||||
bb.build.add_task(var, deps, d)
|
||||
for p in postdeps:
|
||||
pdeps = data.getVarFlag(p, 'deps', d) or []
|
||||
pdeps.append(var)
|
||||
data.setVarFlag(p, 'deps', pdeps, d)
|
||||
bb.build.add_task(p, pdeps, d)
|
||||
|
||||
# now add the handlers
|
||||
if not len(all_handlers) == 0:
|
||||
data.setVar('__all_handlers__', all_handlers, d)
|
||||
|
||||
bbpath.pop(0)
|
||||
if oldfile:
|
||||
bb.data.setVar("FILE", oldfile, d)
|
||||
|
||||
# we have parsed the bb class now
|
||||
if ext == ".bbclass" or ext == ".inc":
|
||||
__parsed_methods__[base_name] = 1
|
||||
|
||||
return d
|
||||
|
||||
def feeder(lineno, s, fn, root, d):
|
||||
global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__,__infunc__, __body__, classes, bb, __residue__
|
||||
if __infunc__:
|
||||
if s == '}':
|
||||
__body__.append('')
|
||||
data.setVar(__infunc__, '\n'.join(__body__), d)
|
||||
data.setVarFlag(__infunc__, "func", 1, d)
|
||||
if __infunc__ == "__anonymous":
|
||||
anonqueue = bb.data.getVar("__anonqueue", d) or []
|
||||
anonitem = {}
|
||||
anonitem["content"] = bb.data.getVar("__anonymous", d)
|
||||
anonitem["flags"] = bb.data.getVarFlags("__anonymous", d)
|
||||
anonqueue.append(anonitem)
|
||||
bb.data.setVar("__anonqueue", anonqueue, d)
|
||||
bb.data.delVarFlags("__anonymous", d)
|
||||
bb.data.delVar("__anonymous", d)
|
||||
__infunc__ = ""
|
||||
__body__ = []
|
||||
else:
|
||||
__body__.append(s)
|
||||
return
|
||||
|
||||
if __inpython__:
|
||||
m = __python_func_regexp__.match(s)
|
||||
if m and lineno != IN_PYTHON_EOF:
|
||||
__body__.append(s)
|
||||
return
|
||||
else:
|
||||
# Note we will add root to parsedmethods after having parse
|
||||
# 'this' file. This means we will not parse methods from
|
||||
# bb classes twice
|
||||
if not root in __parsed_methods__:
|
||||
text = '\n'.join(__body__)
|
||||
methodpool.insert_method( root, text, fn )
|
||||
funcs = data.getVar('__functions__', d) or {}
|
||||
if not funcs.has_key( root ):
|
||||
funcs[root] = text
|
||||
else:
|
||||
funcs[root] = "%s\n%s" % (funcs[root], text)
|
||||
|
||||
data.setVar('__functions__', funcs, d)
|
||||
__body__ = []
|
||||
__inpython__ = False
|
||||
|
||||
if lineno == IN_PYTHON_EOF:
|
||||
return
|
||||
|
||||
# fall through
|
||||
|
||||
if s == '' or s[0] == '#': return # skip comments and empty lines
|
||||
|
||||
if s[-1] == '\\':
|
||||
__residue__.append(s[:-1])
|
||||
return
|
||||
|
||||
s = "".join(__residue__) + s
|
||||
__residue__ = []
|
||||
|
||||
m = __func_start_regexp__.match(s)
|
||||
if m:
|
||||
__infunc__ = m.group("func") or "__anonymous"
|
||||
key = __infunc__
|
||||
if data.getVar(key, d):
|
||||
# clean up old version of this piece of metadata, as its
|
||||
# flags could cause problems
|
||||
data.setVarFlag(key, 'python', None, d)
|
||||
data.setVarFlag(key, 'fakeroot', None, d)
|
||||
if m.group("py") is not None:
|
||||
data.setVarFlag(key, "python", "1", d)
|
||||
else:
|
||||
data.delVarFlag(key, "python", d)
|
||||
if m.group("fr") is not None:
|
||||
data.setVarFlag(key, "fakeroot", "1", d)
|
||||
else:
|
||||
data.delVarFlag(key, "fakeroot", d)
|
||||
return
|
||||
|
||||
m = __def_regexp__.match(s)
|
||||
if m:
|
||||
__body__.append(s)
|
||||
__inpython__ = True
|
||||
return
|
||||
|
||||
m = __export_func_regexp__.match(s)
|
||||
if m:
|
||||
fns = m.group(1)
|
||||
n = __word__.findall(fns)
|
||||
for f in n:
|
||||
allvars = []
|
||||
allvars.append(f)
|
||||
allvars.append(classes[-1] + "_" + f)
|
||||
|
||||
vars = [[ allvars[0], allvars[1] ]]
|
||||
if len(classes) > 1 and classes[-2] is not None:
|
||||
allvars.append(classes[-2] + "_" + f)
|
||||
vars = []
|
||||
vars.append([allvars[2], allvars[1]])
|
||||
vars.append([allvars[0], allvars[2]])
|
||||
|
||||
for (var, calledvar) in vars:
|
||||
if data.getVar(var, d) and not data.getVarFlag(var, 'export_func', d):
|
||||
continue
|
||||
|
||||
if data.getVar(var, d):
|
||||
data.setVarFlag(var, 'python', None, d)
|
||||
data.setVarFlag(var, 'func', None, d)
|
||||
|
||||
for flag in [ "func", "python" ]:
|
||||
if data.getVarFlag(calledvar, flag, d):
|
||||
data.setVarFlag(var, flag, data.getVarFlag(calledvar, flag, d), d)
|
||||
for flag in [ "dirs" ]:
|
||||
if data.getVarFlag(var, flag, d):
|
||||
data.setVarFlag(calledvar, flag, data.getVarFlag(var, flag, d), d)
|
||||
|
||||
if data.getVarFlag(calledvar, "python", d):
|
||||
data.setVar(var, "\tbb.build.exec_func('" + calledvar + "', d)\n", d)
|
||||
else:
|
||||
data.setVar(var, "\t" + calledvar + "\n", d)
|
||||
data.setVarFlag(var, 'export_func', '1', d)
|
||||
|
||||
return
|
||||
|
||||
m = __addtask_regexp__.match(s)
|
||||
if m:
|
||||
func = m.group("func")
|
||||
before = m.group("before")
|
||||
after = m.group("after")
|
||||
if func is None:
|
||||
return
|
||||
var = "do_" + func
|
||||
|
||||
data.setVarFlag(var, "task", 1, d)
|
||||
|
||||
bbtasks = data.getVar('__BBTASKS', d) or []
|
||||
bbtasks.append(var)
|
||||
data.setVar('__BBTASKS', bbtasks, d)
|
||||
|
||||
if after is not None:
|
||||
# set up deps for function
|
||||
data.setVarFlag(var, "deps", after.split(), d)
|
||||
if before is not None:
|
||||
# set up things that depend on this func
|
||||
data.setVarFlag(var, "postdeps", before.split(), d)
|
||||
return
|
||||
|
||||
m = __addhandler_regexp__.match(s)
|
||||
if m:
|
||||
fns = m.group(1)
|
||||
hs = __word__.findall(fns)
|
||||
bbhands = data.getVar('__BBHANDLERS', d) or []
|
||||
for h in hs:
|
||||
bbhands.append(h)
|
||||
data.setVarFlag(h, "handler", 1, d)
|
||||
data.setVar('__BBHANDLERS', bbhands, d)
|
||||
return
|
||||
|
||||
m = __inherit_regexp__.match(s)
|
||||
if m:
|
||||
|
||||
files = m.group(1)
|
||||
n = __word__.findall(files)
|
||||
inherit(n, d)
|
||||
return
|
||||
|
||||
from bb.parse import ConfHandler
|
||||
return ConfHandler.feeder(lineno, s, fn, d)
|
||||
|
||||
__pkgsplit_cache__={}
|
||||
def vars_from_file(mypkg, d):
|
||||
if not mypkg:
|
||||
return (None, None, None)
|
||||
if mypkg in __pkgsplit_cache__:
|
||||
return __pkgsplit_cache__[mypkg]
|
||||
|
||||
myfile = os.path.splitext(os.path.basename(mypkg))
|
||||
parts = myfile[0].split('_')
|
||||
__pkgsplit_cache__[mypkg] = parts
|
||||
if len(parts) > 3:
|
||||
raise ParseError("Unable to generate default variables from the filename: %s (too many underscores)" % mypkg)
|
||||
exp = 3 - len(parts)
|
||||
tmplist = []
|
||||
while exp != 0:
|
||||
exp -= 1
|
||||
tmplist.append(None)
|
||||
parts.extend(tmplist)
|
||||
return parts
|
||||
|
||||
def set_additional_vars(file, d, include):
|
||||
"""Deduce rest of variables, e.g. ${A} out of ${SRC_URI}"""
|
||||
|
||||
bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s: set_additional_vars" % file)
|
||||
|
||||
src_uri = data.getVar('SRC_URI', d, 1)
|
||||
if not src_uri:
|
||||
return
|
||||
|
||||
a = (data.getVar('A', d, 1) or '').split()
|
||||
|
||||
from bb import fetch
|
||||
try:
|
||||
fetch.init(src_uri.split(), d)
|
||||
except fetch.NoMethodError:
|
||||
pass
|
||||
except bb.MalformedUrl,e:
|
||||
raise ParseError("Unable to generate local paths for SRC_URI due to malformed uri: %s" % e)
|
||||
|
||||
a += fetch.localpaths(d)
|
||||
del fetch
|
||||
data.setVar('A', " ".join(a), d)
|
||||
|
||||
|
||||
# Add us to the handlers list
|
||||
from bb.parse import handlers
|
||||
handlers.append({'supports': supports, 'handle': handle, 'init': init})
|
||||
del handlers
|
||||
217
bitbake/lib/bb/parse/parse_py/ConfHandler.py
Normal file
217
bitbake/lib/bb/parse/parse_py/ConfHandler.py
Normal file
@@ -0,0 +1,217 @@
|
||||
#!/usr/bin/env python
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
class for handling configuration data files
|
||||
|
||||
Reads a .conf file and obtains its metadata
|
||||
|
||||
"""
|
||||
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
# Copyright (C) 2003, 2004 Phil Blundell
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import re, bb.data, os, sys
|
||||
from bb.parse import ParseError
|
||||
|
||||
#__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}]+)\s*(?P<colon>:)?(?P<ques>\?)?=\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$")
|
||||
__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}/]+)(\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?\s*((?P<colon>:=)|(?P<ques>\?=)|(?P<append>\+=)|(?P<prepend>=\+)|(?P<predot>=\.)|(?P<postdot>\.=)|=)\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$")
|
||||
__include_regexp__ = re.compile( r"include\s+(.+)" )
|
||||
__require_regexp__ = re.compile( r"require\s+(.+)" )
|
||||
|
||||
def init(data):
|
||||
if not bb.data.getVar('TOPDIR', data):
|
||||
bb.data.setVar('TOPDIR', os.getcwd(), data)
|
||||
if not bb.data.getVar('BBPATH', data):
|
||||
bb.data.setVar('BBPATH', os.path.join(sys.prefix, 'share', 'bitbake'), data)
|
||||
|
||||
def supports(fn, d):
|
||||
return localpath(fn, d)[-5:] == ".conf"
|
||||
|
||||
def localpath(fn, d):
|
||||
if os.path.exists(fn):
|
||||
return fn
|
||||
|
||||
localfn = None
|
||||
try:
|
||||
localfn = bb.fetch.localpath(fn, d)
|
||||
except bb.MalformedUrl:
|
||||
pass
|
||||
|
||||
if not localfn:
|
||||
localfn = fn
|
||||
return localfn
|
||||
|
||||
def obtain(fn, data):
|
||||
import sys, bb
|
||||
fn = bb.data.expand(fn, data)
|
||||
localfn = bb.data.expand(localpath(fn, data), data)
|
||||
|
||||
if localfn != fn:
|
||||
dldir = bb.data.getVar('DL_DIR', data, 1)
|
||||
if not dldir:
|
||||
bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: DL_DIR not defined")
|
||||
return localfn
|
||||
bb.mkdirhier(dldir)
|
||||
try:
|
||||
bb.fetch.init([fn])
|
||||
except bb.fetch.NoMethodError:
|
||||
(type, value, traceback) = sys.exc_info()
|
||||
bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: no method: %s" % value)
|
||||
return localfn
|
||||
|
||||
try:
|
||||
bb.fetch.go(data)
|
||||
except bb.fetch.MissingParameterError:
|
||||
(type, value, traceback) = sys.exc_info()
|
||||
bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: missing parameters: %s" % value)
|
||||
return localfn
|
||||
except bb.fetch.FetchError:
|
||||
(type, value, traceback) = sys.exc_info()
|
||||
bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: failed: %s" % value)
|
||||
return localfn
|
||||
return localfn
|
||||
|
||||
|
||||
def include(oldfn, fn, data, error_out):
|
||||
"""
|
||||
|
||||
error_out If True a ParseError will be reaised if the to be included
|
||||
"""
|
||||
if oldfn == fn: # prevent infinate recursion
|
||||
return None
|
||||
|
||||
import bb
|
||||
fn = bb.data.expand(fn, data)
|
||||
oldfn = bb.data.expand(oldfn, data)
|
||||
|
||||
from bb.parse import handle
|
||||
try:
|
||||
ret = handle(fn, data, True)
|
||||
except IOError:
|
||||
if error_out:
|
||||
raise ParseError("Could not %(error_out)s file %(fn)s" % vars() )
|
||||
bb.msg.debug(2, bb.msg.domain.Parsing, "CONF file '%s' not found" % fn)
|
||||
|
||||
def handle(fn, data, include = 0):
|
||||
if include:
|
||||
inc_string = "including"
|
||||
else:
|
||||
inc_string = "reading"
|
||||
init(data)
|
||||
|
||||
if include == 0:
|
||||
bb.data.inheritFromOS(data)
|
||||
oldfile = None
|
||||
else:
|
||||
oldfile = bb.data.getVar('FILE', data)
|
||||
|
||||
fn = obtain(fn, data)
|
||||
if not os.path.isabs(fn):
|
||||
f = None
|
||||
bbpath = bb.data.getVar("BBPATH", data, 1) or []
|
||||
for p in bbpath.split(":"):
|
||||
currname = os.path.join(p, fn)
|
||||
if os.access(currname, os.R_OK):
|
||||
f = open(currname, 'r')
|
||||
abs_fn = currname
|
||||
bb.msg.debug(2, bb.msg.domain.Parsing, "CONF %s %s" % (inc_string, currname))
|
||||
break
|
||||
if f is None:
|
||||
raise IOError("file '%s' not found" % fn)
|
||||
else:
|
||||
f = open(fn,'r')
|
||||
bb.msg.debug(1, bb.msg.domain.Parsing, "CONF %s %s" % (inc_string,fn))
|
||||
abs_fn = fn
|
||||
|
||||
if include:
|
||||
bb.parse.mark_dependency(data, abs_fn)
|
||||
|
||||
lineno = 0
|
||||
bb.data.setVar('FILE', fn, data)
|
||||
while 1:
|
||||
lineno = lineno + 1
|
||||
s = f.readline()
|
||||
if not s: break
|
||||
w = s.strip()
|
||||
if not w: continue # skip empty lines
|
||||
s = s.rstrip()
|
||||
if s[0] == '#': continue # skip comments
|
||||
while s[-1] == '\\':
|
||||
s2 = f.readline()[:-1].strip()
|
||||
lineno = lineno + 1
|
||||
s = s[:-1] + s2
|
||||
feeder(lineno, s, fn, data)
|
||||
|
||||
if oldfile:
|
||||
bb.data.setVar('FILE', oldfile, data)
|
||||
return data
|
||||
|
||||
def feeder(lineno, s, fn, data):
|
||||
def getFunc(groupd, key, data):
|
||||
if 'flag' in groupd and groupd['flag'] != None:
|
||||
return bb.data.getVarFlag(key, groupd['flag'], data)
|
||||
else:
|
||||
return bb.data.getVar(key, data)
|
||||
|
||||
m = __config_regexp__.match(s)
|
||||
if m:
|
||||
groupd = m.groupdict()
|
||||
key = groupd["var"]
|
||||
if "exp" in groupd and groupd["exp"] != None:
|
||||
bb.data.setVarFlag(key, "export", 1, data)
|
||||
if "ques" in groupd and groupd["ques"] != None:
|
||||
val = getFunc(groupd, key, data)
|
||||
if val == None:
|
||||
val = groupd["value"]
|
||||
elif "colon" in groupd and groupd["colon"] != None:
|
||||
val = bb.data.expand(groupd["value"], data)
|
||||
elif "append" in groupd and groupd["append"] != None:
|
||||
val = "%s %s" % ((getFunc(groupd, key, data) or ""), groupd["value"])
|
||||
elif "prepend" in groupd and groupd["prepend"] != None:
|
||||
val = "%s %s" % (groupd["value"], (getFunc(groupd, key, data) or ""))
|
||||
elif "postdot" in groupd and groupd["postdot"] != None:
|
||||
val = "%s%s" % ((getFunc(groupd, key, data) or ""), groupd["value"])
|
||||
elif "predot" in groupd and groupd["predot"] != None:
|
||||
val = "%s%s" % (groupd["value"], (getFunc(groupd, key, data) or ""))
|
||||
else:
|
||||
val = groupd["value"]
|
||||
if 'flag' in groupd and groupd['flag'] != None:
|
||||
bb.msg.debug(3, bb.msg.domain.Parsing, "setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val))
|
||||
bb.data.setVarFlag(key, groupd['flag'], val, data)
|
||||
else:
|
||||
bb.data.setVar(key, val, data)
|
||||
return
|
||||
|
||||
m = __include_regexp__.match(s)
|
||||
if m:
|
||||
s = bb.data.expand(m.group(1), data)
|
||||
bb.msg.debug(3, bb.msg.domain.Parsing, "CONF %s:%d: including %s" % (fn, lineno, s))
|
||||
include(fn, s, data, False)
|
||||
return
|
||||
|
||||
m = __require_regexp__.match(s)
|
||||
if m:
|
||||
s = bb.data.expand(m.group(1), data)
|
||||
include(fn, s, data, "include required")
|
||||
return
|
||||
|
||||
raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s));
|
||||
|
||||
# Add us to the handlers list
|
||||
from bb.parse import handlers
|
||||
handlers.append({'supports': supports, 'handle': handle, 'init': init})
|
||||
del handlers
|
||||
33
bitbake/lib/bb/parse/parse_py/__init__.py
Normal file
33
bitbake/lib/bb/parse/parse_py/__init__.py
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake Parsers
|
||||
|
||||
File parsers for the BitBake build tools.
|
||||
|
||||
"""
|
||||
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
# Copyright (C) 2003, 2004 Phil Blundell
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Based on functions from the base bb module, Copyright 2003 Holger Schurig
|
||||
__version__ = '1.0'
|
||||
|
||||
__all__ = [ 'ConfHandler', 'BBHandler']
|
||||
|
||||
import ConfHandler
|
||||
import BBHandler
|
||||
213
bitbake/lib/bb/providers.py
Normal file
213
bitbake/lib/bb/providers.py
Normal file
@@ -0,0 +1,213 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
#
|
||||
# Copyright (C) 2003, 2004 Chris Larson
|
||||
# Copyright (C) 2003, 2004 Phil Blundell
|
||||
# Copyright (C) 2003 - 2005 Michael 'Mickey' Lauer
|
||||
# Copyright (C) 2005 Holger Hans Peter Freyther
|
||||
# Copyright (C) 2005 ROAD GmbH
|
||||
# Copyright (C) 2006 Richard Purdie
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import os, re
|
||||
from bb import data, utils
|
||||
import bb
|
||||
|
||||
class NoProvider(Exception):
|
||||
"""Exception raised when no provider of a build dependency can be found"""
|
||||
|
||||
class NoRProvider(Exception):
|
||||
"""Exception raised when no provider of a runtime dependency can be found"""
|
||||
|
||||
def findBestProvider(pn, cfgData, dataCache, pkg_pn = None, item = None):
|
||||
"""
|
||||
If there is a PREFERRED_VERSION, find the highest-priority bbfile
|
||||
providing that version. If not, find the latest version provided by
|
||||
an bbfile in the highest-priority set.
|
||||
"""
|
||||
if not pkg_pn:
|
||||
pkg_pn = dataCache.pkg_pn
|
||||
|
||||
files = pkg_pn[pn]
|
||||
priorities = {}
|
||||
for f in files:
|
||||
priority = dataCache.bbfile_priority[f]
|
||||
if priority not in priorities:
|
||||
priorities[priority] = []
|
||||
priorities[priority].append(f)
|
||||
p_list = priorities.keys()
|
||||
p_list.sort(lambda a, b: a - b)
|
||||
tmp_pn = []
|
||||
for p in p_list:
|
||||
tmp_pn = [priorities[p]] + tmp_pn
|
||||
|
||||
preferred_file = None
|
||||
|
||||
localdata = data.createCopy(cfgData)
|
||||
bb.data.setVar('OVERRIDES', "%s:%s" % (pn, data.getVar('OVERRIDES', localdata)), localdata)
|
||||
bb.data.update_data(localdata)
|
||||
|
||||
preferred_v = bb.data.getVar('PREFERRED_VERSION_%s' % pn, localdata, True)
|
||||
if preferred_v:
|
||||
m = re.match('(\d+:)*(.*)(_.*)*', preferred_v)
|
||||
if m:
|
||||
if m.group(1):
|
||||
preferred_e = int(m.group(1)[:-1])
|
||||
else:
|
||||
preferred_e = None
|
||||
preferred_v = m.group(2)
|
||||
if m.group(3):
|
||||
preferred_r = m.group(3)[1:]
|
||||
else:
|
||||
preferred_r = None
|
||||
else:
|
||||
preferred_e = None
|
||||
preferred_r = None
|
||||
|
||||
for file_set in tmp_pn:
|
||||
for f in file_set:
|
||||
pe,pv,pr = dataCache.pkg_pepvpr[f]
|
||||
if preferred_v == pv and (preferred_r == pr or preferred_r == None) and (preferred_e == pe or preferred_e == None):
|
||||
preferred_file = f
|
||||
preferred_ver = (pe, pv, pr)
|
||||
break
|
||||
if preferred_file:
|
||||
break;
|
||||
if preferred_r:
|
||||
pv_str = '%s-%s' % (preferred_v, preferred_r)
|
||||
else:
|
||||
pv_str = preferred_v
|
||||
if not (preferred_e is None):
|
||||
pv_str = '%s:%s' % (preferred_e, pv_str)
|
||||
itemstr = ""
|
||||
if item:
|
||||
itemstr = " (for item %s)" % item
|
||||
if preferred_file is None:
|
||||
bb.msg.note(1, bb.msg.domain.Provider, "preferred version %s of %s not available%s" % (pv_str, pn, itemstr))
|
||||
else:
|
||||
bb.msg.debug(1, bb.msg.domain.Provider, "selecting %s as PREFERRED_VERSION %s of package %s%s" % (preferred_file, pv_str, pn, itemstr))
|
||||
|
||||
del localdata
|
||||
|
||||
# get highest priority file set
|
||||
files = tmp_pn[0]
|
||||
latest = None
|
||||
latest_p = 0
|
||||
latest_f = None
|
||||
for file_name in files:
|
||||
pe,pv,pr = dataCache.pkg_pepvpr[file_name]
|
||||
dp = dataCache.pkg_dp[file_name]
|
||||
|
||||
if (latest is None) or ((latest_p == dp) and (utils.vercmp(latest, (pe, pv, pr)) < 0)) or (dp > latest_p):
|
||||
latest = (pe, pv, pr)
|
||||
latest_f = file_name
|
||||
latest_p = dp
|
||||
if preferred_file is None:
|
||||
preferred_file = latest_f
|
||||
preferred_ver = latest
|
||||
|
||||
return (latest,latest_f,preferred_ver, preferred_file)
|
||||
|
||||
def filterProviders(providers, item, cfgData, dataCache):
|
||||
"""
|
||||
Take a list of providers and filter/reorder according to the
|
||||
environment variables and previous build results
|
||||
"""
|
||||
eligible = []
|
||||
preferred_versions = {}
|
||||
|
||||
# Collate providers by PN
|
||||
pkg_pn = {}
|
||||
for p in providers:
|
||||
pn = dataCache.pkg_fn[p]
|
||||
if pn not in pkg_pn:
|
||||
pkg_pn[pn] = []
|
||||
pkg_pn[pn].append(p)
|
||||
|
||||
bb.msg.debug(1, bb.msg.domain.Provider, "providers for %s are: %s" % (item, pkg_pn.keys()))
|
||||
|
||||
for pn in pkg_pn.keys():
|
||||
preferred_versions[pn] = bb.providers.findBestProvider(pn, cfgData, dataCache, pkg_pn, item)[2:4]
|
||||
eligible.append(preferred_versions[pn][1])
|
||||
|
||||
if len(eligible) == 0:
|
||||
bb.msg.error(bb.msg.domain.Provider, "no eligible providers for %s" % item)
|
||||
return 0
|
||||
|
||||
|
||||
# If pn == item, give it a slight default preference
|
||||
# This means PREFERRED_PROVIDER_foobar defaults to foobar if available
|
||||
for p in providers:
|
||||
pn = dataCache.pkg_fn[p]
|
||||
if pn != item:
|
||||
continue
|
||||
(newvers, fn) = preferred_versions[pn]
|
||||
if not fn in eligible:
|
||||
continue
|
||||
eligible.remove(fn)
|
||||
eligible = [fn] + eligible
|
||||
|
||||
# look to see if one of them is already staged, or marked as preferred.
|
||||
# if so, bump it to the head of the queue
|
||||
for p in providers:
|
||||
pn = dataCache.pkg_fn[p]
|
||||
pe, pv, pr = dataCache.pkg_pepvpr[p]
|
||||
|
||||
stamp = '%s.do_populate_staging' % dataCache.stamp[p]
|
||||
if os.path.exists(stamp):
|
||||
(newvers, fn) = preferred_versions[pn]
|
||||
if not fn in eligible:
|
||||
# package was made ineligible by already-failed check
|
||||
continue
|
||||
oldver = "%s-%s" % (pv, pr)
|
||||
if pe > 0:
|
||||
oldver = "%s:%s" % (pe, oldver)
|
||||
newver = "%s-%s" % (newvers[1], newvers[2])
|
||||
if newvers[0] > 0:
|
||||
newver = "%s:%s" % (newvers[0], newver)
|
||||
if (newver != oldver):
|
||||
extra_chat = "%s (%s) already staged but upgrading to %s to satisfy %s" % (pn, oldver, newver, item)
|
||||
else:
|
||||
extra_chat = "Selecting already-staged %s (%s) to satisfy %s" % (pn, oldver, item)
|
||||
|
||||
bb.msg.note(2, bb.msg.domain.Provider, "%s" % extra_chat)
|
||||
eligible.remove(fn)
|
||||
eligible = [fn] + eligible
|
||||
break
|
||||
|
||||
return eligible
|
||||
|
||||
def getRuntimeProviders(dataCache, rdepend):
|
||||
"""
|
||||
Return any providers of runtime dependency
|
||||
"""
|
||||
rproviders = []
|
||||
|
||||
if rdepend in dataCache.rproviders:
|
||||
rproviders += dataCache.rproviders[rdepend]
|
||||
|
||||
if rdepend in dataCache.packages:
|
||||
rproviders += dataCache.packages[rdepend]
|
||||
|
||||
if rproviders:
|
||||
return rproviders
|
||||
|
||||
# Only search dynamic packages if we can't find anything in other variables
|
||||
for pattern in dataCache.packages_dynamic:
|
||||
regexp = re.compile(pattern)
|
||||
if regexp.match(rdepend):
|
||||
rproviders += dataCache.packages_dynamic[pattern]
|
||||
|
||||
return rproviders
|
||||
590
bitbake/lib/bb/runqueue.py
Normal file
590
bitbake/lib/bb/runqueue.py
Normal file
@@ -0,0 +1,590 @@
|
||||
#!/usr/bin/env python
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake 'RunQueue' implementation
|
||||
|
||||
Handles preparation and execution of a queue of tasks
|
||||
"""
|
||||
|
||||
# Copyright (C) 2006 Richard Purdie
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
from bb import msg, data, fetch, event, mkdirhier, utils
|
||||
from sets import Set
|
||||
import bb, os, sys
|
||||
import signal
|
||||
|
||||
class TaskFailure(Exception):
|
||||
"""Exception raised when a task in a runqueue fails"""
|
||||
def __init__(self, x):
|
||||
self.args = x
|
||||
|
||||
|
||||
class RunQueueStats:
|
||||
"""
|
||||
Holds statistics on the tasks handled by the associated runQueue
|
||||
"""
|
||||
def __init__(self):
|
||||
self.completed = 0
|
||||
self.skipped = 0
|
||||
self.failed = 0
|
||||
|
||||
def taskFailed(self):
|
||||
self.failed = self.failed + 1
|
||||
|
||||
def taskCompleted(self):
|
||||
self.completed = self.completed + 1
|
||||
|
||||
def taskSkipped(self):
|
||||
self.skipped = self.skipped + 1
|
||||
|
||||
class RunQueue:
|
||||
"""
|
||||
BitBake Run Queue implementation
|
||||
"""
|
||||
def __init__(self, cooker, cfgData, dataCache, taskData, targets):
|
||||
self.reset_runqueue()
|
||||
self.cooker = cooker
|
||||
self.dataCache = dataCache
|
||||
self.taskData = taskData
|
||||
self.targets = targets
|
||||
|
||||
self.number_tasks = int(bb.data.getVar("BB_NUMBER_THREADS", cfgData) or 1)
|
||||
|
||||
def reset_runqueue(self):
|
||||
|
||||
self.runq_fnid = []
|
||||
self.runq_task = []
|
||||
self.runq_depends = []
|
||||
self.runq_revdeps = []
|
||||
self.runq_weight = []
|
||||
self.prio_map = []
|
||||
|
||||
def get_user_idstring(self, task):
|
||||
fn = self.taskData.fn_index[self.runq_fnid[task]]
|
||||
taskname = self.runq_task[task]
|
||||
return "%s, %s" % (fn, taskname)
|
||||
|
||||
def prepare_runqueue(self):
|
||||
"""
|
||||
Turn a set of taskData into a RunQueue and compute data needed
|
||||
to optimise the execution order.
|
||||
"""
|
||||
|
||||
depends = []
|
||||
runq_weight1 = []
|
||||
runq_build = []
|
||||
runq_done = []
|
||||
|
||||
taskData = self.taskData
|
||||
|
||||
if len(taskData.tasks_name) == 0:
|
||||
# Nothing to do
|
||||
return
|
||||
|
||||
bb.msg.note(1, bb.msg.domain.RunQueue, "Preparing runqueue")
|
||||
|
||||
for task in range(len(taskData.tasks_name)):
|
||||
fnid = taskData.tasks_fnid[task]
|
||||
fn = taskData.fn_index[fnid]
|
||||
task_deps = self.dataCache.task_deps[fn]
|
||||
|
||||
if fnid not in taskData.failed_fnids:
|
||||
|
||||
depends = taskData.tasks_tdepends[task]
|
||||
|
||||
# Resolve Depends
|
||||
if 'deptask' in task_deps and taskData.tasks_name[task] in task_deps['deptask']:
|
||||
taskname = task_deps['deptask'][taskData.tasks_name[task]]
|
||||
for depid in taskData.depids[fnid]:
|
||||
if depid in taskData.build_targets:
|
||||
depdata = taskData.build_targets[depid][0]
|
||||
if depdata:
|
||||
dep = taskData.fn_index[depdata]
|
||||
depends.append(taskData.gettask_id(dep, taskname))
|
||||
|
||||
# Resolve Runtime Depends
|
||||
if 'rdeptask' in task_deps and taskData.tasks_name[task] in task_deps['rdeptask']:
|
||||
taskname = task_deps['rdeptask'][taskData.tasks_name[task]]
|
||||
for depid in taskData.rdepids[fnid]:
|
||||
if depid in taskData.run_targets:
|
||||
depdata = taskData.run_targets[depid][0]
|
||||
if depdata:
|
||||
dep = taskData.fn_index[depdata]
|
||||
depends.append(taskData.gettask_id(dep, taskname))
|
||||
|
||||
idepends = taskData.tasks_idepends[task]
|
||||
for idepend in idepends:
|
||||
depid = int(idepend.split(":")[0])
|
||||
if depid in taskData.build_targets:
|
||||
depdata = taskData.build_targets[depid][0]
|
||||
if depdata:
|
||||
dep = taskData.fn_index[depdata]
|
||||
depends.append(taskData.gettask_id(dep, idepend.split(":")[1]))
|
||||
|
||||
def add_recursive_build(depid):
|
||||
"""
|
||||
Add build depends of depid to depends
|
||||
(if we've not see it before)
|
||||
(calls itself recursively)
|
||||
"""
|
||||
if str(depid) in dep_seen:
|
||||
return
|
||||
dep_seen.append(depid)
|
||||
if depid in taskData.build_targets:
|
||||
depdata = taskData.build_targets[depid][0]
|
||||
if depdata:
|
||||
dep = taskData.fn_index[depdata]
|
||||
# Need to avoid creating new tasks here
|
||||
taskid = taskData.gettask_id(dep, taskname, False)
|
||||
if taskid:
|
||||
depends.append(taskid)
|
||||
fnid = taskData.tasks_fnid[taskid]
|
||||
else:
|
||||
fnid = taskData.getfn_id(dep)
|
||||
for nextdepid in taskData.depids[fnid]:
|
||||
if nextdepid not in dep_seen:
|
||||
add_recursive_build(nextdepid)
|
||||
for nextdepid in taskData.rdepids[fnid]:
|
||||
if nextdepid not in rdep_seen:
|
||||
add_recursive_run(nextdepid)
|
||||
|
||||
def add_recursive_run(rdepid):
|
||||
"""
|
||||
Add runtime depends of rdepid to depends
|
||||
(if we've not see it before)
|
||||
(calls itself recursively)
|
||||
"""
|
||||
if str(rdepid) in rdep_seen:
|
||||
return
|
||||
rdep_seen.append(rdepid)
|
||||
if rdepid in taskData.run_targets:
|
||||
depdata = taskData.run_targets[rdepid][0]
|
||||
if depdata:
|
||||
dep = taskData.fn_index[depdata]
|
||||
# Need to avoid creating new tasks here
|
||||
taskid = taskData.gettask_id(dep, taskname, False)
|
||||
if taskid:
|
||||
depends.append(taskid)
|
||||
fnid = taskData.tasks_fnid[taskid]
|
||||
else:
|
||||
fnid = taskData.getfn_id(dep)
|
||||
for nextdepid in taskData.depids[fnid]:
|
||||
if nextdepid not in dep_seen:
|
||||
add_recursive_build(nextdepid)
|
||||
for nextdepid in taskData.rdepids[fnid]:
|
||||
if nextdepid not in rdep_seen:
|
||||
add_recursive_run(nextdepid)
|
||||
|
||||
|
||||
# Resolve Recursive Runtime Depends
|
||||
# Also includes all Build Depends (and their runtime depends)
|
||||
if 'recrdeptask' in task_deps and taskData.tasks_name[task] in task_deps['recrdeptask']:
|
||||
for taskname in task_deps['recrdeptask'][taskData.tasks_name[task]].split():
|
||||
dep_seen = []
|
||||
rdep_seen = []
|
||||
for depid in taskData.depids[fnid]:
|
||||
add_recursive_build(depid)
|
||||
for rdepid in taskData.rdepids[fnid]:
|
||||
add_recursive_run(rdepid)
|
||||
|
||||
#Prune self references
|
||||
if task in depends:
|
||||
newdep = []
|
||||
bb.msg.debug(2, bb.msg.domain.RunQueue, "Task %s (%s %s) contains self reference! %s" % (task, taskData.fn_index[taskData.tasks_fnid[task]], taskData.tasks_name[task], depends))
|
||||
for dep in depends:
|
||||
if task != dep:
|
||||
newdep.append(dep)
|
||||
depends = newdep
|
||||
|
||||
|
||||
self.runq_fnid.append(taskData.tasks_fnid[task])
|
||||
self.runq_task.append(taskData.tasks_name[task])
|
||||
self.runq_depends.append(Set(depends))
|
||||
self.runq_revdeps.append(Set())
|
||||
self.runq_weight.append(0)
|
||||
|
||||
runq_weight1.append(0)
|
||||
runq_build.append(0)
|
||||
runq_done.append(0)
|
||||
|
||||
bb.msg.note(2, bb.msg.domain.RunQueue, "Marking Active Tasks")
|
||||
|
||||
def mark_active(listid, depth):
|
||||
"""
|
||||
Mark an item as active along with its depends
|
||||
(calls itself recursively)
|
||||
"""
|
||||
|
||||
if runq_build[listid] == 1:
|
||||
return
|
||||
|
||||
runq_build[listid] = 1
|
||||
|
||||
depends = self.runq_depends[listid]
|
||||
for depend in depends:
|
||||
mark_active(depend, depth+1)
|
||||
|
||||
for target in self.targets:
|
||||
targetid = taskData.getbuild_id(target[0])
|
||||
|
||||
if targetid not in taskData.build_targets:
|
||||
continue
|
||||
|
||||
if targetid in taskData.failed_deps:
|
||||
continue
|
||||
|
||||
fnid = taskData.build_targets[targetid][0]
|
||||
|
||||
# Remove stamps for targets if force mode active
|
||||
if self.cooker.configuration.force:
|
||||
fn = taskData.fn_index[fnid]
|
||||
bb.msg.note(2, bb.msg.domain.RunQueue, "Remove stamp %s, %s" % (target[1], fn))
|
||||
bb.build.del_stamp(target[1], self.dataCache, fn)
|
||||
|
||||
if fnid in taskData.failed_fnids:
|
||||
continue
|
||||
|
||||
listid = taskData.tasks_lookup[fnid][target[1]]
|
||||
|
||||
mark_active(listid, 1)
|
||||
|
||||
# Prune inactive tasks
|
||||
maps = []
|
||||
delcount = 0
|
||||
for listid in range(len(self.runq_fnid)):
|
||||
if runq_build[listid-delcount] == 1:
|
||||
maps.append(listid-delcount)
|
||||
else:
|
||||
del self.runq_fnid[listid-delcount]
|
||||
del self.runq_task[listid-delcount]
|
||||
del self.runq_depends[listid-delcount]
|
||||
del self.runq_weight[listid-delcount]
|
||||
del runq_weight1[listid-delcount]
|
||||
del runq_build[listid-delcount]
|
||||
del runq_done[listid-delcount]
|
||||
del self.runq_revdeps[listid-delcount]
|
||||
delcount = delcount + 1
|
||||
maps.append(-1)
|
||||
|
||||
if len(self.runq_fnid) == 0:
|
||||
if not taskData.abort:
|
||||
bb.msg.note(1, bb.msg.domain.RunQueue, "All possible tasks have been run but build incomplete (--continue mode). See errors above for incomplete tasks.")
|
||||
return
|
||||
bb.msg.fatal(bb.msg.domain.RunQueue, "No active tasks and not in --continue mode?! Please report this bug.")
|
||||
|
||||
bb.msg.note(2, bb.msg.domain.RunQueue, "Pruned %s inactive tasks, %s left" % (delcount, len(self.runq_fnid)))
|
||||
|
||||
for listid in range(len(self.runq_fnid)):
|
||||
newdeps = []
|
||||
origdeps = self.runq_depends[listid]
|
||||
for origdep in origdeps:
|
||||
if maps[origdep] == -1:
|
||||
bb.msg.fatal(bb.msg.domain.RunQueue, "Invalid mapping - Should never happen!")
|
||||
newdeps.append(maps[origdep])
|
||||
self.runq_depends[listid] = Set(newdeps)
|
||||
|
||||
bb.msg.note(2, bb.msg.domain.RunQueue, "Assign Weightings")
|
||||
|
||||
for listid in range(len(self.runq_fnid)):
|
||||
for dep in self.runq_depends[listid]:
|
||||
self.runq_revdeps[dep].add(listid)
|
||||
|
||||
endpoints = []
|
||||
for listid in range(len(self.runq_fnid)):
|
||||
revdeps = self.runq_revdeps[listid]
|
||||
if len(revdeps) == 0:
|
||||
runq_done[listid] = 1
|
||||
self.runq_weight[listid] = 1
|
||||
endpoints.append(listid)
|
||||
for dep in revdeps:
|
||||
if dep in self.runq_depends[listid]:
|
||||
#self.dump_data(taskData)
|
||||
bb.msg.fatal(bb.msg.domain.RunQueue, "Task %s (%s) has circular dependency on %s (%s)" % (taskData.fn_index[self.runq_fnid[dep]], self.runq_task[dep] , taskData.fn_index[self.runq_fnid[listid]], self.runq_task[listid]))
|
||||
runq_weight1[listid] = len(revdeps)
|
||||
|
||||
bb.msg.note(2, bb.msg.domain.RunQueue, "Compute totals (have %s endpoint(s))" % len(endpoints))
|
||||
|
||||
while 1:
|
||||
next_points = []
|
||||
for listid in endpoints:
|
||||
for revdep in self.runq_depends[listid]:
|
||||
self.runq_weight[revdep] = self.runq_weight[revdep] + self.runq_weight[listid]
|
||||
runq_weight1[revdep] = runq_weight1[revdep] - 1
|
||||
if runq_weight1[revdep] == 0:
|
||||
next_points.append(revdep)
|
||||
runq_done[revdep] = 1
|
||||
endpoints = next_points
|
||||
if len(next_points) == 0:
|
||||
break
|
||||
|
||||
# Sanity Checks
|
||||
for task in range(len(self.runq_fnid)):
|
||||
if runq_done[task] == 0:
|
||||
seen = []
|
||||
deps_seen = []
|
||||
def print_chain(taskid, finish):
|
||||
seen.append(taskid)
|
||||
for revdep in self.runq_revdeps[taskid]:
|
||||
if runq_done[revdep] == 0 and revdep not in seen and not finish:
|
||||
bb.msg.error(bb.msg.domain.RunQueue, "Task %s (%s) (depends: %s)" % (revdep, self.get_user_idstring(revdep), self.runq_depends[revdep]))
|
||||
if revdep in deps_seen:
|
||||
bb.msg.error(bb.msg.domain.RunQueue, "Chain ends at Task %s (%s)" % (revdep, self.get_user_idstring(revdep)))
|
||||
finish = True
|
||||
return
|
||||
for dep in self.runq_depends[revdep]:
|
||||
deps_seen.append(dep)
|
||||
print_chain(revdep, finish)
|
||||
print_chain(task, False)
|
||||
bb.msg.fatal(bb.msg.domain.RunQueue, "Task %s (%s) not processed!\nThis is probably a circular dependency (the chain might be printed above)." % (task, self.get_user_idstring(task)))
|
||||
if runq_weight1[task] != 0:
|
||||
bb.msg.fatal(bb.msg.domain.RunQueue, "Task %s (%s) count not zero!" % (task, self.get_user_idstring(task)))
|
||||
|
||||
# Make a weight sorted map
|
||||
from copy import deepcopy
|
||||
|
||||
sortweight = deepcopy(self.runq_weight)
|
||||
sortweight.sort()
|
||||
copyweight = deepcopy(self.runq_weight)
|
||||
self.prio_map = []
|
||||
|
||||
for weight in sortweight:
|
||||
idx = copyweight.index(weight)
|
||||
self.prio_map.append(idx)
|
||||
copyweight[idx] = -1
|
||||
self.prio_map.reverse()
|
||||
|
||||
#self.dump_data(taskData)
|
||||
|
||||
def execute_runqueue(self):
|
||||
"""
|
||||
Run the tasks in a queue prepared by prepare_runqueue
|
||||
Upon failure, optionally try to recover the build using any alternate providers
|
||||
(if the abort on failure configuration option isn't set)
|
||||
"""
|
||||
|
||||
failures = 0
|
||||
while 1:
|
||||
failed_fnids = []
|
||||
try:
|
||||
self.execute_runqueue_internal()
|
||||
finally:
|
||||
if self.master_process:
|
||||
failed_fnids = self.finish_runqueue()
|
||||
if len(failed_fnids) == 0:
|
||||
return failures
|
||||
if self.taskData.abort:
|
||||
raise bb.runqueue.TaskFailure(failed_fnids)
|
||||
for fnid in failed_fnids:
|
||||
#print "Failure: %s %s %s" % (fnid, self.taskData.fn_index[fnid], self.runq_task[fnid])
|
||||
self.taskData.fail_fnid(fnid)
|
||||
failures = failures + 1
|
||||
self.reset_runqueue()
|
||||
self.prepare_runqueue()
|
||||
|
||||
def execute_runqueue_initVars(self):
|
||||
|
||||
self.stats = RunQueueStats()
|
||||
|
||||
self.active_builds = 0
|
||||
self.runq_buildable = []
|
||||
self.runq_running = []
|
||||
self.runq_complete = []
|
||||
self.build_pids = {}
|
||||
self.failed_fnids = []
|
||||
self.master_process = True
|
||||
|
||||
# Mark initial buildable tasks
|
||||
for task in range(len(self.runq_fnid)):
|
||||
self.runq_running.append(0)
|
||||
self.runq_complete.append(0)
|
||||
if len(self.runq_depends[task]) == 0:
|
||||
self.runq_buildable.append(1)
|
||||
else:
|
||||
self.runq_buildable.append(0)
|
||||
|
||||
def task_complete(self, task):
|
||||
"""
|
||||
Mark a task as completed
|
||||
Look at the reverse dependencies and mark any task with
|
||||
completed dependencies as buildable
|
||||
"""
|
||||
self.runq_complete[task] = 1
|
||||
for revdep in self.runq_revdeps[task]:
|
||||
if self.runq_running[revdep] == 1:
|
||||
continue
|
||||
if self.runq_buildable[revdep] == 1:
|
||||
continue
|
||||
alldeps = 1
|
||||
for dep in self.runq_depends[revdep]:
|
||||
if self.runq_complete[dep] != 1:
|
||||
alldeps = 0
|
||||
if alldeps == 1:
|
||||
self.runq_buildable[revdep] = 1
|
||||
fn = self.taskData.fn_index[self.runq_fnid[revdep]]
|
||||
taskname = self.runq_task[revdep]
|
||||
bb.msg.debug(1, bb.msg.domain.RunQueue, "Marking task %s (%s, %s) as buildable" % (revdep, fn, taskname))
|
||||
|
||||
def get_next_task(self):
|
||||
"""
|
||||
Return the id of the highest priority task that is buildable
|
||||
"""
|
||||
for task1 in range(len(self.runq_fnid)):
|
||||
task = self.prio_map[task1]
|
||||
if self.runq_running[task] == 1:
|
||||
continue
|
||||
if self.runq_buildable[task] == 1:
|
||||
return task
|
||||
return None
|
||||
|
||||
def execute_runqueue_internal(self):
|
||||
"""
|
||||
Run the tasks in a queue prepared by prepare_runqueue
|
||||
"""
|
||||
|
||||
bb.msg.note(1, bb.msg.domain.RunQueue, "Executing runqueue")
|
||||
|
||||
self.execute_runqueue_initVars()
|
||||
|
||||
if len(self.runq_fnid) == 0:
|
||||
# nothing to do
|
||||
return []
|
||||
|
||||
def sigint_handler(signum, frame):
|
||||
raise KeyboardInterrupt
|
||||
|
||||
while True:
|
||||
task = self.get_next_task()
|
||||
if task is not None:
|
||||
fn = self.taskData.fn_index[self.runq_fnid[task]]
|
||||
|
||||
taskname = self.runq_task[task]
|
||||
if bb.build.stamp_is_current(taskname, self.dataCache, fn):
|
||||
bb.msg.debug(2, bb.msg.domain.RunQueue, "Stamp current task %s (%s)" % (task, self.get_user_idstring(task)))
|
||||
self.runq_running[task] = 1
|
||||
self.task_complete(task)
|
||||
self.stats.taskCompleted()
|
||||
self.stats.taskSkipped()
|
||||
continue
|
||||
|
||||
bb.msg.note(1, bb.msg.domain.RunQueue, "Running task %d of %d (ID: %s, %s)" % (self.stats.completed + self.active_builds + 1, len(self.runq_fnid), task, self.get_user_idstring(task)))
|
||||
try:
|
||||
pid = os.fork()
|
||||
except OSError, e:
|
||||
bb.msg.fatal(bb.msg.domain.RunQueue, "fork failed: %d (%s)" % (e.errno, e.strerror))
|
||||
if pid == 0:
|
||||
# Bypass master process' handling
|
||||
self.master_process = False
|
||||
# Stop Ctrl+C being sent to children
|
||||
# signal.signal(signal.SIGINT, signal.SIG_IGN)
|
||||
# Make the child the process group leader
|
||||
os.setpgid(0, 0)
|
||||
newsi = os.open('/dev/null', os.O_RDWR)
|
||||
os.dup2(newsi, sys.stdin.fileno())
|
||||
self.cooker.configuration.cmd = taskname[3:]
|
||||
try:
|
||||
self.cooker.tryBuild(fn, False)
|
||||
except bb.build.EventException:
|
||||
bb.msg.error(bb.msg.domain.Build, "Build of " + fn + " " + taskname + " failed")
|
||||
sys.exit(1)
|
||||
except:
|
||||
bb.msg.error(bb.msg.domain.Build, "Build of " + fn + " " + taskname + " failed")
|
||||
raise
|
||||
sys.exit(0)
|
||||
self.build_pids[pid] = task
|
||||
self.runq_running[task] = 1
|
||||
self.active_builds = self.active_builds + 1
|
||||
if self.active_builds < self.number_tasks:
|
||||
continue
|
||||
if self.active_builds > 0:
|
||||
result = os.waitpid(-1, 0)
|
||||
self.active_builds = self.active_builds - 1
|
||||
task = self.build_pids[result[0]]
|
||||
if result[1] != 0:
|
||||
del self.build_pids[result[0]]
|
||||
bb.msg.error(bb.msg.domain.RunQueue, "Task %s (%s) failed" % (task, self.get_user_idstring(task)))
|
||||
self.failed_fnids.append(self.runq_fnid[task])
|
||||
self.stats.taskFailed()
|
||||
break
|
||||
self.task_complete(task)
|
||||
self.stats.taskCompleted()
|
||||
del self.build_pids[result[0]]
|
||||
continue
|
||||
return
|
||||
|
||||
def finish_runqueue(self):
|
||||
try:
|
||||
while self.active_builds > 0:
|
||||
bb.msg.note(1, bb.msg.domain.RunQueue, "Waiting for %s active tasks to finish" % self.active_builds)
|
||||
tasknum = 1
|
||||
for k, v in self.build_pids.iteritems():
|
||||
bb.msg.note(1, bb.msg.domain.RunQueue, "%s: %s (%s)" % (tasknum, self.get_user_idstring(v), k))
|
||||
tasknum = tasknum + 1
|
||||
result = os.waitpid(-1, 0)
|
||||
task = self.build_pids[result[0]]
|
||||
if result[1] != 0:
|
||||
bb.msg.error(bb.msg.domain.RunQueue, "Task %s (%s) failed" % (task, self.get_user_idstring(task)))
|
||||
self.failed_fnids.append(self.runq_fnid[task])
|
||||
self.stats.taskFailed()
|
||||
del self.build_pids[result[0]]
|
||||
self.active_builds = self.active_builds - 1
|
||||
bb.msg.note(1, bb.msg.domain.RunQueue, "Tasks Summary: Attempted %d tasks of which %d didn't need to be rerun and %d failed." % (self.stats.completed, self.stats.skipped, self.stats.failed))
|
||||
return self.failed_fnids
|
||||
except KeyboardInterrupt:
|
||||
bb.msg.note(1, bb.msg.domain.RunQueue, "Sending SIGINT to remaining %s tasks" % self.active_builds)
|
||||
for k, v in self.build_pids.iteritems():
|
||||
try:
|
||||
os.kill(-k, signal.SIGINT)
|
||||
except:
|
||||
pass
|
||||
raise
|
||||
|
||||
# Sanity Checks
|
||||
for task in range(len(self.runq_fnid)):
|
||||
if self.runq_buildable[task] == 0:
|
||||
bb.msg.error(bb.msg.domain.RunQueue, "Task %s never buildable!" % task)
|
||||
if self.runq_running[task] == 0:
|
||||
bb.msg.error(bb.msg.domain.RunQueue, "Task %s never ran!" % task)
|
||||
if self.runq_complete[task] == 0:
|
||||
bb.msg.error(bb.msg.domain.RunQueue, "Task %s never completed!" % task)
|
||||
|
||||
bb.msg.note(1, bb.msg.domain.RunQueue, "Tasks Summary: Attempted %d tasks of which %d didn't need to be rerun and %d failed." % (self.stats.completed, self.stats.skipped, self.stats.failed))
|
||||
|
||||
return self.failed_fnids
|
||||
|
||||
def dump_data(self, taskQueue):
|
||||
"""
|
||||
Dump some debug information on the internal data structures
|
||||
"""
|
||||
bb.msg.debug(3, bb.msg.domain.RunQueue, "run_tasks:")
|
||||
for task in range(len(self.runq_fnid)):
|
||||
bb.msg.debug(3, bb.msg.domain.RunQueue, " (%s)%s - %s: %s Deps %s RevDeps %s" % (task,
|
||||
taskQueue.fn_index[self.runq_fnid[task]],
|
||||
self.runq_task[task],
|
||||
self.runq_weight[task],
|
||||
self.runq_depends[task],
|
||||
self.runq_revdeps[task]))
|
||||
|
||||
bb.msg.debug(3, bb.msg.domain.RunQueue, "sorted_tasks:")
|
||||
for task1 in range(len(self.runq_fnid)):
|
||||
if task1 in self.prio_map:
|
||||
task = self.prio_map[task1]
|
||||
bb.msg.debug(3, bb.msg.domain.RunQueue, " (%s)%s - %s: %s Deps %s RevDeps %s" % (task,
|
||||
taskQueue.fn_index[self.runq_fnid[task]],
|
||||
self.runq_task[task],
|
||||
self.runq_weight[task],
|
||||
self.runq_depends[task],
|
||||
self.runq_revdeps[task]))
|
||||
838
bitbake/lib/bb/shell.py
Normal file
838
bitbake/lib/bb/shell.py
Normal file
@@ -0,0 +1,838 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
##########################################################################
|
||||
#
|
||||
# Copyright (C) 2005-2006 Michael 'Mickey' Lauer <mickey@Vanille.de>
|
||||
# Copyright (C) 2005-2006 Vanille Media
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
##########################################################################
|
||||
#
|
||||
# Thanks to:
|
||||
# * Holger Freyther <zecke@handhelds.org>
|
||||
# * Justin Patrin <papercrane@reversefold.com>
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
"""
|
||||
BitBake Shell
|
||||
|
||||
IDEAS:
|
||||
* list defined tasks per package
|
||||
* list classes
|
||||
* toggle force
|
||||
* command to reparse just one (or more) bbfile(s)
|
||||
* automatic check if reparsing is necessary (inotify?)
|
||||
* frontend for bb file manipulation
|
||||
* more shell-like features:
|
||||
- output control, i.e. pipe output into grep, sort, etc.
|
||||
- job control, i.e. bring running commands into background and foreground
|
||||
* start parsing in background right after startup
|
||||
* ncurses interface
|
||||
|
||||
PROBLEMS:
|
||||
* force doesn't always work
|
||||
* readline completion for commands with more than one parameters
|
||||
|
||||
"""
|
||||
|
||||
##########################################################################
|
||||
# Import and setup global variables
|
||||
##########################################################################
|
||||
|
||||
try:
|
||||
set
|
||||
except NameError:
|
||||
from sets import Set as set
|
||||
import sys, os, readline, socket, httplib, urllib, commands, popen2, copy, shlex, Queue, fnmatch
|
||||
from bb import data, parse, build, fatal, cache, taskdata, runqueue, providers as Providers
|
||||
|
||||
__version__ = "0.5.3.1"
|
||||
__credits__ = """BitBake Shell Version %s (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
|
||||
Type 'help' for more information, press CTRL-D to exit.""" % __version__
|
||||
|
||||
cmds = {}
|
||||
leave_mainloop = False
|
||||
last_exception = None
|
||||
cooker = None
|
||||
parsed = False
|
||||
initdata = None
|
||||
debug = os.environ.get( "BBSHELL_DEBUG", "" )
|
||||
|
||||
##########################################################################
|
||||
# Class BitBakeShellCommands
|
||||
##########################################################################
|
||||
|
||||
class BitBakeShellCommands:
|
||||
"""This class contains the valid commands for the shell"""
|
||||
|
||||
def __init__( self, shell ):
|
||||
"""Register all the commands"""
|
||||
self._shell = shell
|
||||
for attr in BitBakeShellCommands.__dict__:
|
||||
if not attr.startswith( "_" ):
|
||||
if attr.endswith( "_" ):
|
||||
command = attr[:-1].lower()
|
||||
else:
|
||||
command = attr[:].lower()
|
||||
method = getattr( BitBakeShellCommands, attr )
|
||||
debugOut( "registering command '%s'" % command )
|
||||
# scan number of arguments
|
||||
usage = getattr( method, "usage", "" )
|
||||
if usage != "<...>":
|
||||
numArgs = len( usage.split() )
|
||||
else:
|
||||
numArgs = -1
|
||||
shell.registerCommand( command, method, numArgs, "%s %s" % ( command, usage ), method.__doc__ )
|
||||
|
||||
def _checkParsed( self ):
|
||||
if not parsed:
|
||||
print "SHELL: This command needs to parse bbfiles..."
|
||||
self.parse( None )
|
||||
|
||||
def _findProvider( self, item ):
|
||||
self._checkParsed()
|
||||
# Need to use taskData for this information
|
||||
preferred = data.getVar( "PREFERRED_PROVIDER_%s" % item, cooker.configuration.data, 1 )
|
||||
if not preferred: preferred = item
|
||||
try:
|
||||
lv, lf, pv, pf = Providers.findBestProvider(preferred, cooker.configuration.data, cooker.status)
|
||||
except KeyError:
|
||||
if item in cooker.status.providers:
|
||||
pf = cooker.status.providers[item][0]
|
||||
else:
|
||||
pf = None
|
||||
return pf
|
||||
|
||||
def alias( self, params ):
|
||||
"""Register a new name for a command"""
|
||||
new, old = params
|
||||
if not old in cmds:
|
||||
print "ERROR: Command '%s' not known" % old
|
||||
else:
|
||||
cmds[new] = cmds[old]
|
||||
print "OK"
|
||||
alias.usage = "<alias> <command>"
|
||||
|
||||
def buffer( self, params ):
|
||||
"""Dump specified output buffer"""
|
||||
index = params[0]
|
||||
print self._shell.myout.buffer( int( index ) )
|
||||
buffer.usage = "<index>"
|
||||
|
||||
def buffers( self, params ):
|
||||
"""Show the available output buffers"""
|
||||
commands = self._shell.myout.bufferedCommands()
|
||||
if not commands:
|
||||
print "SHELL: No buffered commands available yet. Start doing something."
|
||||
else:
|
||||
print "="*35, "Available Output Buffers", "="*27
|
||||
for index, cmd in enumerate( commands ):
|
||||
print "| %s %s" % ( str( index ).ljust( 3 ), cmd )
|
||||
print "="*88
|
||||
|
||||
def build( self, params, cmd = "build" ):
|
||||
"""Build a providee"""
|
||||
global last_exception
|
||||
globexpr = params[0]
|
||||
self._checkParsed()
|
||||
names = globfilter( cooker.status.pkg_pn.keys(), globexpr )
|
||||
if len( names ) == 0: names = [ globexpr ]
|
||||
print "SHELL: Building %s" % ' '.join( names )
|
||||
|
||||
oldcmd = cooker.configuration.cmd
|
||||
cooker.configuration.cmd = cmd
|
||||
|
||||
td = taskdata.TaskData(cooker.configuration.abort)
|
||||
|
||||
try:
|
||||
tasks = []
|
||||
for name in names:
|
||||
td.add_provider(cooker.configuration.data, cooker.status, name)
|
||||
providers = td.get_provider(name)
|
||||
|
||||
if len(providers) == 0:
|
||||
raise Providers.NoProvider
|
||||
|
||||
tasks.append([name, "do_%s" % cooker.configuration.cmd])
|
||||
|
||||
td.add_unresolved(cooker.configuration.data, cooker.status)
|
||||
|
||||
rq = runqueue.RunQueue(cooker, cooker.configuration.data, cooker.status, td, tasks)
|
||||
rq.prepare_runqueue()
|
||||
rq.execute_runqueue()
|
||||
|
||||
except Providers.NoProvider:
|
||||
print "ERROR: No Provider"
|
||||
last_exception = Providers.NoProvider
|
||||
|
||||
except runqueue.TaskFailure, fnids:
|
||||
for fnid in fnids:
|
||||
print "ERROR: '%s' failed" % td.fn_index[fnid]
|
||||
last_exception = runqueue.TaskFailure
|
||||
|
||||
except build.EventException, e:
|
||||
print "ERROR: Couldn't build '%s'" % names
|
||||
last_exception = e
|
||||
|
||||
cooker.configuration.cmd = oldcmd
|
||||
|
||||
build.usage = "<providee>"
|
||||
|
||||
def clean( self, params ):
|
||||
"""Clean a providee"""
|
||||
self.build( params, "clean" )
|
||||
clean.usage = "<providee>"
|
||||
|
||||
def compile( self, params ):
|
||||
"""Execute 'compile' on a providee"""
|
||||
self.build( params, "compile" )
|
||||
compile.usage = "<providee>"
|
||||
|
||||
def configure( self, params ):
|
||||
"""Execute 'configure' on a providee"""
|
||||
self.build( params, "configure" )
|
||||
configure.usage = "<providee>"
|
||||
|
||||
def edit( self, params ):
|
||||
"""Call $EDITOR on a providee"""
|
||||
name = params[0]
|
||||
bbfile = self._findProvider( name )
|
||||
if bbfile is not None:
|
||||
os.system( "%s %s" % ( os.environ.get( "EDITOR", "vi" ), bbfile ) )
|
||||
else:
|
||||
print "ERROR: Nothing provides '%s'" % name
|
||||
edit.usage = "<providee>"
|
||||
|
||||
def environment( self, params ):
|
||||
"""Dump out the outer BitBake environment (see bbread)"""
|
||||
data.emit_env(sys.__stdout__, cooker.configuration.data, True)
|
||||
|
||||
def exit_( self, params ):
|
||||
"""Leave the BitBake Shell"""
|
||||
debugOut( "setting leave_mainloop to true" )
|
||||
global leave_mainloop
|
||||
leave_mainloop = True
|
||||
|
||||
def fetch( self, params ):
|
||||
"""Fetch a providee"""
|
||||
self.build( params, "fetch" )
|
||||
fetch.usage = "<providee>"
|
||||
|
||||
def fileBuild( self, params, cmd = "build" ):
|
||||
"""Parse and build a .bb file"""
|
||||
global last_exception
|
||||
name = params[0]
|
||||
bf = completeFilePath( name )
|
||||
print "SHELL: Calling '%s' on '%s'" % ( cmd, bf )
|
||||
|
||||
oldcmd = cooker.configuration.cmd
|
||||
cooker.configuration.cmd = cmd
|
||||
|
||||
thisdata = copy.deepcopy( initdata )
|
||||
# Caution: parse.handle modifies thisdata, hence it would
|
||||
# lead to pollution cooker.configuration.data, which is
|
||||
# why we use it on a safe copy we obtained from cooker right after
|
||||
# parsing the initial *.conf files
|
||||
try:
|
||||
bbfile_data = parse.handle( bf, thisdata )
|
||||
except parse.ParseError:
|
||||
print "ERROR: Unable to open or parse '%s'" % bf
|
||||
else:
|
||||
# Remove stamp for target if force mode active
|
||||
if cooker.configuration.force:
|
||||
bb.msg.note(2, bb.msg.domain.RunQueue, "Remove stamp %s, %s" % (cmd, bf))
|
||||
bb.build.del_stamp('do_%s' % cmd, bbfile_data)
|
||||
|
||||
item = data.getVar('PN', bbfile_data, 1)
|
||||
data.setVar( "_task_cache", [], bbfile_data ) # force
|
||||
try:
|
||||
cooker.tryBuildPackage( os.path.abspath( bf ), item, cmd, bbfile_data, True )
|
||||
except build.EventException, e:
|
||||
print "ERROR: Couldn't build '%s'" % name
|
||||
last_exception = e
|
||||
|
||||
cooker.configuration.cmd = oldcmd
|
||||
fileBuild.usage = "<bbfile>"
|
||||
|
||||
def fileClean( self, params ):
|
||||
"""Clean a .bb file"""
|
||||
self.fileBuild( params, "clean" )
|
||||
fileClean.usage = "<bbfile>"
|
||||
|
||||
def fileEdit( self, params ):
|
||||
"""Call $EDITOR on a .bb file"""
|
||||
name = params[0]
|
||||
os.system( "%s %s" % ( os.environ.get( "EDITOR", "vi" ), completeFilePath( name ) ) )
|
||||
fileEdit.usage = "<bbfile>"
|
||||
|
||||
def fileRebuild( self, params ):
|
||||
"""Rebuild (clean & build) a .bb file"""
|
||||
self.fileBuild( params, "rebuild" )
|
||||
fileRebuild.usage = "<bbfile>"
|
||||
|
||||
def fileReparse( self, params ):
|
||||
"""(re)Parse a bb file"""
|
||||
bbfile = params[0]
|
||||
print "SHELL: Parsing '%s'" % bbfile
|
||||
parse.update_mtime( bbfile )
|
||||
cooker.bb_cache.cacheValidUpdate(bbfile)
|
||||
fromCache = cooker.bb_cache.loadData(bbfile, cooker.configuration.data)
|
||||
cooker.bb_cache.sync()
|
||||
if False: #fromCache:
|
||||
print "SHELL: File has not been updated, not reparsing"
|
||||
else:
|
||||
print "SHELL: Parsed"
|
||||
fileReparse.usage = "<bbfile>"
|
||||
|
||||
def abort( self, params ):
|
||||
"""Toggle abort task execution flag (see bitbake -k)"""
|
||||
cooker.configuration.abort = not cooker.configuration.abort
|
||||
print "SHELL: Abort Flag is now '%s'" % repr( cooker.configuration.abort )
|
||||
|
||||
def force( self, params ):
|
||||
"""Toggle force task execution flag (see bitbake -f)"""
|
||||
cooker.configuration.force = not cooker.configuration.force
|
||||
print "SHELL: Force Flag is now '%s'" % repr( cooker.configuration.force )
|
||||
|
||||
def help( self, params ):
|
||||
"""Show a comprehensive list of commands and their purpose"""
|
||||
print "="*30, "Available Commands", "="*30
|
||||
allcmds = cmds.keys()
|
||||
allcmds.sort()
|
||||
for cmd in allcmds:
|
||||
function,numparams,usage,helptext = cmds[cmd]
|
||||
print "| %s | %s" % (usage.ljust(30), helptext)
|
||||
print "="*78
|
||||
|
||||
def lastError( self, params ):
|
||||
"""Show the reason or log that was produced by the last BitBake event exception"""
|
||||
if last_exception is None:
|
||||
print "SHELL: No Errors yet (Phew)..."
|
||||
else:
|
||||
reason, event = last_exception.args
|
||||
print "SHELL: Reason for the last error: '%s'" % reason
|
||||
if ':' in reason:
|
||||
msg, filename = reason.split( ':' )
|
||||
filename = filename.strip()
|
||||
print "SHELL: Dumping log file for last error:"
|
||||
try:
|
||||
print open( filename ).read()
|
||||
except IOError:
|
||||
print "ERROR: Couldn't open '%s'" % filename
|
||||
|
||||
def match( self, params ):
|
||||
"""Dump all files or providers matching a glob expression"""
|
||||
what, globexpr = params
|
||||
if what == "files":
|
||||
self._checkParsed()
|
||||
for key in globfilter( cooker.status.pkg_fn.keys(), globexpr ): print key
|
||||
elif what == "providers":
|
||||
self._checkParsed()
|
||||
for key in globfilter( cooker.status.pkg_pn.keys(), globexpr ): print key
|
||||
else:
|
||||
print "Usage: match %s" % self.print_.usage
|
||||
match.usage = "<files|providers> <glob>"
|
||||
|
||||
def new( self, params ):
|
||||
"""Create a new .bb file and open the editor"""
|
||||
dirname, filename = params
|
||||
packages = '/'.join( data.getVar( "BBFILES", cooker.configuration.data, 1 ).split('/')[:-2] )
|
||||
fulldirname = "%s/%s" % ( packages, dirname )
|
||||
|
||||
if not os.path.exists( fulldirname ):
|
||||
print "SHELL: Creating '%s'" % fulldirname
|
||||
os.mkdir( fulldirname )
|
||||
if os.path.exists( fulldirname ) and os.path.isdir( fulldirname ):
|
||||
if os.path.exists( "%s/%s" % ( fulldirname, filename ) ):
|
||||
print "SHELL: ERROR: %s/%s already exists" % ( fulldirname, filename )
|
||||
return False
|
||||
print "SHELL: Creating '%s/%s'" % ( fulldirname, filename )
|
||||
newpackage = open( "%s/%s" % ( fulldirname, filename ), "w" )
|
||||
print >>newpackage,"""DESCRIPTION = ""
|
||||
SECTION = ""
|
||||
AUTHOR = ""
|
||||
HOMEPAGE = ""
|
||||
MAINTAINER = ""
|
||||
LICENSE = "GPL"
|
||||
PR = "r0"
|
||||
|
||||
SRC_URI = ""
|
||||
|
||||
#inherit base
|
||||
|
||||
#do_configure() {
|
||||
#
|
||||
#}
|
||||
|
||||
#do_compile() {
|
||||
#
|
||||
#}
|
||||
|
||||
#do_stage() {
|
||||
#
|
||||
#}
|
||||
|
||||
#do_install() {
|
||||
#
|
||||
#}
|
||||
"""
|
||||
newpackage.close()
|
||||
os.system( "%s %s/%s" % ( os.environ.get( "EDITOR" ), fulldirname, filename ) )
|
||||
new.usage = "<directory> <filename>"
|
||||
|
||||
def pasteBin( self, params ):
|
||||
"""Send a command + output buffer to the pastebin at http://rafb.net/paste"""
|
||||
index = params[0]
|
||||
contents = self._shell.myout.buffer( int( index ) )
|
||||
sendToPastebin( "output of " + params[0], contents )
|
||||
pasteBin.usage = "<index>"
|
||||
|
||||
def pasteLog( self, params ):
|
||||
"""Send the last event exception error log (if there is one) to http://rafb.net/paste"""
|
||||
if last_exception is None:
|
||||
print "SHELL: No Errors yet (Phew)..."
|
||||
else:
|
||||
reason, event = last_exception.args
|
||||
print "SHELL: Reason for the last error: '%s'" % reason
|
||||
if ':' in reason:
|
||||
msg, filename = reason.split( ':' )
|
||||
filename = filename.strip()
|
||||
print "SHELL: Pasting log file to pastebin..."
|
||||
|
||||
file = open( filename ).read()
|
||||
sendToPastebin( "contents of " + filename, file )
|
||||
|
||||
def patch( self, params ):
|
||||
"""Execute 'patch' command on a providee"""
|
||||
self.build( params, "patch" )
|
||||
patch.usage = "<providee>"
|
||||
|
||||
def parse( self, params ):
|
||||
"""(Re-)parse .bb files and calculate the dependency graph"""
|
||||
cooker.status = cache.CacheData()
|
||||
ignore = data.getVar("ASSUME_PROVIDED", cooker.configuration.data, 1) or ""
|
||||
cooker.status.ignored_dependencies = set( ignore.split() )
|
||||
cooker.handleCollections( data.getVar("BBFILE_COLLECTIONS", cooker.configuration.data, 1) )
|
||||
|
||||
(filelist, masked) = cooker.collect_bbfiles()
|
||||
cooker.parse_bbfiles(filelist, masked, cooker.myProgressCallback)
|
||||
cooker.buildDepgraph()
|
||||
global parsed
|
||||
parsed = True
|
||||
print
|
||||
|
||||
def reparse( self, params ):
|
||||
"""(re)Parse a providee's bb file"""
|
||||
bbfile = self._findProvider( params[0] )
|
||||
if bbfile is not None:
|
||||
print "SHELL: Found bbfile '%s' for '%s'" % ( bbfile, params[0] )
|
||||
self.fileReparse( [ bbfile ] )
|
||||
else:
|
||||
print "ERROR: Nothing provides '%s'" % params[0]
|
||||
reparse.usage = "<providee>"
|
||||
|
||||
def getvar( self, params ):
|
||||
"""Dump the contents of an outer BitBake environment variable"""
|
||||
var = params[0]
|
||||
value = data.getVar( var, cooker.configuration.data, 1 )
|
||||
print value
|
||||
getvar.usage = "<variable>"
|
||||
|
||||
def peek( self, params ):
|
||||
"""Dump contents of variable defined in providee's metadata"""
|
||||
name, var = params
|
||||
bbfile = self._findProvider( name )
|
||||
if bbfile is not None:
|
||||
the_data = cooker.bb_cache.loadDataFull(bbfile, cooker.configuration.data)
|
||||
value = the_data.getVar( var, 1 )
|
||||
print value
|
||||
else:
|
||||
print "ERROR: Nothing provides '%s'" % name
|
||||
peek.usage = "<providee> <variable>"
|
||||
|
||||
def poke( self, params ):
|
||||
"""Set contents of variable defined in providee's metadata"""
|
||||
name, var, value = params
|
||||
bbfile = self._findProvider( name )
|
||||
if bbfile is not None:
|
||||
print "ERROR: Sorry, this functionality is currently broken"
|
||||
#d = cooker.pkgdata[bbfile]
|
||||
#data.setVar( var, value, d )
|
||||
|
||||
# mark the change semi persistant
|
||||
#cooker.pkgdata.setDirty(bbfile, d)
|
||||
#print "OK"
|
||||
else:
|
||||
print "ERROR: Nothing provides '%s'" % name
|
||||
poke.usage = "<providee> <variable> <value>"
|
||||
|
||||
def print_( self, params ):
|
||||
"""Dump all files or providers"""
|
||||
what = params[0]
|
||||
if what == "files":
|
||||
self._checkParsed()
|
||||
for key in cooker.status.pkg_fn.keys(): print key
|
||||
elif what == "providers":
|
||||
self._checkParsed()
|
||||
for key in cooker.status.providers.keys(): print key
|
||||
else:
|
||||
print "Usage: print %s" % self.print_.usage
|
||||
print_.usage = "<files|providers>"
|
||||
|
||||
def python( self, params ):
|
||||
"""Enter the expert mode - an interactive BitBake Python Interpreter"""
|
||||
sys.ps1 = "EXPERT BB>>> "
|
||||
sys.ps2 = "EXPERT BB... "
|
||||
import code
|
||||
interpreter = code.InteractiveConsole( dict( globals() ) )
|
||||
interpreter.interact( "SHELL: Expert Mode - BitBake Python %s\nType 'help' for more information, press CTRL-D to switch back to BBSHELL." % sys.version )
|
||||
|
||||
def showdata( self, params ):
|
||||
"""Execute 'showdata' on a providee"""
|
||||
self.build( params, "showdata" )
|
||||
showdata.usage = "<providee>"
|
||||
|
||||
def setVar( self, params ):
|
||||
"""Set an outer BitBake environment variable"""
|
||||
var, value = params
|
||||
data.setVar( var, value, cooker.configuration.data )
|
||||
print "OK"
|
||||
setVar.usage = "<variable> <value>"
|
||||
|
||||
def rebuild( self, params ):
|
||||
"""Clean and rebuild a .bb file or a providee"""
|
||||
self.build( params, "clean" )
|
||||
self.build( params, "build" )
|
||||
rebuild.usage = "<providee>"
|
||||
|
||||
def shell( self, params ):
|
||||
"""Execute a shell command and dump the output"""
|
||||
if params != "":
|
||||
print commands.getoutput( " ".join( params ) )
|
||||
shell.usage = "<...>"
|
||||
|
||||
def stage( self, params ):
|
||||
"""Execute 'stage' on a providee"""
|
||||
self.build( params, "stage" )
|
||||
stage.usage = "<providee>"
|
||||
|
||||
def status( self, params ):
|
||||
"""<just for testing>"""
|
||||
print "-" * 78
|
||||
print "building list = '%s'" % cooker.building_list
|
||||
print "build path = '%s'" % cooker.build_path
|
||||
print "consider_msgs_cache = '%s'" % cooker.consider_msgs_cache
|
||||
print "build stats = '%s'" % cooker.stats
|
||||
if last_exception is not None: print "last_exception = '%s'" % repr( last_exception.args )
|
||||
print "memory output contents = '%s'" % self._shell.myout._buffer
|
||||
|
||||
def test( self, params ):
|
||||
"""<just for testing>"""
|
||||
print "testCommand called with '%s'" % params
|
||||
|
||||
def unpack( self, params ):
|
||||
"""Execute 'unpack' on a providee"""
|
||||
self.build( params, "unpack" )
|
||||
unpack.usage = "<providee>"
|
||||
|
||||
def which( self, params ):
|
||||
"""Computes the providers for a given providee"""
|
||||
# Need to use taskData for this information
|
||||
item = params[0]
|
||||
|
||||
self._checkParsed()
|
||||
|
||||
preferred = data.getVar( "PREFERRED_PROVIDER_%s" % item, cooker.configuration.data, 1 )
|
||||
if not preferred: preferred = item
|
||||
|
||||
try:
|
||||
lv, lf, pv, pf = Providers.findBestProvider(preferred, cooker.configuration.data, cooker.status)
|
||||
except KeyError:
|
||||
lv, lf, pv, pf = (None,)*4
|
||||
|
||||
try:
|
||||
providers = cooker.status.providers[item]
|
||||
except KeyError:
|
||||
print "SHELL: ERROR: Nothing provides", preferred
|
||||
else:
|
||||
for provider in providers:
|
||||
if provider == pf: provider = " (***) %s" % provider
|
||||
else: provider = " %s" % provider
|
||||
print provider
|
||||
which.usage = "<providee>"
|
||||
|
||||
##########################################################################
|
||||
# Common helper functions
|
||||
##########################################################################
|
||||
|
||||
def completeFilePath( bbfile ):
|
||||
"""Get the complete bbfile path"""
|
||||
if not cooker.status.pkg_fn: return bbfile
|
||||
for key in cooker.status.pkg_fn.keys():
|
||||
if key.endswith( bbfile ):
|
||||
return key
|
||||
return bbfile
|
||||
|
||||
def sendToPastebin( desc, content ):
|
||||
"""Send content to http://oe.pastebin.com"""
|
||||
mydata = {}
|
||||
mydata["lang"] = "Plain Text"
|
||||
mydata["desc"] = desc
|
||||
mydata["cvt_tabs"] = "No"
|
||||
mydata["nick"] = "%s@%s" % ( os.environ.get( "USER", "unknown" ), socket.gethostname() or "unknown" )
|
||||
mydata["text"] = content
|
||||
params = urllib.urlencode( mydata )
|
||||
headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}
|
||||
|
||||
host = "rafb.net"
|
||||
conn = httplib.HTTPConnection( "%s:80" % host )
|
||||
conn.request("POST", "/paste/paste.php", params, headers )
|
||||
|
||||
response = conn.getresponse()
|
||||
conn.close()
|
||||
|
||||
if response.status == 302:
|
||||
location = response.getheader( "location" ) or "unknown"
|
||||
print "SHELL: Pasted to http://%s%s" % ( host, location )
|
||||
else:
|
||||
print "ERROR: %s %s" % ( response.status, response.reason )
|
||||
|
||||
def completer( text, state ):
|
||||
"""Return a possible readline completion"""
|
||||
debugOut( "completer called with text='%s', state='%d'" % ( text, state ) )
|
||||
|
||||
if state == 0:
|
||||
line = readline.get_line_buffer()
|
||||
if " " in line:
|
||||
line = line.split()
|
||||
# we are in second (or more) argument
|
||||
if line[0] in cmds and hasattr( cmds[line[0]][0], "usage" ): # known command and usage
|
||||
u = getattr( cmds[line[0]][0], "usage" ).split()[0]
|
||||
if u == "<variable>":
|
||||
allmatches = cooker.configuration.data.keys()
|
||||
elif u == "<bbfile>":
|
||||
if cooker.status.pkg_fn is None: allmatches = [ "(No Matches Available. Parsed yet?)" ]
|
||||
else: allmatches = [ x.split("/")[-1] for x in cooker.status.pkg_fn.keys() ]
|
||||
elif u == "<providee>":
|
||||
if cooker.status.pkg_fn is None: allmatches = [ "(No Matches Available. Parsed yet?)" ]
|
||||
else: allmatches = cooker.status.providers.iterkeys()
|
||||
else: allmatches = [ "(No tab completion available for this command)" ]
|
||||
else: allmatches = [ "(No tab completion available for this command)" ]
|
||||
else:
|
||||
# we are in first argument
|
||||
allmatches = cmds.iterkeys()
|
||||
|
||||
completer.matches = [ x for x in allmatches if x[:len(text)] == text ]
|
||||
#print "completer.matches = '%s'" % completer.matches
|
||||
if len( completer.matches ) > state:
|
||||
return completer.matches[state]
|
||||
else:
|
||||
return None
|
||||
|
||||
def debugOut( text ):
|
||||
if debug:
|
||||
sys.stderr.write( "( %s )\n" % text )
|
||||
|
||||
def columnize( alist, width = 80 ):
|
||||
"""
|
||||
A word-wrap function that preserves existing line breaks
|
||||
and most spaces in the text. Expects that existing line
|
||||
breaks are posix newlines (\n).
|
||||
"""
|
||||
return reduce(lambda line, word, width=width: '%s%s%s' %
|
||||
(line,
|
||||
' \n'[(len(line[line.rfind('\n')+1:])
|
||||
+ len(word.split('\n',1)[0]
|
||||
) >= width)],
|
||||
word),
|
||||
alist
|
||||
)
|
||||
|
||||
def globfilter( names, pattern ):
|
||||
return fnmatch.filter( names, pattern )
|
||||
|
||||
##########################################################################
|
||||
# Class MemoryOutput
|
||||
##########################################################################
|
||||
|
||||
class MemoryOutput:
|
||||
"""File-like output class buffering the output of the last 10 commands"""
|
||||
def __init__( self, delegate ):
|
||||
self.delegate = delegate
|
||||
self._buffer = []
|
||||
self.text = []
|
||||
self._command = None
|
||||
|
||||
def startCommand( self, command ):
|
||||
self._command = command
|
||||
self.text = []
|
||||
def endCommand( self ):
|
||||
if self._command is not None:
|
||||
if len( self._buffer ) == 10: del self._buffer[0]
|
||||
self._buffer.append( ( self._command, self.text ) )
|
||||
def removeLast( self ):
|
||||
if self._buffer:
|
||||
del self._buffer[ len( self._buffer ) - 1 ]
|
||||
self.text = []
|
||||
self._command = None
|
||||
def lastBuffer( self ):
|
||||
if self._buffer:
|
||||
return self._buffer[ len( self._buffer ) -1 ][1]
|
||||
def bufferedCommands( self ):
|
||||
return [ cmd for cmd, output in self._buffer ]
|
||||
def buffer( self, i ):
|
||||
if i < len( self._buffer ):
|
||||
return "BB>> %s\n%s" % ( self._buffer[i][0], "".join( self._buffer[i][1] ) )
|
||||
else: return "ERROR: Invalid buffer number. Buffer needs to be in (0, %d)" % ( len( self._buffer ) - 1 )
|
||||
def write( self, text ):
|
||||
if self._command is not None and text != "BB>> ": self.text.append( text )
|
||||
if self.delegate is not None: self.delegate.write( text )
|
||||
def flush( self ):
|
||||
return self.delegate.flush()
|
||||
def fileno( self ):
|
||||
return self.delegate.fileno()
|
||||
def isatty( self ):
|
||||
return self.delegate.isatty()
|
||||
|
||||
##########################################################################
|
||||
# Class BitBakeShell
|
||||
##########################################################################
|
||||
|
||||
class BitBakeShell:
|
||||
|
||||
def __init__( self ):
|
||||
"""Register commands and set up readline"""
|
||||
self.commandQ = Queue.Queue()
|
||||
self.commands = BitBakeShellCommands( self )
|
||||
self.myout = MemoryOutput( sys.stdout )
|
||||
self.historyfilename = os.path.expanduser( "~/.bbsh_history" )
|
||||
self.startupfilename = os.path.expanduser( "~/.bbsh_startup" )
|
||||
|
||||
readline.set_completer( completer )
|
||||
readline.set_completer_delims( " " )
|
||||
readline.parse_and_bind("tab: complete")
|
||||
|
||||
try:
|
||||
readline.read_history_file( self.historyfilename )
|
||||
except IOError:
|
||||
pass # It doesn't exist yet.
|
||||
|
||||
print __credits__
|
||||
|
||||
# save initial cooker configuration (will be reused in file*** commands)
|
||||
global initdata
|
||||
initdata = copy.deepcopy( cooker.configuration.data )
|
||||
|
||||
def cleanup( self ):
|
||||
"""Write readline history and clean up resources"""
|
||||
debugOut( "writing command history" )
|
||||
try:
|
||||
readline.write_history_file( self.historyfilename )
|
||||
except:
|
||||
print "SHELL: Unable to save command history"
|
||||
|
||||
def registerCommand( self, command, function, numparams = 0, usage = "", helptext = "" ):
|
||||
"""Register a command"""
|
||||
if usage == "": usage = command
|
||||
if helptext == "": helptext = function.__doc__ or "<not yet documented>"
|
||||
cmds[command] = ( function, numparams, usage, helptext )
|
||||
|
||||
def processCommand( self, command, params ):
|
||||
"""Process a command. Check number of params and print a usage string, if appropriate"""
|
||||
debugOut( "processing command '%s'..." % command )
|
||||
try:
|
||||
function, numparams, usage, helptext = cmds[command]
|
||||
except KeyError:
|
||||
print "SHELL: ERROR: '%s' command is not a valid command." % command
|
||||
self.myout.removeLast()
|
||||
else:
|
||||
if (numparams != -1) and (not len( params ) == numparams):
|
||||
print "Usage: '%s'" % usage
|
||||
return
|
||||
|
||||
result = function( self.commands, params )
|
||||
debugOut( "result was '%s'" % result )
|
||||
|
||||
def processStartupFile( self ):
|
||||
"""Read and execute all commands found in $HOME/.bbsh_startup"""
|
||||
if os.path.exists( self.startupfilename ):
|
||||
startupfile = open( self.startupfilename, "r" )
|
||||
for cmdline in startupfile:
|
||||
debugOut( "processing startup line '%s'" % cmdline )
|
||||
if not cmdline:
|
||||
continue
|
||||
if "|" in cmdline:
|
||||
print "ERROR: '|' in startup file is not allowed. Ignoring line"
|
||||
continue
|
||||
self.commandQ.put( cmdline.strip() )
|
||||
|
||||
def main( self ):
|
||||
"""The main command loop"""
|
||||
while not leave_mainloop:
|
||||
try:
|
||||
if self.commandQ.empty():
|
||||
sys.stdout = self.myout.delegate
|
||||
cmdline = raw_input( "BB>> " )
|
||||
sys.stdout = self.myout
|
||||
else:
|
||||
cmdline = self.commandQ.get()
|
||||
if cmdline:
|
||||
allCommands = cmdline.split( ';' )
|
||||
for command in allCommands:
|
||||
pipecmd = None
|
||||
#
|
||||
# special case for expert mode
|
||||
if command == 'python':
|
||||
sys.stdout = self.myout.delegate
|
||||
self.processCommand( command, "" )
|
||||
sys.stdout = self.myout
|
||||
else:
|
||||
self.myout.startCommand( command )
|
||||
if '|' in command: # disable output
|
||||
command, pipecmd = command.split( '|' )
|
||||
delegate = self.myout.delegate
|
||||
self.myout.delegate = None
|
||||
tokens = shlex.split( command, True )
|
||||
self.processCommand( tokens[0], tokens[1:] or "" )
|
||||
self.myout.endCommand()
|
||||
if pipecmd is not None: # restore output
|
||||
self.myout.delegate = delegate
|
||||
|
||||
pipe = popen2.Popen4( pipecmd )
|
||||
pipe.tochild.write( "\n".join( self.myout.lastBuffer() ) )
|
||||
pipe.tochild.close()
|
||||
sys.stdout.write( pipe.fromchild.read() )
|
||||
#
|
||||
except EOFError:
|
||||
print
|
||||
return
|
||||
except KeyboardInterrupt:
|
||||
print
|
||||
|
||||
##########################################################################
|
||||
# Start function - called from the BitBake command line utility
|
||||
##########################################################################
|
||||
|
||||
def start( aCooker ):
|
||||
global cooker
|
||||
cooker = aCooker
|
||||
bbshell = BitBakeShell()
|
||||
bbshell.processStartupFile()
|
||||
bbshell.main()
|
||||
bbshell.cleanup()
|
||||
|
||||
if __name__ == "__main__":
|
||||
print "SHELL: Sorry, this program should only be called by BitBake."
|
||||
579
bitbake/lib/bb/taskdata.py
Normal file
579
bitbake/lib/bb/taskdata.py
Normal file
@@ -0,0 +1,579 @@
|
||||
#!/usr/bin/env python
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake 'TaskData' implementation
|
||||
|
||||
Task data collection and handling
|
||||
|
||||
"""
|
||||
|
||||
# Copyright (C) 2006 Richard Purdie
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
from bb import data, fetch, event, mkdirhier, utils
|
||||
import bb, os
|
||||
|
||||
class TaskData:
|
||||
"""
|
||||
BitBake Task Data implementation
|
||||
"""
|
||||
def __init__(self, abort = True):
|
||||
self.build_names_index = []
|
||||
self.run_names_index = []
|
||||
self.fn_index = []
|
||||
|
||||
self.build_targets = {}
|
||||
self.run_targets = {}
|
||||
|
||||
self.external_targets = []
|
||||
|
||||
self.tasks_fnid = []
|
||||
self.tasks_name = []
|
||||
self.tasks_tdepends = []
|
||||
self.tasks_idepends = []
|
||||
# Cache to speed up task ID lookups
|
||||
self.tasks_lookup = {}
|
||||
|
||||
self.depids = {}
|
||||
self.rdepids = {}
|
||||
|
||||
self.consider_msgs_cache = []
|
||||
|
||||
self.failed_deps = []
|
||||
self.failed_rdeps = []
|
||||
self.failed_fnids = []
|
||||
|
||||
self.abort = abort
|
||||
|
||||
def getbuild_id(self, name):
|
||||
"""
|
||||
Return an ID number for the build target name.
|
||||
If it doesn't exist, create one.
|
||||
"""
|
||||
if not name in self.build_names_index:
|
||||
self.build_names_index.append(name)
|
||||
return len(self.build_names_index) - 1
|
||||
|
||||
return self.build_names_index.index(name)
|
||||
|
||||
def getrun_id(self, name):
|
||||
"""
|
||||
Return an ID number for the run target name.
|
||||
If it doesn't exist, create one.
|
||||
"""
|
||||
if not name in self.run_names_index:
|
||||
self.run_names_index.append(name)
|
||||
return len(self.run_names_index) - 1
|
||||
|
||||
return self.run_names_index.index(name)
|
||||
|
||||
def getfn_id(self, name):
|
||||
"""
|
||||
Return an ID number for the filename.
|
||||
If it doesn't exist, create one.
|
||||
"""
|
||||
if not name in self.fn_index:
|
||||
self.fn_index.append(name)
|
||||
return len(self.fn_index) - 1
|
||||
|
||||
return self.fn_index.index(name)
|
||||
|
||||
def gettask_id(self, fn, task, create = True):
|
||||
"""
|
||||
Return an ID number for the task matching fn and task.
|
||||
If it doesn't exist, create one by default.
|
||||
Optionally return None instead.
|
||||
"""
|
||||
fnid = self.getfn_id(fn)
|
||||
|
||||
if fnid in self.tasks_lookup:
|
||||
if task in self.tasks_lookup[fnid]:
|
||||
return self.tasks_lookup[fnid][task]
|
||||
|
||||
if not create:
|
||||
return None
|
||||
|
||||
self.tasks_name.append(task)
|
||||
self.tasks_fnid.append(fnid)
|
||||
self.tasks_tdepends.append([])
|
||||
self.tasks_idepends.append([])
|
||||
|
||||
listid = len(self.tasks_name) - 1
|
||||
|
||||
if fnid not in self.tasks_lookup:
|
||||
self.tasks_lookup[fnid] = {}
|
||||
self.tasks_lookup[fnid][task] = listid
|
||||
|
||||
return listid
|
||||
|
||||
def add_tasks(self, fn, dataCache):
|
||||
"""
|
||||
Add tasks for a given fn to the database
|
||||
"""
|
||||
|
||||
task_graph = dataCache.task_queues[fn]
|
||||
task_deps = dataCache.task_deps[fn]
|
||||
|
||||
fnid = self.getfn_id(fn)
|
||||
|
||||
if fnid in self.failed_fnids:
|
||||
bb.msg.fatal(bb.msg.domain.TaskData, "Trying to re-add a failed file? Something is broken...")
|
||||
|
||||
# Check if we've already seen this fn
|
||||
if fnid in self.tasks_fnid:
|
||||
return
|
||||
|
||||
for task in task_graph.allnodes():
|
||||
|
||||
# Work out task dependencies
|
||||
parentids = []
|
||||
for dep in task_graph.getparents(task):
|
||||
parentid = self.gettask_id(fn, dep)
|
||||
parentids.append(parentid)
|
||||
taskid = self.gettask_id(fn, task)
|
||||
self.tasks_tdepends[taskid].extend(parentids)
|
||||
|
||||
# Touch all intertask dependencies
|
||||
if 'depends' in task_deps and task in task_deps['depends']:
|
||||
ids = []
|
||||
for dep in task_deps['depends'][task].split(" "):
|
||||
if dep:
|
||||
ids.append(str(self.getbuild_id(dep.split(":")[0])) + ":" + dep.split(":")[1])
|
||||
self.tasks_idepends[taskid].extend(ids)
|
||||
|
||||
# Work out build dependencies
|
||||
if not fnid in self.depids:
|
||||
dependids = {}
|
||||
for depend in dataCache.deps[fn]:
|
||||
bb.msg.debug(2, bb.msg.domain.TaskData, "Added dependency %s for %s" % (depend, fn))
|
||||
dependids[self.getbuild_id(depend)] = None
|
||||
self.depids[fnid] = dependids.keys()
|
||||
|
||||
# Work out runtime dependencies
|
||||
if not fnid in self.rdepids:
|
||||
rdependids = {}
|
||||
rdepends = dataCache.rundeps[fn]
|
||||
rrecs = dataCache.runrecs[fn]
|
||||
for package in rdepends:
|
||||
for rdepend in rdepends[package]:
|
||||
bb.msg.debug(2, bb.msg.domain.TaskData, "Added runtime dependency %s for %s" % (rdepend, fn))
|
||||
rdependids[self.getrun_id(rdepend)] = None
|
||||
for package in rrecs:
|
||||
for rdepend in rrecs[package]:
|
||||
bb.msg.debug(2, bb.msg.domain.TaskData, "Added runtime recommendation %s for %s" % (rdepend, fn))
|
||||
rdependids[self.getrun_id(rdepend)] = None
|
||||
self.rdepids[fnid] = rdependids.keys()
|
||||
|
||||
for dep in self.depids[fnid]:
|
||||
if dep in self.failed_deps:
|
||||
self.fail_fnid(fnid)
|
||||
return
|
||||
for dep in self.rdepids[fnid]:
|
||||
if dep in self.failed_rdeps:
|
||||
self.fail_fnid(fnid)
|
||||
return
|
||||
|
||||
def have_build_target(self, target):
|
||||
"""
|
||||
Have we a build target matching this name?
|
||||
"""
|
||||
targetid = self.getbuild_id(target)
|
||||
|
||||
if targetid in self.build_targets:
|
||||
return True
|
||||
return False
|
||||
|
||||
def have_runtime_target(self, target):
|
||||
"""
|
||||
Have we a runtime target matching this name?
|
||||
"""
|
||||
targetid = self.getrun_id(target)
|
||||
|
||||
if targetid in self.run_targets:
|
||||
return True
|
||||
return False
|
||||
|
||||
def add_build_target(self, fn, item):
|
||||
"""
|
||||
Add a build target.
|
||||
If already present, append the provider fn to the list
|
||||
"""
|
||||
targetid = self.getbuild_id(item)
|
||||
fnid = self.getfn_id(fn)
|
||||
|
||||
if targetid in self.build_targets:
|
||||
if fnid in self.build_targets[targetid]:
|
||||
return
|
||||
self.build_targets[targetid].append(fnid)
|
||||
return
|
||||
self.build_targets[targetid] = [fnid]
|
||||
|
||||
def add_runtime_target(self, fn, item):
|
||||
"""
|
||||
Add a runtime target.
|
||||
If already present, append the provider fn to the list
|
||||
"""
|
||||
targetid = self.getrun_id(item)
|
||||
fnid = self.getfn_id(fn)
|
||||
|
||||
if targetid in self.run_targets:
|
||||
if fnid in self.run_targets[targetid]:
|
||||
return
|
||||
self.run_targets[targetid].append(fnid)
|
||||
return
|
||||
self.run_targets[targetid] = [fnid]
|
||||
|
||||
def mark_external_target(self, item):
|
||||
"""
|
||||
Mark a build target as being externally requested
|
||||
"""
|
||||
targetid = self.getbuild_id(item)
|
||||
|
||||
if targetid not in self.external_targets:
|
||||
self.external_targets.append(targetid)
|
||||
|
||||
def get_unresolved_build_targets(self, dataCache):
|
||||
"""
|
||||
Return a list of build targets who's providers
|
||||
are unknown.
|
||||
"""
|
||||
unresolved = []
|
||||
for target in self.build_names_index:
|
||||
if target in dataCache.ignored_dependencies:
|
||||
continue
|
||||
if self.build_names_index.index(target) in self.failed_deps:
|
||||
continue
|
||||
if not self.have_build_target(target):
|
||||
unresolved.append(target)
|
||||
return unresolved
|
||||
|
||||
def get_unresolved_run_targets(self, dataCache):
|
||||
"""
|
||||
Return a list of runtime targets who's providers
|
||||
are unknown.
|
||||
"""
|
||||
unresolved = []
|
||||
for target in self.run_names_index:
|
||||
if target in dataCache.ignored_dependencies:
|
||||
continue
|
||||
if self.run_names_index.index(target) in self.failed_rdeps:
|
||||
continue
|
||||
if not self.have_runtime_target(target):
|
||||
unresolved.append(target)
|
||||
return unresolved
|
||||
|
||||
def get_provider(self, item):
|
||||
"""
|
||||
Return a list of providers of item
|
||||
"""
|
||||
targetid = self.getbuild_id(item)
|
||||
|
||||
return self.build_targets[targetid]
|
||||
|
||||
def get_dependees(self, itemid):
|
||||
"""
|
||||
Return a list of targets which depend on item
|
||||
"""
|
||||
dependees = []
|
||||
for fnid in self.depids:
|
||||
if itemid in self.depids[fnid]:
|
||||
dependees.append(fnid)
|
||||
return dependees
|
||||
|
||||
def get_dependees_str(self, item):
|
||||
"""
|
||||
Return a list of targets which depend on item as a user readable string
|
||||
"""
|
||||
itemid = self.getbuild_id(item)
|
||||
dependees = []
|
||||
for fnid in self.depids:
|
||||
if itemid in self.depids[fnid]:
|
||||
dependees.append(self.fn_index[fnid])
|
||||
return dependees
|
||||
|
||||
def get_rdependees(self, itemid):
|
||||
"""
|
||||
Return a list of targets which depend on runtime item
|
||||
"""
|
||||
dependees = []
|
||||
for fnid in self.rdepids:
|
||||
if itemid in self.rdepids[fnid]:
|
||||
dependees.append(fnid)
|
||||
return dependees
|
||||
|
||||
def get_rdependees_str(self, item):
|
||||
"""
|
||||
Return a list of targets which depend on runtime item as a user readable string
|
||||
"""
|
||||
itemid = self.getrun_id(item)
|
||||
dependees = []
|
||||
for fnid in self.rdepids:
|
||||
if itemid in self.rdepids[fnid]:
|
||||
dependees.append(self.fn_index[fnid])
|
||||
return dependees
|
||||
|
||||
def add_provider(self, cfgData, dataCache, item):
|
||||
try:
|
||||
self.add_provider_internal(cfgData, dataCache, item)
|
||||
except bb.providers.NoProvider:
|
||||
if self.abort:
|
||||
bb.msg.error(bb.msg.domain.Provider, "No providers of build target %s (for %s)" % (item, self.get_dependees_str(item)))
|
||||
raise
|
||||
targetid = self.getbuild_id(item)
|
||||
self.remove_buildtarget(targetid)
|
||||
|
||||
self.mark_external_target(item)
|
||||
|
||||
def add_provider_internal(self, cfgData, dataCache, item):
|
||||
"""
|
||||
Add the providers of item to the task data
|
||||
Mark entries were specifically added externally as against dependencies
|
||||
added internally during dependency resolution
|
||||
"""
|
||||
|
||||
if item in dataCache.ignored_dependencies:
|
||||
return
|
||||
|
||||
if not item in dataCache.providers:
|
||||
bb.msg.note(2, bb.msg.domain.Provider, "No providers of build target %s (for %s)" % (item, self.get_dependees_str(item)))
|
||||
bb.event.fire(bb.event.NoProvider(item, cfgData))
|
||||
raise bb.providers.NoProvider(item)
|
||||
|
||||
if self.have_build_target(item):
|
||||
return
|
||||
|
||||
all_p = dataCache.providers[item]
|
||||
|
||||
eligible = bb.providers.filterProviders(all_p, item, cfgData, dataCache)
|
||||
|
||||
for p in eligible:
|
||||
fnid = self.getfn_id(p)
|
||||
if fnid in self.failed_fnids:
|
||||
eligible.remove(p)
|
||||
|
||||
if not eligible:
|
||||
bb.msg.note(2, bb.msg.domain.Provider, "No providers of build target %s after filtering (for %s)" % (item, self.get_dependees_str(item)))
|
||||
bb.event.fire(bb.event.NoProvider(item, cfgData))
|
||||
raise bb.providers.NoProvider(item)
|
||||
|
||||
prefervar = bb.data.getVar('PREFERRED_PROVIDER_%s' % item, cfgData, 1)
|
||||
if prefervar:
|
||||
dataCache.preferred[item] = prefervar
|
||||
|
||||
discriminated = False
|
||||
if item in dataCache.preferred:
|
||||
for p in eligible:
|
||||
pn = dataCache.pkg_fn[p]
|
||||
if dataCache.preferred[item] == pn:
|
||||
bb.msg.note(2, bb.msg.domain.Provider, "selecting %s to satisfy %s due to PREFERRED_PROVIDERS" % (pn, item))
|
||||
eligible.remove(p)
|
||||
eligible = [p] + eligible
|
||||
discriminated = True
|
||||
break
|
||||
|
||||
if len(eligible) > 1 and discriminated == False:
|
||||
if item not in self.consider_msgs_cache:
|
||||
providers_list = []
|
||||
for fn in eligible:
|
||||
providers_list.append(dataCache.pkg_fn[fn])
|
||||
bb.msg.note(1, bb.msg.domain.Provider, "multiple providers are available for %s (%s);" % (item, ", ".join(providers_list)))
|
||||
bb.msg.note(1, bb.msg.domain.Provider, "consider defining PREFERRED_PROVIDER_%s" % item)
|
||||
bb.event.fire(bb.event.MultipleProviders(item,providers_list,cfgData))
|
||||
self.consider_msgs_cache.append(item)
|
||||
|
||||
for fn in eligible:
|
||||
fnid = self.getfn_id(fn)
|
||||
if fnid in self.failed_fnids:
|
||||
continue
|
||||
bb.msg.debug(2, bb.msg.domain.Provider, "adding %s to satisfy %s" % (fn, item))
|
||||
self.add_build_target(fn, item)
|
||||
self.add_tasks(fn, dataCache)
|
||||
|
||||
|
||||
#item = dataCache.pkg_fn[fn]
|
||||
|
||||
def add_rprovider(self, cfgData, dataCache, item):
|
||||
"""
|
||||
Add the runtime providers of item to the task data
|
||||
(takes item names from RDEPENDS/PACKAGES namespace)
|
||||
"""
|
||||
|
||||
if item in dataCache.ignored_dependencies:
|
||||
return
|
||||
|
||||
if self.have_runtime_target(item):
|
||||
return
|
||||
|
||||
all_p = bb.providers.getRuntimeProviders(dataCache, item)
|
||||
|
||||
if not all_p:
|
||||
bb.msg.error(bb.msg.domain.Provider, "No providers of runtime build target %s (for %s)" % (item, self.get_rdependees_str(item)))
|
||||
bb.event.fire(bb.event.NoProvider(item, cfgData, runtime=True))
|
||||
raise bb.providers.NoRProvider(item)
|
||||
|
||||
eligible = bb.providers.filterProviders(all_p, item, cfgData, dataCache)
|
||||
|
||||
for p in eligible:
|
||||
fnid = self.getfn_id(p)
|
||||
if fnid in self.failed_fnids:
|
||||
eligible.remove(p)
|
||||
|
||||
if not eligible:
|
||||
bb.msg.error(bb.msg.domain.Provider, "No providers of runtime build target %s after filtering (for %s)" % (item, self.get_rdependees_str(item)))
|
||||
bb.event.fire(bb.event.NoProvider(item, cfgData, runtime=True))
|
||||
raise bb.providers.NoRProvider(item)
|
||||
|
||||
# Should use dataCache.preferred here?
|
||||
preferred = []
|
||||
for p in eligible:
|
||||
pn = dataCache.pkg_fn[p]
|
||||
provides = dataCache.pn_provides[pn]
|
||||
for provide in provides:
|
||||
prefervar = bb.data.getVar('PREFERRED_PROVIDER_%s' % provide, cfgData, 1)
|
||||
if prefervar == pn:
|
||||
bb.msg.note(2, bb.msg.domain.Provider, "selecting %s to satisfy runtime %s due to PREFERRED_PROVIDERS" % (pn, item))
|
||||
eligible.remove(p)
|
||||
eligible = [p] + eligible
|
||||
preferred.append(p)
|
||||
break
|
||||
|
||||
if len(eligible) > 1 and len(preferred) == 0:
|
||||
if item not in self.consider_msgs_cache:
|
||||
providers_list = []
|
||||
for fn in eligible:
|
||||
providers_list.append(dataCache.pkg_fn[fn])
|
||||
bb.msg.note(2, bb.msg.domain.Provider, "multiple providers are available for runtime %s (%s);" % (item, ", ".join(providers_list)))
|
||||
bb.msg.note(2, bb.msg.domain.Provider, "consider defining a PREFERRED_PROVIDER entry to match runtime %s" % item)
|
||||
bb.event.fire(bb.event.MultipleProviders(item,providers_list, cfgData, runtime=True))
|
||||
self.consider_msgs_cache.append(item)
|
||||
|
||||
if len(preferred) > 1:
|
||||
if item not in self.consider_msgs_cache:
|
||||
providers_list = []
|
||||
for fn in preferred:
|
||||
providers_list.append(dataCache.pkg_fn[fn])
|
||||
bb.msg.note(2, bb.msg.domain.Provider, "multiple preferred providers are available for runtime %s (%s);" % (item, ", ".join(providers_list)))
|
||||
bb.msg.note(2, bb.msg.domain.Provider, "consider defining only one PREFERRED_PROVIDER entry to match runtime %s" % item)
|
||||
bb.event.fire(bb.event.MultipleProviders(item,providers_list, cfgData, runtime=True))
|
||||
self.consider_msgs_cache.append(item)
|
||||
|
||||
# run through the list until we find one that we can build
|
||||
for fn in eligible:
|
||||
fnid = self.getfn_id(fn)
|
||||
if fnid in self.failed_fnids:
|
||||
continue
|
||||
bb.msg.debug(2, bb.msg.domain.Provider, "adding %s to satisfy runtime %s" % (fn, item))
|
||||
self.add_runtime_target(fn, item)
|
||||
self.add_tasks(fn, dataCache)
|
||||
|
||||
def fail_fnid(self, fnid):
|
||||
"""
|
||||
Mark a file as failed (unbuildable)
|
||||
Remove any references from build and runtime provider lists
|
||||
"""
|
||||
if fnid in self.failed_fnids:
|
||||
return
|
||||
bb.msg.debug(1, bb.msg.domain.Provider, "Removing failed file %s" % self.fn_index[fnid])
|
||||
self.failed_fnids.append(fnid)
|
||||
for target in self.build_targets:
|
||||
if fnid in self.build_targets[target]:
|
||||
self.build_targets[target].remove(fnid)
|
||||
if len(self.build_targets[target]) == 0:
|
||||
self.remove_buildtarget(target)
|
||||
for target in self.run_targets:
|
||||
if fnid in self.run_targets[target]:
|
||||
self.run_targets[target].remove(fnid)
|
||||
if len(self.run_targets[target]) == 0:
|
||||
self.remove_runtarget(target)
|
||||
|
||||
def remove_buildtarget(self, targetid):
|
||||
"""
|
||||
Mark a build target as failed (unbuildable)
|
||||
Trigger removal of any files that have this as a dependency
|
||||
"""
|
||||
bb.msg.note(2, bb.msg.domain.Provider, "Removing failed build target %s" % self.build_names_index[targetid])
|
||||
self.failed_deps.append(targetid)
|
||||
dependees = self.get_dependees(targetid)
|
||||
for fnid in dependees:
|
||||
self.fail_fnid(fnid)
|
||||
if self.abort and targetid in self.external_targets:
|
||||
bb.msg.error(bb.msg.domain.Provider, "No buildable providers available for required build target %s" % self.build_names_index[targetid])
|
||||
raise bb.providers.NoProvider
|
||||
|
||||
def remove_runtarget(self, targetid):
|
||||
"""
|
||||
Mark a run target as failed (unbuildable)
|
||||
Trigger removal of any files that have this as a dependency
|
||||
"""
|
||||
bb.msg.note(1, bb.msg.domain.Provider, "Removing failed runtime build target %s" % self.run_names_index[targetid])
|
||||
self.failed_rdeps.append(targetid)
|
||||
dependees = self.get_rdependees(targetid)
|
||||
for fnid in dependees:
|
||||
self.fail_fnid(fnid)
|
||||
|
||||
def add_unresolved(self, cfgData, dataCache):
|
||||
"""
|
||||
Resolve all unresolved build and runtime targets
|
||||
"""
|
||||
bb.msg.note(1, bb.msg.domain.TaskData, "Resolving missing task queue dependencies")
|
||||
while 1:
|
||||
added = 0
|
||||
for target in self.get_unresolved_build_targets(dataCache):
|
||||
try:
|
||||
self.add_provider_internal(cfgData, dataCache, target)
|
||||
added = added + 1
|
||||
except bb.providers.NoProvider:
|
||||
targetid = self.getbuild_id(target)
|
||||
if self.abort and targetid in self.external_targets:
|
||||
raise
|
||||
self.remove_buildtarget(targetid)
|
||||
for target in self.get_unresolved_run_targets(dataCache):
|
||||
try:
|
||||
self.add_rprovider(cfgData, dataCache, target)
|
||||
added = added + 1
|
||||
except bb.providers.NoRProvider:
|
||||
self.remove_runtarget(self.getrun_id(target))
|
||||
bb.msg.debug(1, bb.msg.domain.TaskData, "Resolved " + str(added) + " extra dependecies")
|
||||
if added == 0:
|
||||
break
|
||||
# self.dump_data()
|
||||
|
||||
def dump_data(self):
|
||||
"""
|
||||
Dump some debug information on the internal data structures
|
||||
"""
|
||||
bb.msg.debug(3, bb.msg.domain.TaskData, "build_names:")
|
||||
bb.msg.debug(3, bb.msg.domain.TaskData, ", ".join(self.build_names_index))
|
||||
bb.msg.debug(3, bb.msg.domain.TaskData, "run_names:")
|
||||
bb.msg.debug(3, bb.msg.domain.TaskData, ", ".join(self.run_names_index))
|
||||
bb.msg.debug(3, bb.msg.domain.TaskData, "build_targets:")
|
||||
for target in self.build_targets.keys():
|
||||
bb.msg.debug(3, bb.msg.domain.TaskData, " %s: %s" % (self.build_names_index[target], self.build_targets[target]))
|
||||
bb.msg.debug(3, bb.msg.domain.TaskData, "run_targets:")
|
||||
for target in self.run_targets.keys():
|
||||
bb.msg.debug(3, bb.msg.domain.TaskData, " %s: %s" % (self.run_names_index[target], self.run_targets[target]))
|
||||
bb.msg.debug(3, bb.msg.domain.TaskData, "tasks:")
|
||||
for task in range(len(self.tasks_name)):
|
||||
bb.msg.debug(3, bb.msg.domain.TaskData, " (%s)%s - %s: %s" % (
|
||||
task,
|
||||
self.fn_index[self.tasks_fnid[task]],
|
||||
self.tasks_name[task],
|
||||
self.tasks_tdepends[task]))
|
||||
bb.msg.debug(3, bb.msg.domain.TaskData, "runtime ids (per fn):")
|
||||
for fnid in self.rdepids:
|
||||
bb.msg.debug(3, bb.msg.domain.TaskData, " %s %s: %s" % (fnid, self.fn_index[fnid], self.rdepids[fnid]))
|
||||
|
||||
|
||||
204
bitbake/lib/bb/utils.py
Normal file
204
bitbake/lib/bb/utils.py
Normal file
@@ -0,0 +1,204 @@
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
"""
|
||||
BitBake Utility Functions
|
||||
"""
|
||||
|
||||
# Copyright (C) 2004 Michael Lauer
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
digits = "0123456789"
|
||||
ascii_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
import re
|
||||
|
||||
def explode_version(s):
|
||||
r = []
|
||||
alpha_regexp = re.compile('^([a-zA-Z]+)(.*)$')
|
||||
numeric_regexp = re.compile('^(\d+)(.*)$')
|
||||
while (s != ''):
|
||||
if s[0] in digits:
|
||||
m = numeric_regexp.match(s)
|
||||
r.append(int(m.group(1)))
|
||||
s = m.group(2)
|
||||
continue
|
||||
if s[0] in ascii_letters:
|
||||
m = alpha_regexp.match(s)
|
||||
r.append(m.group(1))
|
||||
s = m.group(2)
|
||||
continue
|
||||
s = s[1:]
|
||||
return r
|
||||
|
||||
def vercmp_part(a, b):
|
||||
va = explode_version(a)
|
||||
vb = explode_version(b)
|
||||
while True:
|
||||
if va == []:
|
||||
ca = None
|
||||
else:
|
||||
ca = va.pop(0)
|
||||
if vb == []:
|
||||
cb = None
|
||||
else:
|
||||
cb = vb.pop(0)
|
||||
if ca == None and cb == None:
|
||||
return 0
|
||||
if ca > cb:
|
||||
return 1
|
||||
if ca < cb:
|
||||
return -1
|
||||
|
||||
def vercmp(ta, tb):
|
||||
(ea, va, ra) = ta
|
||||
(eb, vb, rb) = tb
|
||||
|
||||
r = int(ea)-int(eb)
|
||||
if (r == 0):
|
||||
r = vercmp_part(va, vb)
|
||||
if (r == 0):
|
||||
r = vercmp_part(ra, rb)
|
||||
return r
|
||||
|
||||
def explode_deps(s):
|
||||
"""
|
||||
Take an RDEPENDS style string of format:
|
||||
"DEPEND1 (optional version) DEPEND2 (optional version) ..."
|
||||
and return a list of dependencies.
|
||||
Version information is ignored.
|
||||
"""
|
||||
r = []
|
||||
l = s.split()
|
||||
flag = False
|
||||
for i in l:
|
||||
if i[0] == '(':
|
||||
flag = True
|
||||
j = []
|
||||
if flag:
|
||||
j.append(i)
|
||||
else:
|
||||
r.append(i)
|
||||
if flag and i.endswith(')'):
|
||||
flag = False
|
||||
# Ignore version
|
||||
#r[-1] += ' ' + ' '.join(j)
|
||||
return r
|
||||
|
||||
|
||||
|
||||
def _print_trace(body, line):
|
||||
"""
|
||||
Print the Environment of a Text Body
|
||||
"""
|
||||
import bb
|
||||
|
||||
# print the environment of the method
|
||||
bb.msg.error(bb.msg.domain.Util, "Printing the environment of the function")
|
||||
min_line = max(1,line-4)
|
||||
max_line = min(line+4,len(body)-1)
|
||||
for i in range(min_line,max_line+1):
|
||||
bb.msg.error(bb.msg.domain.Util, "\t%.4d:%s" % (i, body[i-1]) )
|
||||
|
||||
|
||||
def better_compile(text, file, realfile):
|
||||
"""
|
||||
A better compile method. This method
|
||||
will print the offending lines.
|
||||
"""
|
||||
try:
|
||||
return compile(text, file, "exec")
|
||||
except Exception, e:
|
||||
import bb,sys
|
||||
|
||||
# split the text into lines again
|
||||
body = text.split('\n')
|
||||
bb.msg.error(bb.msg.domain.Util, "Error in compiling: ", realfile)
|
||||
bb.msg.error(bb.msg.domain.Util, "The lines resulting into this error were:")
|
||||
bb.msg.error(bb.msg.domain.Util, "\t%d:%s:'%s'" % (e.lineno, e.__class__.__name__, body[e.lineno-1]))
|
||||
|
||||
_print_trace(body, e.lineno)
|
||||
|
||||
# exit now
|
||||
sys.exit(1)
|
||||
|
||||
def better_exec(code, context, text, realfile):
|
||||
"""
|
||||
Similiar to better_compile, better_exec will
|
||||
print the lines that are responsible for the
|
||||
error.
|
||||
"""
|
||||
import bb,sys
|
||||
try:
|
||||
exec code in context
|
||||
except:
|
||||
(t,value,tb) = sys.exc_info()
|
||||
|
||||
if t in [bb.parse.SkipPackage, bb.build.FuncFailed]:
|
||||
raise
|
||||
|
||||
# print the Header of the Error Message
|
||||
bb.msg.error(bb.msg.domain.Util, "Error in executing: ", realfile)
|
||||
bb.msg.error(bb.msg.domain.Util, "Exception:%s Message:%s" % (t,value) )
|
||||
|
||||
# let us find the line number now
|
||||
while tb.tb_next:
|
||||
tb = tb.tb_next
|
||||
|
||||
import traceback
|
||||
line = traceback.tb_lineno(tb)
|
||||
|
||||
_print_trace( text.split('\n'), line )
|
||||
|
||||
raise
|
||||
|
||||
def Enum(*names):
|
||||
"""
|
||||
A simple class to give Enum support
|
||||
"""
|
||||
|
||||
assert names, "Empty enums are not supported"
|
||||
|
||||
class EnumClass(object):
|
||||
__slots__ = names
|
||||
def __iter__(self): return iter(constants)
|
||||
def __len__(self): return len(constants)
|
||||
def __getitem__(self, i): return constants[i]
|
||||
def __repr__(self): return 'Enum' + str(names)
|
||||
def __str__(self): return 'enum ' + str(constants)
|
||||
|
||||
class EnumValue(object):
|
||||
__slots__ = ('__value')
|
||||
def __init__(self, value): self.__value = value
|
||||
Value = property(lambda self: self.__value)
|
||||
EnumType = property(lambda self: EnumType)
|
||||
def __hash__(self): return hash(self.__value)
|
||||
def __cmp__(self, other):
|
||||
# C fans might want to remove the following assertion
|
||||
# to make all enums comparable by ordinal value {;))
|
||||
assert self.EnumType is other.EnumType, "Only values from the same enum are comparable"
|
||||
return cmp(self.__value, other.__value)
|
||||
def __invert__(self): return constants[maximum - self.__value]
|
||||
def __nonzero__(self): return bool(self.__value)
|
||||
def __repr__(self): return str(names[self.__value])
|
||||
|
||||
maximum = len(names) - 1
|
||||
constants = [None] * len(names)
|
||||
for i, each in enumerate(names):
|
||||
val = EnumValue(i)
|
||||
setattr(EnumClass, each, val)
|
||||
constants[i] = val
|
||||
constants = tuple(constants)
|
||||
EnumType = EnumClass()
|
||||
return EnumType
|
||||
102
build/conf/local.conf.sample
Normal file
102
build/conf/local.conf.sample
Normal file
@@ -0,0 +1,102 @@
|
||||
# Where to cache the files Poky downloads
|
||||
DL_DIR ?= "${OEROOT}/sources"
|
||||
BBFILES = "${OEROOT}/meta/packages/*/*.bb"
|
||||
|
||||
# To enable extra packages, uncomment the following lines:
|
||||
# BBFILES := "${OEROOT}/meta/packages/*/*.bb ${OEROOT}/meta-extras/packages/*/*.bb"
|
||||
# BBFILE_COLLECTIONS = "normal extras"
|
||||
# BBFILE_PATTERN_normal = "^${OEROOT}/meta/"
|
||||
# BBFILE_PATTERN_extras = "^${OEROOT}/meta/"
|
||||
# BBFILE_PRIORITY_normal = "5"
|
||||
# BBFILE_PRIORITY_extras = "5"
|
||||
|
||||
BBMASK = ""
|
||||
|
||||
# The machine to target
|
||||
MACHINE ?= "qemuarm"
|
||||
|
||||
# Other supported machines
|
||||
#MACHINE ?= "cmx270"
|
||||
#MACHINE ?= "qemux86"
|
||||
#MACHINE ?= "c7x0"
|
||||
#MACHINE ?= "akita"
|
||||
#MACHINE ?= "spitz"
|
||||
#MACHINE ?= "nokia770"
|
||||
|
||||
|
||||
DISTRO ?= "poky"
|
||||
# For bleeding edge / experimental / unstable package versions
|
||||
# DISTRO ?= "poky-bleeding"
|
||||
|
||||
# IMAGE_FEATURES configuration of the generated images
|
||||
# (Some of these are automatically added to certain image types)
|
||||
# "dbg-pkgs" - add -dbg packages for all installed packages
|
||||
# (adds symbol information for debugging/profiling)
|
||||
# "dev-pkgs" - add -dev packages for all installed packages
|
||||
# (useful if you want to develop against libs in the image)
|
||||
# "tools-sdk" - add development tools (gcc, make, pkgconfig etc.)
|
||||
# "tools-debug" - add debugging tools (gdb, strace)
|
||||
# "tools-profile" - add profiling tools (oprofile, exmap, lttng valgrind (x86 only))
|
||||
# "tools-testapps" - add useful testing tools (ts_print, aplay, arecord etc.)
|
||||
# "debug-tweaks" - make an image for suitable of development
|
||||
# e.g. ssh root access has a blank password
|
||||
# There are other application targets too, see meta/classes/poky-image.bbclass
|
||||
# and meta/packages/tasks/task-poky.bb for more details.
|
||||
|
||||
IMAGE_FEATURES = "tools-dbg tools-profile tools-testapps debug-tweaks"
|
||||
|
||||
# A list of packaging systems used in generated images
|
||||
# The first package type listed will be used for rootfs generation
|
||||
# include 'package_deb' for debs
|
||||
# include 'package_ipk' for ipks
|
||||
#PACKAGE_CLASSES ?= "package_deb package_ipk"
|
||||
PACKAGE_CLASSES ?= "package_ipk"
|
||||
|
||||
# POKYMODE controls the characteristics of the generated packages/images.
|
||||
# Options include several different EABI combinations and a
|
||||
# compatibility mode for the OABI mode poky use to use. Use "oabi" for machines
|
||||
# with kernels < 2.6.18 for example. The default is "eabi". These changes only
|
||||
# really apply for ARM machines.
|
||||
# POKYMODE = "oabi"
|
||||
|
||||
# Uncomment this to specify where BitBake should create its temporary files.
|
||||
# Note that a full build of everything in OpenEmbedded will take GigaBytes of hard
|
||||
# disk space, so make sure to free enough space. The default TMPDIR is
|
||||
# <build directory>/tmp
|
||||
TMPDIR = "${OEROOT}/build/tmp"
|
||||
|
||||
# Uncomment and set to allow bitbake to execute multiple tasks at once.
|
||||
# Note, This option is currently experimental - YMMV.
|
||||
# BB_NUMBER_THREADS = "1"
|
||||
|
||||
# Comment this out if you are *not* using provided qemu deb - see README
|
||||
ASSUME_PROVIDED += "qemu-native"
|
||||
|
||||
# Uncomment these two if you want BitBake to build images useful for debugging.
|
||||
# DEBUG_BUILD = "1"
|
||||
# INHIBIT_PACKAGE_STRIP = "1"
|
||||
|
||||
# Uncomment these to build a package such that you can use gprof to profile it.
|
||||
# NOTE: This will only work with 'linux' targets, not
|
||||
# 'linux-uclibc', as uClibc doesn't provide the necessary
|
||||
# object files. Also, don't build glibc itself with these
|
||||
# flags, or it'll fail to build.
|
||||
#
|
||||
# PROFILE_OPTIMIZATION = "-pg"
|
||||
# SELECTED_OPTIMIZATION = "${PROFILE_OPTIMIZATION}"
|
||||
# LDFLAGS =+ "-pg"
|
||||
|
||||
# Uncomment this if you want BitBake to emit debugging output
|
||||
# BBDEBUG = "yes"
|
||||
# Uncomment this if you want BitBake to emit the log if a build fails.
|
||||
BBINCLUDELOGS = "yes"
|
||||
|
||||
# Specifies a location to search for pre-generated tarballs when fetching
|
||||
# a cvs:// URI. Uncomment this, if you not want to pull directly from CVS.
|
||||
CVS_TARBALL_STASH = "http://folks.o-hand.com/~richard/poky/sources/"
|
||||
|
||||
ENABLE_BINARY_LOCALE_GENERATION = "1"
|
||||
|
||||
# A precompiled poky toolchain is available. If installed, uncomment the
|
||||
# line below to enable (Note this support is still experimental)
|
||||
#require conf/external_toolchain.conf
|
||||
17
meta-extras/COPYING.MIT
Normal file
17
meta-extras/COPYING.MIT
Normal file
@@ -0,0 +1,17 @@
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
312
meta-extras/packages/bash/bash-3.2/001-005.patch
vendored
Normal file
312
meta-extras/packages/bash/bash-3.2/001-005.patch
vendored
Normal file
@@ -0,0 +1,312 @@
|
||||
|
||||
Collected upstream patches: 001 -> 005
|
||||
|
||||
Index: bash-3.2/parse.y
|
||||
===================================================================
|
||||
--- bash-3.2.orig/parse.y 2006-11-27 20:09:18.000000000 +0100
|
||||
+++ bash-3.2/parse.y 2006-11-27 20:10:10.000000000 +0100
|
||||
@@ -1029,6 +1029,7 @@
|
||||
#define PST_CMDTOKEN 0x1000 /* command token OK - unused */
|
||||
#define PST_COMPASSIGN 0x2000 /* parsing x=(...) compound assignment */
|
||||
#define PST_ASSIGNOK 0x4000 /* assignment statement ok in this context */
|
||||
+#define PST_REGEXP 0x8000 /* parsing an ERE/BRE as a single word */
|
||||
|
||||
/* Initial size to allocate for tokens, and the
|
||||
amount to grow them by. */
|
||||
@@ -2591,6 +2592,9 @@
|
||||
return (character);
|
||||
}
|
||||
|
||||
+ if (parser_state & PST_REGEXP)
|
||||
+ goto tokword;
|
||||
+
|
||||
/* Shell meta-characters. */
|
||||
if MBTEST(shellmeta (character) && ((parser_state & PST_DBLPAREN) == 0))
|
||||
{
|
||||
@@ -2698,6 +2702,7 @@
|
||||
if MBTEST(character == '-' && (last_read_token == LESS_AND || last_read_token == GREATER_AND))
|
||||
return (character);
|
||||
|
||||
+tokword:
|
||||
/* Okay, if we got this far, we have to read a word. Read one,
|
||||
and then check it against the known ones. */
|
||||
result = read_token_word (character);
|
||||
@@ -2735,7 +2740,7 @@
|
||||
/* itrace("parse_matched_pair: open = %c close = %c", open, close); */
|
||||
count = 1;
|
||||
pass_next_character = backq_backslash = was_dollar = in_comment = 0;
|
||||
- check_comment = (flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
|
||||
+ check_comment = (flags & P_COMMAND) && qc != '`' && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
|
||||
|
||||
/* RFLAGS is the set of flags we want to pass to recursive calls. */
|
||||
rflags = (qc == '"') ? P_DQUOTE : (flags & P_DQUOTE);
|
||||
@@ -3202,8 +3207,11 @@
|
||||
if (tok == WORD && test_binop (yylval.word->word))
|
||||
op = yylval.word;
|
||||
#if defined (COND_REGEXP)
|
||||
- else if (tok == WORD && STREQ (yylval.word->word,"=~"))
|
||||
- op = yylval.word;
|
||||
+ else if (tok == WORD && STREQ (yylval.word->word, "=~"))
|
||||
+ {
|
||||
+ op = yylval.word;
|
||||
+ parser_state |= PST_REGEXP;
|
||||
+ }
|
||||
#endif
|
||||
else if (tok == '<' || tok == '>')
|
||||
op = make_word_from_token (tok); /* ( */
|
||||
@@ -3234,6 +3242,7 @@
|
||||
|
||||
/* rhs */
|
||||
tok = read_token (READ);
|
||||
+ parser_state &= ~PST_REGEXP;
|
||||
if (tok == WORD)
|
||||
{
|
||||
tright = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL);
|
||||
@@ -3419,9 +3428,34 @@
|
||||
goto next_character;
|
||||
}
|
||||
|
||||
+#ifdef COND_REGEXP
|
||||
+ /* When parsing a regexp as a single word inside a conditional command,
|
||||
+ we need to special-case characters special to both the shell and
|
||||
+ regular expressions. Right now, that is only '(' and '|'. */ /*)*/
|
||||
+ if MBTEST((parser_state & PST_REGEXP) && (character == '(' || character == '|')) /*)*/
|
||||
+ {
|
||||
+ if (character == '|')
|
||||
+ goto got_character;
|
||||
+
|
||||
+ push_delimiter (dstack, character);
|
||||
+ ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);
|
||||
+ pop_delimiter (dstack);
|
||||
+ if (ttok == &matched_pair_error)
|
||||
+ return -1; /* Bail immediately. */
|
||||
+ RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2,
|
||||
+ token_buffer_size, TOKEN_DEFAULT_GROW_SIZE);
|
||||
+ token[token_index++] = character;
|
||||
+ strcpy (token + token_index, ttok);
|
||||
+ token_index += ttoklen;
|
||||
+ FREE (ttok);
|
||||
+ dollar_present = all_digit_token = 0;
|
||||
+ goto next_character;
|
||||
+ }
|
||||
+#endif /* COND_REGEXP */
|
||||
+
|
||||
#ifdef EXTENDED_GLOB
|
||||
/* Parse a ksh-style extended pattern matching specification. */
|
||||
- if (extended_glob && PATTERN_CHAR (character))
|
||||
+ if MBTEST(extended_glob && PATTERN_CHAR (character))
|
||||
{
|
||||
peek_char = shell_getc (1);
|
||||
if MBTEST(peek_char == '(') /* ) */
|
||||
Index: bash-3.2/patchlevel.h
|
||||
===================================================================
|
||||
--- bash-3.2.orig/patchlevel.h 2006-11-27 20:09:18.000000000 +0100
|
||||
+++ bash-3.2/patchlevel.h 2006-11-27 20:11:06.000000000 +0100
|
||||
@@ -25,6 +25,6 @@
|
||||
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
|
||||
looks for to find the patch level (for the sccs version string). */
|
||||
|
||||
-#define PATCHLEVEL 0
|
||||
+#define PATCHLEVEL 5
|
||||
|
||||
#endif /* _PATCHLEVEL_H_ */
|
||||
Index: bash-3.2/po/ru.po
|
||||
===================================================================
|
||||
--- bash-3.2.orig/po/ru.po 2006-11-27 20:09:18.000000000 +0100
|
||||
+++ bash-3.2/po/ru.po 2006-11-27 20:10:00.000000000 +0100
|
||||
@@ -12,7 +12,7 @@
|
||||
"Last-Translator: Evgeniy Dushistov <dushistov@mail.ru>\n"
|
||||
"Language-Team: Russian <ru@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
-"Content-Type: text/plain; charset=UTF-8\n"
|
||||
+"Content-Type: text/plain; charset=KOI8-R\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
|
||||
|
||||
Index: bash-3.2/subst.c
|
||||
===================================================================
|
||||
--- bash-3.2.orig/subst.c 2006-11-27 20:09:18.000000000 +0100
|
||||
+++ bash-3.2/subst.c 2006-11-27 20:10:26.000000000 +0100
|
||||
@@ -5707,6 +5707,11 @@
|
||||
vtype &= ~VT_STARSUB;
|
||||
|
||||
mflags = 0;
|
||||
+ if (patsub && *patsub == '/')
|
||||
+ {
|
||||
+ mflags |= MATCH_GLOBREP;
|
||||
+ patsub++;
|
||||
+ }
|
||||
|
||||
/* Malloc this because expand_string_if_necessary or one of the expansion
|
||||
functions in its call chain may free it on a substitution error. */
|
||||
@@ -5741,13 +5746,12 @@
|
||||
}
|
||||
|
||||
/* ksh93 doesn't allow the match specifier to be a part of the expanded
|
||||
- pattern. This is an extension. */
|
||||
+ pattern. This is an extension. Make sure we don't anchor the pattern
|
||||
+ at the beginning or end of the string if we're doing global replacement,
|
||||
+ though. */
|
||||
p = pat;
|
||||
- if (pat && pat[0] == '/')
|
||||
- {
|
||||
- mflags |= MATCH_GLOBREP|MATCH_ANY;
|
||||
- p++;
|
||||
- }
|
||||
+ if (mflags & MATCH_GLOBREP)
|
||||
+ mflags |= MATCH_ANY;
|
||||
else if (pat && pat[0] == '#')
|
||||
{
|
||||
mflags |= MATCH_BEG;
|
||||
Index: bash-3.2/tests/new-exp.right
|
||||
===================================================================
|
||||
--- bash-3.2.orig/tests/new-exp.right 2006-11-27 20:09:18.000000000 +0100
|
||||
+++ bash-3.2/tests/new-exp.right 2006-11-27 20:10:29.000000000 +0100
|
||||
@@ -430,7 +430,7 @@
|
||||
Case06---1---A B C::---
|
||||
Case07---3---A:B:C---
|
||||
Case08---3---A:B:C---
|
||||
-./new-exp.tests: line 506: /${$(($#-1))}: bad substitution
|
||||
+./new-exp.tests: line 506: ${$(($#-1))}: bad substitution
|
||||
argv[1] = <a>
|
||||
argv[2] = <b>
|
||||
argv[3] = <c>
|
||||
Index: bash-3.2/builtins/printf.def
|
||||
===================================================================
|
||||
--- bash-3.2.orig/builtins/printf.def 2006-11-27 20:09:18.000000000 +0100
|
||||
+++ bash-3.2/builtins/printf.def 2006-11-27 20:11:05.000000000 +0100
|
||||
@@ -49,6 +49,12 @@
|
||||
# define INT_MIN (-2147483647-1)
|
||||
#endif
|
||||
|
||||
+#if defined (PREFER_STDARG)
|
||||
+# include <stdarg.h>
|
||||
+#else
|
||||
+# include <varargs.h>
|
||||
+#endif
|
||||
+
|
||||
#include <stdio.h>
|
||||
#include <chartypes.h>
|
||||
|
||||
@@ -151,6 +157,10 @@
|
||||
#define SKIP1 "#'-+ 0"
|
||||
#define LENMODS "hjlLtz"
|
||||
|
||||
+#ifndef HAVE_ASPRINTF
|
||||
+extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
|
||||
+#endif
|
||||
+
|
||||
static void printf_erange __P((char *));
|
||||
static int printstr __P((char *, char *, int, int, int));
|
||||
static int tescape __P((char *, char *, int *));
|
||||
Index: bash-3.2/lib/sh/snprintf.c
|
||||
===================================================================
|
||||
--- bash-3.2.orig/lib/sh/snprintf.c 2006-11-27 20:09:18.000000000 +0100
|
||||
+++ bash-3.2/lib/sh/snprintf.c 2006-11-27 20:11:06.000000000 +0100
|
||||
@@ -471,6 +471,8 @@
|
||||
10^x ~= r
|
||||
* log_10(200) = 2;
|
||||
* log_10(250) = 2;
|
||||
+ *
|
||||
+ * NOTE: do not call this with r == 0 -- an infinite loop results.
|
||||
*/
|
||||
static int
|
||||
log_10(r)
|
||||
@@ -576,8 +578,11 @@
|
||||
{
|
||||
integral_part[0] = '0';
|
||||
integral_part[1] = '\0';
|
||||
- fraction_part[0] = '0';
|
||||
- fraction_part[1] = '\0';
|
||||
+ /* The fractional part has to take the precision into account */
|
||||
+ for (ch = 0; ch < precision-1; ch++)
|
||||
+ fraction_part[ch] = '0';
|
||||
+ fraction_part[ch] = '0';
|
||||
+ fraction_part[ch+1] = '\0';
|
||||
if (fract)
|
||||
*fract = fraction_part;
|
||||
return integral_part;
|
||||
@@ -805,6 +810,7 @@
|
||||
PUT_CHAR(*tmp, p);
|
||||
tmp++;
|
||||
}
|
||||
+
|
||||
PAD_LEFT(p);
|
||||
}
|
||||
|
||||
@@ -972,11 +978,21 @@
|
||||
if ((p->flags & PF_THOUSANDS) && grouping && (t = groupnum (tmp)))
|
||||
tmp = t;
|
||||
|
||||
+ if ((*p->pf == 'g' || *p->pf == 'G') && (p->flags & PF_ALTFORM) == 0)
|
||||
+ {
|
||||
+ /* smash the trailing zeros unless altform */
|
||||
+ for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--)
|
||||
+ tmp2[i] = '\0';
|
||||
+ if (tmp2[0] == '\0')
|
||||
+ p->precision = 0;
|
||||
+ }
|
||||
+
|
||||
/* calculate the padding. 1 for the dot */
|
||||
p->width = p->width -
|
||||
((d > 0. && p->justify == RIGHT) ? 1:0) -
|
||||
((p->flags & PF_SPACE) ? 1:0) -
|
||||
- strlen(tmp) - p->precision - 1;
|
||||
+ strlen(tmp) - p->precision -
|
||||
+ ((p->precision != 0 || (p->flags & PF_ALTFORM)) ? 1 : 0); /* radix char */
|
||||
PAD_RIGHT(p);
|
||||
PUT_PLUS(d, p, 0.);
|
||||
PUT_SPACE(d, p, 0.);
|
||||
@@ -991,11 +1007,6 @@
|
||||
if (p->precision != 0 || (p->flags & PF_ALTFORM))
|
||||
PUT_CHAR(decpoint, p); /* put the '.' */
|
||||
|
||||
- if ((*p->pf == 'g' || *p->pf == 'G') && (p->flags & PF_ALTFORM) == 0)
|
||||
- /* smash the trailing zeros unless altform */
|
||||
- for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--)
|
||||
- tmp2[i] = '\0';
|
||||
-
|
||||
for (; *tmp2; tmp2++)
|
||||
PUT_CHAR(*tmp2, p); /* the fraction */
|
||||
|
||||
@@ -1011,14 +1022,19 @@
|
||||
char *tmp, *tmp2;
|
||||
int j, i;
|
||||
|
||||
- if (chkinfnan(p, d, 1) || chkinfnan(p, d, 2))
|
||||
+ if (d != 0 && (chkinfnan(p, d, 1) || chkinfnan(p, d, 2)))
|
||||
return; /* already printed nan or inf */
|
||||
|
||||
GETLOCALEDATA(decpoint, thoussep, grouping);
|
||||
DEF_PREC(p);
|
||||
- j = log_10(d);
|
||||
- d = d / pow_10(j); /* get the Mantissa */
|
||||
- d = ROUND(d, p);
|
||||
+ if (d == 0.)
|
||||
+ j = 0;
|
||||
+ else
|
||||
+ {
|
||||
+ j = log_10(d);
|
||||
+ d = d / pow_10(j); /* get the Mantissa */
|
||||
+ d = ROUND(d, p);
|
||||
+ }
|
||||
tmp = dtoa(d, p->precision, &tmp2);
|
||||
|
||||
/* 1 for unit, 1 for the '.', 1 for 'e|E',
|
||||
@@ -1076,6 +1092,7 @@
|
||||
PUT_CHAR(*tmp, p);
|
||||
tmp++;
|
||||
}
|
||||
+
|
||||
PAD_LEFT(p);
|
||||
}
|
||||
#endif
|
||||
@@ -1358,7 +1375,7 @@
|
||||
STAR_ARGS(data);
|
||||
DEF_PREC(data);
|
||||
d = GETDOUBLE(data);
|
||||
- i = log_10(d);
|
||||
+ i = (d != 0.) ? log_10(d) : -1;
|
||||
/*
|
||||
* for '%g|%G' ANSI: use f if exponent
|
||||
* is in the range or [-4,p] exclusively
|
||||
28
meta-extras/packages/bash/bash_3.2.bb
Normal file
28
meta-extras/packages/bash/bash_3.2.bb
Normal file
@@ -0,0 +1,28 @@
|
||||
DESCRIPTION = "An sh-compatible command language interpreter."
|
||||
HOMEPAGE = "http://cnswww.cns.cwru.edu/~chet/bash/bashtop.html"
|
||||
DEPENDS = "ncurses"
|
||||
SECTION = "base/shell"
|
||||
LICENSE = "GPL"
|
||||
|
||||
SRC_URI = "${GNU_MIRROR}/bash/bash-${PV}.tar.gz \
|
||||
file://001-005.patch;patch=1"
|
||||
|
||||
inherit autotools gettext
|
||||
|
||||
PARALLEL_MAKE = ""
|
||||
|
||||
bindir = "/bin"
|
||||
sbindir = "/sbin"
|
||||
|
||||
EXTRA_OECONF = "--with-ncurses"
|
||||
export CC_FOR_BUILD = "${BUILD_CC}"
|
||||
|
||||
do_configure () {
|
||||
gnu-configize
|
||||
oe_runconf
|
||||
}
|
||||
|
||||
pkg_postinst () {
|
||||
grep -q "bin/bash" ${sysconfdir}/shells || echo /bin/bash >> ${sysconfdir}/shells
|
||||
grep -q "bin/sh" ${sysconfdir}/shells || echo /bin/sh >> ${sysconfdir}/shells
|
||||
}
|
||||
23
meta-extras/packages/cdrtools/cdrtools-native_2.01.bb
Normal file
23
meta-extras/packages/cdrtools/cdrtools-native_2.01.bb
Normal file
@@ -0,0 +1,23 @@
|
||||
# cdrtools-native OE build file
|
||||
# Copyright (C) 2004-2006, Advanced Micro Devices, Inc. All Rights Reserved
|
||||
# Released under the MIT license (see packages/COPYING)
|
||||
|
||||
LICENSE="GPL"
|
||||
DESCRIPTION="A set of tools for CD recording, including cdrecord"
|
||||
HOMEPAGE="http://cdrecord.berlios.de/old/private/cdrecord.html"
|
||||
|
||||
SRC_URI="ftp://ftp.berlios.de/pub/cdrecord/cdrtools-${PV}.tar.bz2"
|
||||
|
||||
S="${WORKDIR}/cdrtools-${PV}"
|
||||
|
||||
inherit native
|
||||
|
||||
STAGE_TEMP="${WORKDIR}/stage_temp"
|
||||
|
||||
do_stage() {
|
||||
install -d ${STAGE_TEMP}
|
||||
make install INS_BASE=${STAGE_TEMP}
|
||||
|
||||
install -d ${STAGING_BINDIR}
|
||||
install ${STAGE_TEMP}/bin/* ${STAGING_BINDIR}
|
||||
}
|
||||
25
meta-extras/packages/dhcdbd/dhcdbd_2.0.bb
Normal file
25
meta-extras/packages/dhcdbd/dhcdbd_2.0.bb
Normal file
@@ -0,0 +1,25 @@
|
||||
DESCRIPTION="DBus-enabled dhcp client"
|
||||
SECTION="net"
|
||||
LICENSE="GPL"
|
||||
HOMEPAGE="http://people.redhat.com/jvdias/dhcdbd/"
|
||||
|
||||
DEPENDS = "dbus"
|
||||
RDEPENDS = "dhcp-client"
|
||||
|
||||
PR = "r0"
|
||||
|
||||
SRC_URI="http://people.redhat.com/dcantrel/dhcdbd/dhcdbd-${PV}.tar.bz2 \
|
||||
file://no-ext-options.patch;patch=1 \
|
||||
file://dhcdbd"
|
||||
|
||||
do_compile() {
|
||||
CC=${TARGET_SYS}-gcc DESTDIR=${prefix} make
|
||||
}
|
||||
|
||||
do_install() {
|
||||
DESTDIR=${D} make install
|
||||
install -d ${D}/etc/init.d
|
||||
install -m 0755 ${WORKDIR}/dhcdbd ${D}/etc/init.d/
|
||||
}
|
||||
|
||||
FILES_${PN} += "${sysconfdir} ${datadir}/dbus-1 ${base_sbindir}/*"
|
||||
20
meta-extras/packages/dhcdbd/files/dbus-api-fix.patch
Normal file
20
meta-extras/packages/dhcdbd/files/dbus-api-fix.patch
Normal file
@@ -0,0 +1,20 @@
|
||||
--- /tmp/dbus_service.c 2006-08-24 22:09:14.000000000 +0200
|
||||
+++ dhcdbd-1.14/dbus_service.c 2006-08-24 22:09:44.228306000 +0200
|
||||
@@ -1412,7 +1412,7 @@
|
||||
return ( cs );
|
||||
|
||||
give_up:
|
||||
- dbus_connection_disconnect( connection );
|
||||
+ dbus_connection_close( connection );
|
||||
dbus_shutdown();
|
||||
return ( 0L );
|
||||
}
|
||||
@@ -1456,7 +1456,7 @@
|
||||
cs->roots=0L;
|
||||
|
||||
|
||||
- dbus_connection_disconnect( cs->connection );
|
||||
+ dbus_connection_close( cs->connection );
|
||||
dbus_shutdown();
|
||||
free( cs );
|
||||
}
|
||||
28
meta-extras/packages/dhcdbd/files/dhcdbd
Normal file
28
meta-extras/packages/dhcdbd/files/dhcdbd
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# DHCDBD startup script
|
||||
|
||||
. /etc/profile
|
||||
|
||||
case $1 in
|
||||
'start')
|
||||
echo -n "Starting dhcdbd daemon: dhcdbd"
|
||||
/sbin/dhcdbd --system
|
||||
echo "."
|
||||
;;
|
||||
|
||||
'stop')
|
||||
echo -n "Stopping dhcdbd: dhcdbd"
|
||||
killall `ps |grep /sbin/dhcdbd | grep -v grep | cut "-d " -f2`
|
||||
echo "."
|
||||
;;
|
||||
|
||||
'restart')
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 { start | stop | restart }"
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,26 @@
|
||||
diff -Naur dhcdbd-1.14/Makefile dhcdbd-1.14-mod/Makefile
|
||||
--- dhcdbd-1.14/Makefile 2006-01-17 22:23:51.000000000 +0100
|
||||
+++ dhcdbd-1.14-mod/Makefile 2006-08-02 18:02:42.000000000 +0200
|
||||
@@ -7,8 +7,8 @@
|
||||
LDFLAGS ?= -g
|
||||
DESTDIR ?= /
|
||||
LIBDIR ?= lib
|
||||
-DBUS_INCLUDES ?= -I/usr/$(LIBDIR)/dbus-1.0/include -I/usr/include/dbus-1.0
|
||||
-DBUS_LIBS ?= -ldbus-1
|
||||
+DBUS_INCLUDES ?= `pkg-config dbus-1 --cflags`
|
||||
+DBUS_LIBS ?= `pkg-config dbus-1 --libs`
|
||||
OBJS = dbus_service.o dhcdbd.o dhcp_options.o main.o
|
||||
SRCS = dbus_service.c dhcdbd.c dhcp_options.c main.c
|
||||
INCS = dbus_service.h dhcdbd.h dhcp_options.h includes.h
|
||||
diff -Naur dhcdbd-1.14/tests/Makefile dhcdbd-1.14-mod/tests/Makefile
|
||||
--- dhcdbd-1.14/tests/Makefile 2006-01-17 22:23:51.000000000 +0100
|
||||
+++ dhcdbd-1.14-mod/tests/Makefile 2006-08-02 18:11:43.000000000 +0200
|
||||
@@ -2,7 +2,7 @@
|
||||
LD = ${CC}
|
||||
CFLAGS ?= -g -Wall
|
||||
LDFLAGS ?= -g
|
||||
-DBUS_LIBS ?= -ldbus-1
|
||||
+DBUS_LIBS ?= `pkg-config dbus-1 --libs`
|
||||
|
||||
all: test_dhcp_options test_dhcdbd_state test_subscriber test_subscriber_dbus test_prospective_subscriber
|
||||
|
||||
13
meta-extras/packages/dhcdbd/files/no-ext-options.patch
Normal file
13
meta-extras/packages/dhcdbd/files/no-ext-options.patch
Normal file
@@ -0,0 +1,13 @@
|
||||
Index: dhcdbd-2.0/include/dhcdbd.h
|
||||
===================================================================
|
||||
--- dhcdbd-2.0.orig/include/dhcdbd.h 2006-10-18 09:38:18.000000000 +0100
|
||||
+++ dhcdbd-2.0/include/dhcdbd.h 2006-10-18 09:38:45.000000000 +0100
|
||||
@@ -76,7 +76,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef DHCLIENT_EXTENDED_OPTION_ENVIRONMENT
|
||||
-#define DHCLIENT_EXTENDED_OPTION_ENVIRONMENT 1
|
||||
+#define DHCLIENT_EXTENDED_OPTION_ENVIRONMENT 0
|
||||
#endif
|
||||
|
||||
#define DHCDBD_INTERFACE_TEXT "text"
|
||||
51
meta-extras/packages/dhcp/dhcp_3.0.2.bb
Normal file
51
meta-extras/packages/dhcp/dhcp_3.0.2.bb
Normal file
@@ -0,0 +1,51 @@
|
||||
SECTION = "console/network"
|
||||
DESCRIPTION = "Internet Software Consortium DHCP package"
|
||||
HOMEPAGE = "http://www.isc.org/"
|
||||
LICENSE = "BSD"
|
||||
PR = "r4"
|
||||
SRC_URI = "ftp://ftp.isc.org/isc/dhcp/dhcp-3.0-history/dhcp-${PV}.tar.gz \
|
||||
file://noattrmode.patch;patch=1 \
|
||||
file://fixincludes.patch;patch=1 \
|
||||
file://dhcp-3.0.3-dhclient-dbus.patch;patch=1;pnum=0 \
|
||||
file://init-relay file://default-relay \
|
||||
file://init-server file://default-server \
|
||||
file://dhclient.conf file://dhcpd.conf"
|
||||
|
||||
do_configure() {
|
||||
./configure
|
||||
}
|
||||
|
||||
do_compile() {
|
||||
make RANLIB=${RANLIB} PREDEFINES='-D_PATH_DHCPD_DB=\"/var/lib/dhcp/dhcpd.leases\" \
|
||||
-D_PATH_DHCLIENT_DB=\"/var/lib/dhcp/dhclient.leases\" \
|
||||
-D_PATH_DHCLIENT_SCRIPT=\"/sbin/dhclient-script\" \
|
||||
-D_PATH_DHCPD_CONF=\"/etc/dhcp/dhcpd.conf\" \
|
||||
-D_PATH_DHCLIENT_CONF=\"/etc/dhcp/dhclient.conf\"'
|
||||
}
|
||||
|
||||
do_install() {
|
||||
make -e DESTDIR=${D} USRMANDIR=${mandir}/man1 ADMMANDIR=${mandir}/man8 FFMANDIR=${mandir}/man5 LIBMANDIR=${mandir}/man3 LIBDIR=${libdir} INCDIR=${includedir} install
|
||||
install -d ${D}${sysconfdir}/init.d
|
||||
install -d ${D}${sysconfdir}/default
|
||||
install -d ${D}${sysconfdir}/dhcp
|
||||
install -m 0755 ${WORKDIR}/init-relay ${D}${sysconfdir}/init.d/dhcp-relay
|
||||
install -m 0644 ${WORKDIR}/default-relay ${D}${sysconfdir}/default/dhcp-relay
|
||||
install -m 0755 ${WORKDIR}/init-server ${D}${sysconfdir}/init.d/dhcp-server
|
||||
install -m 0644 ${WORKDIR}/default-server ${D}${sysconfdir}/default/dhcp-server
|
||||
install -m 0644 ${WORKDIR}/dhclient.conf ${D}${sysconfdir}/dhcp/dhclient.conf
|
||||
install -m 0644 ${WORKDIR}/dhcpd.conf ${D}${sysconfdir}/dhcp/dhcpd.conf
|
||||
}
|
||||
|
||||
PACKAGES += "dhcp-server dhcp-client dhcp-relay dhcp-omshell"
|
||||
FILES_${PN} = ""
|
||||
FILES_dhcp-server = "${sbindir}/dhcpd ${sysconfdir}/init.d/dhcp-server ${sysconfdir}/default/dhcp-server ${sysconfdir}/dhcp/dhcpd.conf"
|
||||
FILES_dhcp-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay"
|
||||
|
||||
FILES_dhcp-client = "${base_sbindir}/dhclient ${base_sbindir}/dhclient-script ${sysconfdir}/dhcp/dhclient.conf"
|
||||
RDEPENDS_dhcp-client = "bash"
|
||||
|
||||
FILES_dhcp-omshell = "${bindir}/omshell"
|
||||
|
||||
CONFFILES_dhcp-server_nylon = "/etc/dhcp/dhcpd.conf"
|
||||
CONFFILES_dhcp-relay_nylon = "/etc/default/dhcp-relay"
|
||||
CONFFILES_dhcp-client_nylon = "/etc/dhcp/dhclient.conf"
|
||||
12
meta-extras/packages/dhcp/files/default-relay
Normal file
12
meta-extras/packages/dhcp/files/default-relay
Normal file
@@ -0,0 +1,12 @@
|
||||
# Defaults for dhcp-relay initscript
|
||||
# sourced by /etc/init.d/dhcp-relay
|
||||
|
||||
# What servers should the DHCP relay forward requests to?
|
||||
# e.g: SERVERS="192.168.0.1"
|
||||
SERVERS=""
|
||||
|
||||
# On what interfaces should the DHCP relay (dhrelay) serve DHCP requests?
|
||||
INTERFACES=""
|
||||
|
||||
# Additional options that are passed to the DHCP relay daemon?
|
||||
OPTIONS=""
|
||||
7
meta-extras/packages/dhcp/files/default-server
Normal file
7
meta-extras/packages/dhcp/files/default-server
Normal file
@@ -0,0 +1,7 @@
|
||||
# Defaults for dhcp initscript
|
||||
# sourced by /etc/init.d/dhcp-server
|
||||
# installed at /etc/default/dhcp-server by the maintainer scripts
|
||||
|
||||
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
|
||||
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
|
||||
INTERFACES=""
|
||||
50
meta-extras/packages/dhcp/files/dhclient.conf
Normal file
50
meta-extras/packages/dhcp/files/dhclient.conf
Normal file
@@ -0,0 +1,50 @@
|
||||
# Configuration file for /sbin/dhclient, which is included in Debian's
|
||||
# dhcp3-client package.
|
||||
#
|
||||
# This is a sample configuration file for dhclient. See dhclient.conf's
|
||||
# man page for more information about the syntax of this file
|
||||
# and a more comprehensive list of the parameters understood by
|
||||
# dhclient.
|
||||
#
|
||||
# Normally, if the DHCP server provides reasonable information and does
|
||||
# not leave anything out (like the domain name, for example), then
|
||||
# few changes must be made to this file, if any.
|
||||
#
|
||||
|
||||
#send host-name "andare.fugue.com";
|
||||
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
|
||||
#send dhcp-lease-time 3600;
|
||||
#supersede domain-name "fugue.com home.vix.com";
|
||||
#prepend domain-name-servers 127.0.0.1;
|
||||
request subnet-mask, broadcast-address, time-offset, routers,
|
||||
domain-name, domain-name-servers, host-name,
|
||||
netbios-name-servers, netbios-scope;
|
||||
#require subnet-mask, domain-name-servers;
|
||||
#timeout 60;
|
||||
#retry 60;
|
||||
#reboot 10;
|
||||
#select-timeout 5;
|
||||
#initial-interval 2;
|
||||
#script "/etc/dhcp3/dhclient-script";
|
||||
#media "-link0 -link1 -link2", "link0 link1";
|
||||
#reject 192.33.137.209;
|
||||
|
||||
#alias {
|
||||
# interface "eth0";
|
||||
# fixed-address 192.5.5.213;
|
||||
# option subnet-mask 255.255.255.255;
|
||||
#}
|
||||
|
||||
#lease {
|
||||
# interface "eth0";
|
||||
# fixed-address 192.33.137.200;
|
||||
# medium "link0 link1";
|
||||
# option host-name "andare.swiftmedia.com";
|
||||
# option subnet-mask 255.255.255.0;
|
||||
# option broadcast-address 192.33.137.255;
|
||||
# option routers 192.33.137.250;
|
||||
# option domain-name-servers 127.0.0.1;
|
||||
# renew 2 2000/1/12 00:00:01;
|
||||
# rebind 2 2000/1/12 00:00:01;
|
||||
# expire 2 2000/1/12 00:00:01;
|
||||
#}
|
||||
@@ -0,0 +1,84 @@
|
||||
--- client/scripts/bsdos
|
||||
+++ client/scripts/bsdos
|
||||
@@ -47,6 +47,11 @@
|
||||
. /etc/dhcp/dhclient-exit-hooks
|
||||
fi
|
||||
# probably should do something with exit status of the local script
|
||||
+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
|
||||
+ dbus-send --system --dest=com.redhat.dhcp \
|
||||
+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
|
||||
+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
|
||||
+ fi
|
||||
exit $exit_status
|
||||
}
|
||||
|
||||
--- client/scripts/freebsd
|
||||
+++ client/scripts/freebsd
|
||||
@@ -57,6 +57,11 @@
|
||||
. /etc/dhcp/dhclient-exit-hooks
|
||||
fi
|
||||
# probably should do something with exit status of the local script
|
||||
+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
|
||||
+ dbus-send --system --dest=com.redhat.dhcp \
|
||||
+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
|
||||
+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
|
||||
+ fi
|
||||
exit $exit_status
|
||||
}
|
||||
|
||||
--- client/scripts/linux
|
||||
+++ client/scripts/linux
|
||||
@@ -69,6 +69,11 @@
|
||||
. /etc/dhcp/dhclient-exit-hooks
|
||||
fi
|
||||
# probably should do something with exit status of the local script
|
||||
+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
|
||||
+ dbus-send --system --dest=com.redhat.dhcp \
|
||||
+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
|
||||
+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
|
||||
+ fi
|
||||
exit $exit_status
|
||||
}
|
||||
|
||||
--- client/scripts/netbsd
|
||||
+++ client/scripts/netbsd
|
||||
@@ -47,6 +47,11 @@
|
||||
. /etc/dhcp/dhclient-exit-hooks
|
||||
fi
|
||||
# probably should do something with exit status of the local script
|
||||
+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
|
||||
+ dbus-send --system --dest=com.redhat.dhcp \
|
||||
+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
|
||||
+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
|
||||
+ fi
|
||||
exit $exit_status
|
||||
}
|
||||
|
||||
--- client/scripts/openbsd
|
||||
+++ client/scripts/openbsd
|
||||
@@ -47,6 +47,11 @@
|
||||
. /etc/dhcp/dhclient-exit-hooks
|
||||
fi
|
||||
# probably should do something with exit status of the local script
|
||||
+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
|
||||
+ dbus-send --system --dest=com.redhat.dhcp \
|
||||
+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
|
||||
+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
|
||||
+ fi
|
||||
exit $exit_status
|
||||
}
|
||||
|
||||
--- client/scripts/solaris
|
||||
+++ client/scripts/solaris
|
||||
@@ -47,6 +47,11 @@
|
||||
. /etc/dhcp/dhclient-exit-hooks
|
||||
fi
|
||||
# probably should do something with exit status of the local script
|
||||
+ if [ x$dhc_dbus != x -a $exit_status -eq 0 ]; then
|
||||
+ dbus-send --system --dest=com.redhat.dhcp \
|
||||
+ --type=method_call /com/redhat/dhcp/$interface com.redhat.dhcp.set \
|
||||
+ 'string:'"`env | grep -Ev '^(PATH|SHLVL|_|PWD|dhc_dbus)\='`"
|
||||
+ fi
|
||||
exit $exit_status
|
||||
}
|
||||
|
||||
108
meta-extras/packages/dhcp/files/dhcpd.conf
Normal file
108
meta-extras/packages/dhcp/files/dhcpd.conf
Normal file
@@ -0,0 +1,108 @@
|
||||
#
|
||||
# Sample configuration file for ISC dhcpd for Debian
|
||||
#
|
||||
# $Id: dhcpd.conf,v 1.1.1.1 2002/05/21 00:07:44 peloy Exp $
|
||||
#
|
||||
|
||||
# The ddns-updates-style parameter controls whether or not the server will
|
||||
# attempt to do a DNS update when a lease is confirmed. We default to the
|
||||
# behavior of the version 2 packages ('none', since DHCP v2 didn't
|
||||
# have support for DDNS.)
|
||||
ddns-update-style none;
|
||||
|
||||
# option definitions common to all supported networks...
|
||||
option domain-name "example.org";
|
||||
option domain-name-servers ns1.example.org, ns2.example.org;
|
||||
|
||||
default-lease-time 600;
|
||||
max-lease-time 7200;
|
||||
|
||||
# If this DHCP server is the official DHCP server for the local
|
||||
# network, the authoritative directive should be uncommented.
|
||||
#authoritative;
|
||||
|
||||
# Use this to send dhcp log messages to a different log file (you also
|
||||
# have to hack syslog.conf to complete the redirection).
|
||||
log-facility local7;
|
||||
|
||||
# No service will be given on this subnet, but declaring it helps the
|
||||
# DHCP server to understand the network topology.
|
||||
|
||||
#subnet 10.152.187.0 netmask 255.255.255.0 {
|
||||
#}
|
||||
|
||||
# This is a very basic subnet declaration.
|
||||
|
||||
#subnet 10.254.239.0 netmask 255.255.255.224 {
|
||||
# range 10.254.239.10 10.254.239.20;
|
||||
# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
|
||||
#}
|
||||
|
||||
# This declaration allows BOOTP clients to get dynamic addresses,
|
||||
# which we don't really recommend.
|
||||
|
||||
#subnet 10.254.239.32 netmask 255.255.255.224 {
|
||||
# range dynamic-bootp 10.254.239.40 10.254.239.60;
|
||||
# option broadcast-address 10.254.239.31;
|
||||
# option routers rtr-239-32-1.example.org;
|
||||
#}
|
||||
|
||||
# A slightly different configuration for an internal subnet.
|
||||
#subnet 10.5.5.0 netmask 255.255.255.224 {
|
||||
# range 10.5.5.26 10.5.5.30;
|
||||
# option domain-name-servers ns1.internal.example.org;
|
||||
# option domain-name "internal.example.org";
|
||||
# option routers 10.5.5.1;
|
||||
# option broadcast-address 10.5.5.31;
|
||||
# default-lease-time 600;
|
||||
# max-lease-time 7200;
|
||||
#}
|
||||
|
||||
# Hosts which require special configuration options can be listed in
|
||||
# host statements. If no address is specified, the address will be
|
||||
# allocated dynamically (if possible), but the host-specific information
|
||||
# will still come from the host declaration.
|
||||
|
||||
#host passacaglia {
|
||||
# hardware ethernet 0:0:c0:5d:bd:95;
|
||||
# filename "vmunix.passacaglia";
|
||||
# server-name "toccata.fugue.com";
|
||||
#}
|
||||
|
||||
# Fixed IP addresses can also be specified for hosts. These addresses
|
||||
# should not also be listed as being available for dynamic assignment.
|
||||
# Hosts for which fixed IP addresses have been specified can boot using
|
||||
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
|
||||
# be booted with DHCP, unless there is an address range on the subnet
|
||||
# to which a BOOTP client is connected which has the dynamic-bootp flag
|
||||
# set.
|
||||
#host fantasia {
|
||||
# hardware ethernet 08:00:07:26:c0:a5;
|
||||
# fixed-address fantasia.fugue.com;
|
||||
#}
|
||||
|
||||
# You can declare a class of clients and then do address allocation
|
||||
# based on that. The example below shows a case where all clients
|
||||
# in a certain class get addresses on the 10.17.224/24 subnet, and all
|
||||
# other clients get addresses on the 10.0.29/24 subnet.
|
||||
|
||||
#class "foo" {
|
||||
# match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
|
||||
#}
|
||||
|
||||
#shared-network 224-29 {
|
||||
# subnet 10.17.224.0 netmask 255.255.255.0 {
|
||||
# option routers rtr-224.example.org;
|
||||
# }
|
||||
# subnet 10.0.29.0 netmask 255.255.255.0 {
|
||||
# option routers rtr-29.example.org;
|
||||
# }
|
||||
# pool {
|
||||
# allow members of "foo";
|
||||
# range 10.17.224.10 10.17.224.250;
|
||||
# }
|
||||
# pool {
|
||||
# deny members of "foo";
|
||||
# range 10.0.29.10 10.0.29.230;
|
||||
# }
|
||||
#}
|
||||
10
meta-extras/packages/dhcp/files/fixincludes.patch
Normal file
10
meta-extras/packages/dhcp/files/fixincludes.patch
Normal file
@@ -0,0 +1,10 @@
|
||||
--- dhcp-3.0.2/common/tr.c~compile 2005-10-13 14:23:37.000000000 +0200
|
||||
+++ dhcp-3.0.2/common/tr.c 2005-10-13 14:23:45.000000000 +0200
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "includes/netinet/udp.h"
|
||||
#include "includes/netinet/if_ether.h"
|
||||
#include "netinet/if_tr.h"
|
||||
+#include <asm/types.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
/*
|
||||
44
meta-extras/packages/dhcp/files/init-relay
Normal file
44
meta-extras/packages/dhcp/files/init-relay
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $Id: dhcp3-relay,v 1.1 2004/04/16 15:41:08 ml Exp $
|
||||
#
|
||||
|
||||
# It is not safe to start if we don't have a default configuration...
|
||||
if [ ! -f /etc/default/dhcp-relay ]; then
|
||||
echo "/etc/default/dhcp-relay does not exist! - Aborting..."
|
||||
echo "create this file to fix the problem."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Read init script configuration (interfaces the daemon should listen on
|
||||
# and the DHCP server we should forward requests to.)
|
||||
. /etc/default/dhcp-relay
|
||||
|
||||
# Build command line for interfaces (will be passed to dhrelay below.)
|
||||
IFCMD=""
|
||||
if test "$INTERFACES" != ""; then
|
||||
for I in $INTERFACES; do
|
||||
IFCMD=${IFCMD}"-i "${I}" "
|
||||
done
|
||||
fi
|
||||
|
||||
DHCRELAYPID=/var/run/dhcrelay.pid
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start-stop-daemon -S -x /usr/sbin/dhcrelay -- -q $OPTIONS $IFCMD $SERVERS
|
||||
;;
|
||||
stop)
|
||||
start-stop-daemon -K -x /usr/sbin/dhcrelay
|
||||
;;
|
||||
restart | force-reload)
|
||||
$0 stop
|
||||
sleep 2
|
||||
$0 start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: /etc/init.d/dhcp-relay {start|stop|restart|force-reload}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit 0
|
||||
44
meta-extras/packages/dhcp/files/init-server
Normal file
44
meta-extras/packages/dhcp/files/init-server
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $Id: dhcp3-server.init.d,v 1.4 2003/07/13 19:12:41 mdz Exp $
|
||||
#
|
||||
|
||||
test -f /usr/sbin/dhcpd || exit 0
|
||||
|
||||
# It is not safe to start if we don't have a default configuration...
|
||||
if [ ! -f /etc/default/dhcp-server ]; then
|
||||
echo "/etc/default/dhcp-server does not exist! - Aborting..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Read init script configuration (so far only interfaces the daemon
|
||||
# should listen on.)
|
||||
. /etc/default/dhcp-server
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting DHCP server: "
|
||||
test -d /var/lib/dhcp/ || mkdir -p /var/lib/dhcp/
|
||||
test -f /var/lib/dhcp/dhcpd.leases || touch /var/lib/dhcp/dhcpd.leases
|
||||
start-stop-daemon -S -x /usr/sbin/dhcpd -- -q $INTERFACES
|
||||
echo "."
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping DHCP server: dhcpd3"
|
||||
start-stop-daemon -K -x /usr/sbin/dhcpd
|
||||
echo "."
|
||||
;;
|
||||
restart | force-reload)
|
||||
$0 stop
|
||||
sleep 2
|
||||
$0 start
|
||||
if [ "$?" != "0" ]; then
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Usage: /etc/init.d/dhcp-server {start|stop|restart|force-reload}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit 0
|
||||
20
meta-extras/packages/dhcp/files/noattrmode.patch
Normal file
20
meta-extras/packages/dhcp/files/noattrmode.patch
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
#
|
||||
# Patch managed by http://www.holgerschurig.de/patcher.html
|
||||
#
|
||||
|
||||
--- dhcp-3.0.1/includes/dhcpd.h~compile
|
||||
+++ dhcp-3.0.1/includes/dhcpd.h
|
||||
@@ -306,9 +306,9 @@
|
||||
# define EPHEMERAL_FLAGS (MS_NULL_TERMINATION | \
|
||||
UNICAST_BROADCAST_HACK)
|
||||
|
||||
- binding_state_t __attribute__ ((mode (__byte__))) binding_state;
|
||||
- binding_state_t __attribute__ ((mode (__byte__))) next_binding_state;
|
||||
- binding_state_t __attribute__ ((mode (__byte__))) desired_binding_state;
|
||||
+ binding_state_t binding_state;
|
||||
+ binding_state_t next_binding_state;
|
||||
+ binding_state_t desired_binding_state;
|
||||
|
||||
struct lease_state *state;
|
||||
|
||||
27
meta-extras/packages/dosfstools/dosfstools-native_2.10.bb
Normal file
27
meta-extras/packages/dosfstools/dosfstools-native_2.10.bb
Normal file
@@ -0,0 +1,27 @@
|
||||
# dosfstools-native OE build file
|
||||
# Copyright (C) 2004-2006, Advanced Micro Devices, Inc. All Rights Reserved
|
||||
# Released under the MIT license (see packages/COPYING)
|
||||
|
||||
require dosfstools_${PV}.bb
|
||||
FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/dosfstools-${PV}"
|
||||
|
||||
S="${WORKDIR}/dosfstools-${PV}"
|
||||
|
||||
PR="r4"
|
||||
|
||||
SRC_URI = "ftp://ftp.uni-erlangen.de/pub/Linux/LOCAL/dosfstools/dosfstools-${PV}.src.tar.gz \
|
||||
file://mkdosfs-bootcode.patch;patch=1 \
|
||||
file://mkdosfs-dir.patch;patch=1 \
|
||||
file://alignment_hack.patch;patch=1 \
|
||||
file://dosfstools-2.10-kernel-2.6.patch;patch=1 \
|
||||
file://msdos_fat12_undefined.patch;patch=1 \
|
||||
file://dosfstools-msdos_fs-types.patch;patch=1 \
|
||||
file://include-linux-types.patch;patch=1 \
|
||||
file://2.6.20-syscall.patch;patch=1"
|
||||
|
||||
inherit native
|
||||
|
||||
do_stage() {
|
||||
install -m 755 ${S}/mkdosfs/mkdosfs ${STAGING_BINDIR}/mkdosfs
|
||||
install -m 755 ${S}/dosfsck/dosfsck ${STAGING_BINDIR}/dosfsck
|
||||
}
|
||||
22
meta-extras/packages/dosfstools/dosfstools_2.10.bb
Normal file
22
meta-extras/packages/dosfstools/dosfstools_2.10.bb
Normal file
@@ -0,0 +1,22 @@
|
||||
# dosfstools OE build file
|
||||
# Copyright (C) 2004-2006, Advanced Micro Devices, Inc. All Rights Reserved
|
||||
# Released under the MIT license (see packages/COPYING)
|
||||
|
||||
DESCRIPTION = "DOS FAT Filesystem Utilities"
|
||||
|
||||
SECTION = "base"
|
||||
PRIORITY = "optional"
|
||||
LICENSE = "GPL"
|
||||
|
||||
PR = "r2"
|
||||
|
||||
SRC_URI = "ftp://ftp.uni-erlangen.de/pub/Linux/LOCAL/dosfstools/dosfstools-${PV}.src.tar.gz \
|
||||
file://alignment_hack.patch;patch=1 \
|
||||
file://dosfstools-2.10-kernel-2.6.patch;patch=1 \
|
||||
file://msdos_fat12_undefined.patch;patch=1 \
|
||||
file://include-linux-types.patch;patch=1"
|
||||
|
||||
do_install () {
|
||||
oe_runmake "PREFIX=${D}" "SBINDIR=${D}${sbindir}" \
|
||||
"MANDIR=${D}${mandir}/man8" install
|
||||
}
|
||||
21
meta-extras/packages/dosfstools/dosfstools_2.11.bb
Normal file
21
meta-extras/packages/dosfstools/dosfstools_2.11.bb
Normal file
@@ -0,0 +1,21 @@
|
||||
# dosfstools OE build file
|
||||
# Copyright (C) 2004-2006, Advanced Micro Devices, Inc. All Rights Reserved
|
||||
# Released under the MIT license (see packages/COPYING)
|
||||
|
||||
DESCRIPTION = "DOS FAT Filesystem Utilities"
|
||||
|
||||
SECTION = "base"
|
||||
PRIORITY = "optional"
|
||||
LICENSE = "GPL"
|
||||
|
||||
PR = "r0"
|
||||
|
||||
SRC_URI = "ftp://ftp.uni-erlangen.de/pub/Linux/LOCAL/dosfstools/dosfstools-${PV}.src.tar.gz \
|
||||
file://alignment_hack.patch;patch=1 \
|
||||
file://msdos_fat12_undefined.patch;patch=1 \
|
||||
file://include-linux-types.patch;patch=1"
|
||||
|
||||
do_install () {
|
||||
oe_runmake "PREFIX=${D}" "SBINDIR=${D}${sbindir}" \
|
||||
"MANDIR=${D}${mandir}/man8" install
|
||||
}
|
||||
65
meta-extras/packages/dosfstools/files/2.6.20-syscall.patch
Normal file
65
meta-extras/packages/dosfstools/files/2.6.20-syscall.patch
Normal file
@@ -0,0 +1,65 @@
|
||||
Index: dosfstools-2.10/dosfsck/io.c
|
||||
===================================================================
|
||||
--- dosfstools-2.10.orig/dosfsck/io.c 2007-06-07 16:15:52.000000000 +0200
|
||||
+++ dosfstools-2.10/dosfsck/io.c 2007-06-07 16:16:06.000000000 +0200
|
||||
@@ -42,28 +42,11 @@
|
||||
/* Use the _llseek system call directly, because there (once?) was a bug in
|
||||
* the glibc implementation of it. */
|
||||
#include <linux/unistd.h>
|
||||
-#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__
|
||||
/* On alpha, the syscall is simply lseek, because it's a 64 bit system. */
|
||||
static loff_t llseek( int fd, loff_t offset, int whence )
|
||||
{
|
||||
return lseek(fd, offset, whence);
|
||||
}
|
||||
-#else
|
||||
-# ifndef __NR__llseek
|
||||
-# error _llseek system call not present
|
||||
-# endif
|
||||
-static _syscall5( int, _llseek, uint, fd, ulong, hi, ulong, lo,
|
||||
- loff_t *, res, uint, wh );
|
||||
-
|
||||
-static loff_t llseek( int fd, loff_t offset, int whence )
|
||||
-{
|
||||
- loff_t actual;
|
||||
-
|
||||
- if (_llseek(fd, offset>>32, offset&0xffffffff, &actual, whence) != 0)
|
||||
- return (loff_t)-1;
|
||||
- return actual;
|
||||
-}
|
||||
-#endif
|
||||
|
||||
|
||||
void fs_open(char *path,int rw)
|
||||
Index: dosfstools-2.10/mkdosfs/mkdosfs.c
|
||||
===================================================================
|
||||
--- dosfstools-2.10.orig/mkdosfs/mkdosfs.c 2007-06-07 16:15:11.000000000 +0200
|
||||
+++ dosfstools-2.10/mkdosfs/mkdosfs.c 2007-06-07 16:15:30.000000000 +0200
|
||||
@@ -116,27 +116,11 @@
|
||||
/* Use the _llseek system call directly, because there (once?) was a bug in
|
||||
* the glibc implementation of it. */
|
||||
#include <linux/unistd.h>
|
||||
-#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__
|
||||
/* On alpha, the syscall is simply lseek, because it's a 64 bit system. */
|
||||
static loff_t llseek( int fd, loff_t offset, int whence )
|
||||
{
|
||||
return lseek(fd, offset, whence);
|
||||
}
|
||||
-#else
|
||||
-# ifndef __NR__llseek
|
||||
-# error _llseek system call not present
|
||||
-# endif
|
||||
-static _syscall5( int, _llseek, uint, fd, ulong, hi, ulong, lo,
|
||||
- loff_t *, res, uint, wh );
|
||||
-static loff_t llseek( int fd, loff_t offset, int whence )
|
||||
-{
|
||||
- loff_t actual;
|
||||
-
|
||||
- if (_llseek(fd, offset>>32, offset&0xffffffff, &actual, whence) != 0)
|
||||
- return (loff_t)-1;
|
||||
- return actual;
|
||||
-}
|
||||
-#endif
|
||||
|
||||
#define ROUND_UP(value, divisor) (value + (divisor - (value % divisor))) / divisor
|
||||
|
||||
34
meta-extras/packages/dosfstools/files/alignment_hack.patch
Normal file
34
meta-extras/packages/dosfstools/files/alignment_hack.patch
Normal file
@@ -0,0 +1,34 @@
|
||||
The problem is that unsigned char[2] is
|
||||
guranteed to be 8Bit aligned on arm
|
||||
but unsigned short is/needs to be 16bit aligned
|
||||
the union { unsigned short; unsigned char[2] } trick
|
||||
didn't work so no we use the alpha hack.
|
||||
|
||||
memcpy into an 16bit aligned
|
||||
|
||||
-zecke
|
||||
|
||||
|
||||
--- dosfstools/dosfsck/boot.c.orig 2003-05-15 19:32:23.000000000 +0200
|
||||
+++ dosfstools/dosfsck/boot.c 2003-06-13 17:44:25.000000000 +0200
|
||||
@@ -36,17 +36,15 @@
|
||||
{ 0xff, "5.25\" 320k floppy 2s/40tr/8sec" },
|
||||
};
|
||||
|
||||
-#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__
|
||||
+
|
||||
/* Unaligned fields must first be copied byte-wise */
|
||||
#define GET_UNALIGNED_W(f) \
|
||||
({ \
|
||||
unsigned short __v; \
|
||||
memcpy( &__v, &f, sizeof(__v) ); \
|
||||
- CF_LE_W( *(unsigned short *)&f ); \
|
||||
+ CF_LE_W( *(unsigned short *)&__v ); \
|
||||
})
|
||||
-#else
|
||||
-#define GET_UNALIGNED_W(f) CF_LE_W( *(unsigned short *)&f )
|
||||
-#endif
|
||||
+
|
||||
|
||||
|
||||
static char *get_media_descr( unsigned char media )
|
||||
@@ -0,0 +1,74 @@
|
||||
Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
|
||||
Date: 2004-02-09
|
||||
Initial Package Version: 2.6
|
||||
Origin: Jim Gifford
|
||||
Upstream Status: Accepted
|
||||
Description: Fixes Compile Issues with the 2.6 Kernel
|
||||
|
||||
--- dosfstools-2.10/dosfsck/common.h.orig 2004-02-09 18:37:59.056737458 +0000
|
||||
+++ dosfstools-2.10/dosfsck/common.h 2004-02-09 18:38:18.333392952 +0000
|
||||
@@ -2,6 +2,13 @@
|
||||
|
||||
/* Written 1993 by Werner Almesberger */
|
||||
|
||||
+#include <linux/version.h>
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
|
||||
+ #define __KERNEL__
|
||||
+ #include <asm/types.h>
|
||||
+ #undef __KERNEL__
|
||||
+ #define MSDOS_FAT12 4084 /* maximum number of clusters in a 12 bit FAT */
|
||||
+#endif
|
||||
|
||||
#ifndef _COMMON_H
|
||||
#define _COMMON_H
|
||||
--- dosfstools-2.10/dosfsck/file.c.orig 2004-02-09 18:40:52.016728845 +0000
|
||||
+++ dosfstools-2.10/dosfsck/file.c 2004-02-09 18:40:03.665117865 +0000
|
||||
@@ -15,6 +15,14 @@
|
||||
#define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
|
||||
#define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h>*/
|
||||
#define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
|
||||
+
|
||||
+#include <linux/version.h>
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
|
||||
+ #define __KERNEL__
|
||||
+ #include <asm/types.h>
|
||||
+ #undef __KERNEL__
|
||||
+#endif
|
||||
+
|
||||
#include <linux/msdos_fs.h>
|
||||
|
||||
#include "common.h"
|
||||
--- dosfstools-2.10/dosfsck/dosfsck.h.orig 2004-02-09 18:57:11.022870974 +0000
|
||||
+++ dosfstools-2.10/dosfsck/dosfsck.h 2004-02-09 18:56:20.628614393 +0000
|
||||
@@ -13,6 +13,15 @@
|
||||
#define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
|
||||
#define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h>*/
|
||||
#define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
|
||||
+
|
||||
+#include <linux/version.h>
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
|
||||
+ #define __KERNEL__
|
||||
+ #include <asm/types.h>
|
||||
+ #include <asm/byteorder.h>
|
||||
+ #undef __KERNEL__
|
||||
+#endif
|
||||
+
|
||||
#include <linux/msdos_fs.h>
|
||||
|
||||
/* 2.1 kernels use le16_to_cpu() type functions for CF_LE_W & Co., but don't
|
||||
--- dosfstools-2.10/mkdosfs/mkdosfs.c.orig 2004-02-09 18:31:41.997157413 +0000
|
||||
+++ dosfstools-2.10/mkdosfs/mkdosfs.c 2004-02-09 18:34:07.311945252 +0000
|
||||
@@ -66,6 +66,13 @@
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
+#include <linux/version.h>
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
|
||||
+ #define __KERNEL__
|
||||
+ #include <asm/types.h>
|
||||
+ #undef __KERNEL__
|
||||
+#endif
|
||||
+
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
@@ -0,0 +1,30 @@
|
||||
--- dosfstools-2.10/dosfsck/dosfsck.h.org 2006-02-21 08:36:14.000000000 -0700
|
||||
+++ dosfstools-2.10/dosfsck/dosfsck.h 2006-02-21 08:40:12.000000000 -0700
|
||||
@@ -22,6 +22,14 @@
|
||||
#undef __KERNEL__
|
||||
#endif
|
||||
|
||||
+#ifndef __s8
|
||||
+#include <asm/types.h>
|
||||
+#endif
|
||||
+
|
||||
+#ifndef __ASM_STUB_BYTEORDER_H__
|
||||
+#include <asm/byteorder.h>
|
||||
+#endif
|
||||
+
|
||||
#include <linux/msdos_fs.h>
|
||||
|
||||
/* 2.1 kernels use le16_to_cpu() type functions for CF_LE_W & Co., but don't
|
||||
--- dosfstools-2.10/dosfsck/file.c.org 2006-02-21 08:37:36.000000000 -0700
|
||||
+++ dosfstools-2.10/dosfsck/file.c 2006-02-21 08:37:47.000000000 -0700
|
||||
@@ -23,6 +23,10 @@
|
||||
#undef __KERNEL__
|
||||
#endif
|
||||
|
||||
+#ifndef __s8
|
||||
+#include <asm/types.h>
|
||||
+#endif
|
||||
+
|
||||
#include <linux/msdos_fs.h>
|
||||
|
||||
#include "common.h"
|
||||
@@ -0,0 +1,17 @@
|
||||
mkdsofs is using types of the style __u8, which it gets with some
|
||||
versions of libc headers via linux/hdreg.h including asm/types.h.
|
||||
Newer version of fedora (at least) have a hdreg.h whichdoes not
|
||||
include asm/types.h. To work around this patch mkdosfs.c to explicity
|
||||
include linux/types.h which will in turn pull in asm/types.h which
|
||||
defines these variables.
|
||||
|
||||
--- dosfstools-2.10/mkdosfs/mkdosfs.c~ 2006-07-12 18:46:21.000000000 +1000
|
||||
+++ dosfstools-2.10/mkdosfs/mkdosfs.c 2006-07-12 18:46:21.000000000 +1000
|
||||
@@ -60,6 +60,7 @@
|
||||
#include "../version.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
+#include <linux/types.h>
|
||||
#include <linux/hdreg.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/fd.h>
|
||||
240
meta-extras/packages/dosfstools/files/mkdosfs-bootcode.patch
Normal file
240
meta-extras/packages/dosfstools/files/mkdosfs-bootcode.patch
Normal file
@@ -0,0 +1,240 @@
|
||||
diff -urN dosfstools-2.10.orig/mkdosfs/ChangeLog dosfstools-2.10/mkdosfs/ChangeLog
|
||||
--- dosfstools-2.10.orig/mkdosfs/ChangeLog 1997-06-18 03:09:38.000000000 -0700
|
||||
+++ dosfstools-2.10/mkdosfs/ChangeLog 2004-08-02 20:57:57.734939816 -0700
|
||||
@@ -1,3 +1,14 @@
|
||||
+19th June 2003 Sam Bingner (sam@bingner.com)
|
||||
+
|
||||
+ Added option to read in bootcode from a file so that if you have
|
||||
+ for example Windows 2000 boot code, you can have it write that
|
||||
+ as the bootcode. This is a dump of the behinning of a partition
|
||||
+ generally 512 bytes, but can be up to reserved sectors*512 bytes.
|
||||
+ Also writes 0x80 as the BIOS drive number if we are formatting a
|
||||
+ hard drive, and sets the number of hidden sectors to be the
|
||||
+ number of sectors in one track. These were required so that DOS
|
||||
+ could boot using the bootcode.
|
||||
+
|
||||
28th January 1995 H. Peter Anvin (hpa@yggdrasil.com)
|
||||
|
||||
Better algorithm to select cluster sizes on large filesystems.
|
||||
diff -urN dosfstools-2.10.orig/mkdosfs/mkdosfs.8 dosfstools-2.10/mkdosfs/mkdosfs.8
|
||||
--- dosfstools-2.10.orig/mkdosfs/mkdosfs.8 2003-05-15 11:28:28.000000000 -0700
|
||||
+++ dosfstools-2.10/mkdosfs/mkdosfs.8 2004-08-02 20:57:57.735939664 -0700
|
||||
@@ -40,6 +40,10 @@
|
||||
.I message-file
|
||||
]
|
||||
[
|
||||
+.B \-B
|
||||
+.I bootcode-file
|
||||
+]
|
||||
+[
|
||||
.B \-n
|
||||
.I volume-name
|
||||
]
|
||||
@@ -155,6 +159,18 @@
|
||||
carriage return-line feed combinations, and tabs have been expanded.
|
||||
If the filename is a hyphen (-), the text is taken from standard input.
|
||||
.TP
|
||||
+.BI \-B " bootcode-file"
|
||||
+Uses boot machine code from file "file". On any thing other than FAT32,
|
||||
+this only writes the first 3 bytes, and 480 bytes from offset 3Eh. On
|
||||
+FAT32, this writes the first 3 bytes, 420 bytes from offset 5Ah to both
|
||||
+primary and backup boot sectors. Also writes all other reserved sectors
|
||||
+excluding the sectors following boot sectors (usually sector 2 and 7).
|
||||
+Does not require that the input file be as large as reserved_sectors*512.
|
||||
+To make a FAT32 partition bootable, you will need at least the first
|
||||
+13 sectors (6656 bytes). You can also specify a partition as the argument
|
||||
+to clone the boot code from that partition.
|
||||
+i.e mkdosfs -B /dev/sda1 /dev/sda1
|
||||
+.TP
|
||||
.BI \-n " volume-name"
|
||||
Sets the volume name (label) of the filesystem. The volume name can
|
||||
be up to 11 characters long. The default is no label.
|
||||
@@ -188,8 +204,9 @@
|
||||
simply will not support it ;)
|
||||
.SH AUTHOR
|
||||
Dave Hudson - <dave@humbug.demon.co.uk>; modified by Peter Anvin
|
||||
-<hpa@yggdrasil.com>. Fixes and additions by Roman Hodek
|
||||
-<Roman.Hodek@informatik.uni-erlangen.de> for Debian/GNU Linux.
|
||||
+<hpa@yggdrasil.com> and Sam Bingner <sam@bingner.com>. Fixes and
|
||||
+additions by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
|
||||
+for Debian/GNU Linux.
|
||||
.SH ACKNOWLEDGEMENTS
|
||||
.B mkdosfs
|
||||
is based on code from
|
||||
diff -urN dosfstools-2.10.orig/mkdosfs/mkdosfs.c dosfstools-2.10/mkdosfs/mkdosfs.c
|
||||
--- dosfstools-2.10.orig/mkdosfs/mkdosfs.c 2003-06-14 13:07:08.000000000 -0700
|
||||
+++ dosfstools-2.10/mkdosfs/mkdosfs.c 2004-08-02 20:57:57.736939512 -0700
|
||||
@@ -24,6 +24,12 @@
|
||||
- New options -A, -S, -C
|
||||
- Support for filesystems > 2GB
|
||||
- FAT32 support
|
||||
+
|
||||
+ Fixes/additions June 2003 by Sam Bingner
|
||||
+ <sam@bingner.com>:
|
||||
+ - Add -B option to read in bootcode from a file
|
||||
+ - Write BIOS drive number so that FS can properly boot
|
||||
+ - Set number of hidden sectors before boot code to be one track
|
||||
|
||||
Copying: Copyright 1993, 1994 David Hudson (dave@humbug.demon.co.uk)
|
||||
|
||||
@@ -167,6 +173,8 @@
|
||||
#define FAT_BAD 0x0ffffff7
|
||||
|
||||
#define MSDOS_EXT_SIGN 0x29 /* extended boot sector signature */
|
||||
+#define HD_DRIVE_NUMBER 0x80 /* Boot off first hard drive */
|
||||
+#define FD_DRIVE_NUMBER 0x00 /* Boot off first floppy drive */
|
||||
#define MSDOS_FAT12_SIGN "FAT12 " /* FAT12 filesystem signature */
|
||||
#define MSDOS_FAT16_SIGN "FAT16 " /* FAT16 filesystem signature */
|
||||
#define MSDOS_FAT32_SIGN "FAT32 " /* FAT32 filesystem signature */
|
||||
@@ -188,6 +196,8 @@
|
||||
#define BOOTCODE_SIZE 448
|
||||
#define BOOTCODE_FAT32_SIZE 420
|
||||
|
||||
+#define MAX_RESERVED 0xFFFF
|
||||
+
|
||||
/* __attribute__ ((packed)) is used on all structures to make gcc ignore any
|
||||
* alignments */
|
||||
|
||||
@@ -215,7 +225,7 @@
|
||||
__u16 fat_length; /* sectors/FAT */
|
||||
__u16 secs_track; /* sectors per track */
|
||||
__u16 heads; /* number of heads */
|
||||
- __u32 hidden; /* hidden sectors (unused) */
|
||||
+ __u32 hidden; /* hidden sectors (one track) */
|
||||
__u32 total_sect; /* number of sectors (if sectors == 0) */
|
||||
union {
|
||||
struct {
|
||||
@@ -298,6 +308,8 @@
|
||||
|
||||
/* Global variables - the root of all evil :-) - see these and weep! */
|
||||
|
||||
+static char *template_boot_code; /* Variable to store a full template boot sector in */
|
||||
+static int use_template = 0;
|
||||
static char *program_name = "mkdosfs"; /* Name of the program */
|
||||
static char *device_name = NULL; /* Name of the device on which to create the filesystem */
|
||||
static int atari_format = 0; /* Use Atari variation of MS-DOS FS format */
|
||||
@@ -842,6 +854,12 @@
|
||||
vi->volume_id[2] = (unsigned char) ((volume_id & 0x00ff0000) >> 16);
|
||||
vi->volume_id[3] = (unsigned char) (volume_id >> 24);
|
||||
}
|
||||
+ if (bs.media == 0xf8) {
|
||||
+ vi->drive_number = HD_DRIVE_NUMBER; /* Set bios drive number to 80h */
|
||||
+ }
|
||||
+ else {
|
||||
+ vi->drive_number = FD_DRIVE_NUMBER; /* Set bios drive number to 00h */
|
||||
+ }
|
||||
|
||||
if (!atari_format) {
|
||||
memcpy(vi->volume_label, volume_name, 11);
|
||||
@@ -886,7 +904,7 @@
|
||||
printf( "Using %d reserved sectors\n", reserved_sectors );
|
||||
bs.fats = (char) nr_fats;
|
||||
if (!atari_format || size_fat == 32)
|
||||
- bs.hidden = CT_LE_L(0);
|
||||
+ bs.hidden = bs.secs_track;
|
||||
else
|
||||
/* In Atari format, hidden is a 16 bit field */
|
||||
memset( &bs.hidden, 0, 2 );
|
||||
@@ -1358,6 +1376,32 @@
|
||||
* dir area on FAT12/16, and the first cluster on FAT32. */
|
||||
writebuf( (char *) root_dir, size_root_dir, "root directory" );
|
||||
|
||||
+ if (use_template == 1) {
|
||||
+ /* dupe template into reserved sectors */
|
||||
+ seekto( 0, "Start of partition" );
|
||||
+ if (size_fat == 32) {
|
||||
+ writebuf( template_boot_code, 3, "backup jmpBoot" );
|
||||
+ seekto( 0x5a, "sector 1 boot area" );
|
||||
+ writebuf( template_boot_code+0x5a, 420, "sector 1 boot area" );
|
||||
+ seekto( 512*2, "third sector" );
|
||||
+ if (backup_boot != 0) {
|
||||
+ writebuf( template_boot_code+512*2, backup_boot*sector_size - 512*2, "data to backup boot" );
|
||||
+ seekto( backup_boot*sector_size, "backup boot sector" );
|
||||
+ writebuf( template_boot_code, 3, "backup jmpBoot" );
|
||||
+ seekto( backup_boot*sector_size+0x5a, "backup boot sector boot area" );
|
||||
+ writebuf( template_boot_code+0x5a, 420, "backup boot sector boot area" );
|
||||
+ seekto( (backup_boot+2)*sector_size, "sector following backup code" );
|
||||
+ writebuf( template_boot_code+(backup_boot+2)*sector_size, (reserved_sectors-backup_boot-2)*512, "remaining data" );
|
||||
+ } else {
|
||||
+ writebuf( template_boot_code+512*2, (reserved_sectors-2)*512, "remaining data" );
|
||||
+ }
|
||||
+ } else {
|
||||
+ writebuf( template_boot_code, 3, "jmpBoot" );
|
||||
+ seekto( 0x3e, "sector 1 boot area" );
|
||||
+ writebuf( template_boot_code+0x3e, 448, "boot code" );
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (info_sector) free( info_sector );
|
||||
free (root_dir); /* Free up the root directory space from setup_tables */
|
||||
free (fat); /* Free up the fat table space reserved during setup_tables */
|
||||
@@ -1371,7 +1415,7 @@
|
||||
{
|
||||
fatal_error("\
|
||||
Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] [-b backup-boot-sector]\n\
|
||||
- [-m boot-msg-file] [-n volume-name] [-i volume-id]\n\
|
||||
+ [-m boot-msg-file] [-n volume-name] [-i volume-id] [-B bootcode]\n\
|
||||
[-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs]\n\
|
||||
[-F fat-size] [-r root-dir-entries] [-R reserved-sectors]\n\
|
||||
/dev/name [blocks]\n");
|
||||
@@ -1433,7 +1477,7 @@
|
||||
printf ("%s " VERSION " (" VERSION_DATE ")\n",
|
||||
program_name);
|
||||
|
||||
- while ((c = getopt (argc, argv, "AcCf:F:Ii:l:m:n:r:R:s:S:v")) != EOF)
|
||||
+ while ((c = getopt (argc, argv, "AcCf:F:Ii:l:m:n:r:R:s:S:v:B:b")) != EOF)
|
||||
/* Scan the command line for options */
|
||||
switch (c)
|
||||
{
|
||||
@@ -1494,6 +1538,51 @@
|
||||
listfile = optarg;
|
||||
break;
|
||||
|
||||
+ case 'B': /* B : read in bootcode */
|
||||
+ if ( strcmp(optarg, "-") )
|
||||
+ {
|
||||
+ msgfile = fopen(optarg, "r");
|
||||
+ if ( !msgfile )
|
||||
+ perror(optarg);
|
||||
+ }
|
||||
+ else
|
||||
+ msgfile = stdin;
|
||||
+
|
||||
+ if ( msgfile )
|
||||
+ {
|
||||
+ if (!(template_boot_code = malloc( MAX_RESERVED )))
|
||||
+ die( "Out of memory" );
|
||||
+ /* The template boot sector including reserved must not be > 65535 */
|
||||
+ use_template = 1;
|
||||
+ i = 0;
|
||||
+ do
|
||||
+ {
|
||||
+ ch = getc(msgfile);
|
||||
+ switch (ch)
|
||||
+ {
|
||||
+ case EOF:
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ template_boot_code[i++] = ch; /* Store character */
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ while ( ch != EOF && i < MAX_RESERVED );
|
||||
+ ch = getc(msgfile); /* find out if we're at EOF */
|
||||
+
|
||||
+ /* Fill up with zeros */
|
||||
+ while( i < MAX_RESERVED )
|
||||
+ template_boot_code[i++] = '\0';
|
||||
+
|
||||
+ if ( ch != EOF )
|
||||
+ printf ("Warning: template too long; truncated after %d bytes\n", i);
|
||||
+
|
||||
+ if ( msgfile != stdin )
|
||||
+ fclose(msgfile);
|
||||
+ }
|
||||
+ break;
|
||||
+
|
||||
case 'm': /* m : Set boot message */
|
||||
if ( strcmp(optarg, "-") )
|
||||
{
|
||||
634
meta-extras/packages/dosfstools/files/mkdosfs-dir.patch
Normal file
634
meta-extras/packages/dosfstools/files/mkdosfs-dir.patch
Normal file
@@ -0,0 +1,634 @@
|
||||
diff -urN dosfstools-2.10.orig/mkdosfs/mkdosfs.c dosfstools-2.10/mkdosfs/mkdosfs.c
|
||||
--- dosfstools-2.10.orig/mkdosfs/mkdosfs.c 2004-08-02 20:48:45.000000000 -0700
|
||||
+++ dosfstools-2.10/mkdosfs/mkdosfs.c 2004-08-02 20:49:44.296953792 -0700
|
||||
@@ -18,6 +18,10 @@
|
||||
as a rule), and not the block. For example the boot block does not
|
||||
occupy a full cluster.
|
||||
|
||||
+ June 2004 - Jordan Crouse (info.linux@amd.com)
|
||||
+ Added -d <directory> support to populate the image
|
||||
+ Copyright (C) 2004, Advanced Micro Devices, All Rights Reserved
|
||||
+
|
||||
Fixes/additions May 1998 by Roman Hodek
|
||||
<Roman.Hodek@informatik.uni-erlangen.de>:
|
||||
- Atari format support
|
||||
@@ -71,6 +75,8 @@
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
+#include <libgen.h>
|
||||
+#include <dirent.h>
|
||||
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
|
||||
@@ -124,6 +130,8 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
+#define ROUND_UP(value, divisor) (value + (divisor - (value % divisor))) / divisor
|
||||
+
|
||||
/* Constant definitions */
|
||||
|
||||
#define TRUE 1 /* Boolean constants */
|
||||
@@ -163,7 +171,6 @@
|
||||
#define ATTR_VOLUME 8 /* volume label */
|
||||
#define ATTR_DIR 16 /* directory */
|
||||
#define ATTR_ARCH 32 /* archived */
|
||||
-
|
||||
#define ATTR_NONE 0 /* no attribute bits */
|
||||
#define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
|
||||
/* attribute bits that are copied "as is" */
|
||||
@@ -258,6 +265,19 @@
|
||||
__u32 reserved2[4];
|
||||
};
|
||||
|
||||
+/* This stores up to 13 chars of the name */
|
||||
+
|
||||
+struct msdos_dir_slot {
|
||||
+ __u8 id; /* sequence number for slot */
|
||||
+ __u8 name0_4[10]; /* first 5 characters in name */
|
||||
+ __u8 attr; /* attribute byte */
|
||||
+ __u8 reserved; /* always 0 */
|
||||
+ __u8 alias_checksum; /* checksum for 8.3 alias */
|
||||
+ __u8 name5_10[12]; /* 6 more characters in name */
|
||||
+ __u16 start; /* starting cluster number, 0 in long slots */
|
||||
+ __u8 name11_12[4]; /* last 2 characters in name */
|
||||
+};
|
||||
+
|
||||
struct msdos_dir_entry
|
||||
{
|
||||
char name[8], ext[3]; /* name and extension */
|
||||
@@ -306,6 +326,15 @@
|
||||
|
||||
#define MESSAGE_OFFSET 29 /* Offset of message in above code */
|
||||
|
||||
+/* Special structure to keep track of directories as we add them for the -d option */
|
||||
+
|
||||
+struct dir_entry {
|
||||
+ int root; /* Specifies if this is the root dir or not */
|
||||
+ int count; /* Number of items in the table */
|
||||
+ int entries; /* Number of entries in the table */
|
||||
+ struct msdos_dir_entry *table; /* Pointer to the entry table */
|
||||
+};
|
||||
+
|
||||
/* Global variables - the root of all evil :-) - see these and weep! */
|
||||
|
||||
static char *template_boot_code; /* Variable to store a full template boot sector in */
|
||||
@@ -339,6 +368,9 @@
|
||||
static int size_root_dir; /* Size of the root directory in bytes */
|
||||
static int sectors_per_cluster = 0; /* Number of sectors per disk cluster */
|
||||
static int root_dir_entries = 0; /* Number of root directory entries */
|
||||
+static int root_dir_num_entries = 0;
|
||||
+static int last_cluster_written = 0;
|
||||
+
|
||||
static char *blank_sector; /* Blank sector - all zeros */
|
||||
|
||||
|
||||
@@ -411,7 +443,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
-
|
||||
/* Mark a specified sector as having a particular value in it's FAT entry */
|
||||
|
||||
static void
|
||||
@@ -1262,6 +1293,9 @@
|
||||
die ("unable to allocate space for root directory in memory");
|
||||
}
|
||||
|
||||
+
|
||||
+ last_cluster_written = 2;
|
||||
+
|
||||
memset(root_dir, 0, size_root_dir);
|
||||
if ( memcmp(volume_name, " ", 11) )
|
||||
{
|
||||
@@ -1310,11 +1344,11 @@
|
||||
}
|
||||
|
||||
if (!(blank_sector = malloc( sector_size )))
|
||||
- die( "Out of memory" );
|
||||
+ die( "Out of memory" );
|
||||
+
|
||||
memset(blank_sector, 0, sector_size);
|
||||
}
|
||||
-
|
||||
-
|
||||
+
|
||||
/* Write the new filesystem's data tables to wherever they're going to end up! */
|
||||
|
||||
#define error(str) \
|
||||
@@ -1336,7 +1370,7 @@
|
||||
do { \
|
||||
int __size = (size); \
|
||||
if (write (dev, buf, __size) != __size) \
|
||||
- error ("failed whilst writing " errstr); \
|
||||
+ error ("failed whilst writing " errstr); \
|
||||
} while(0)
|
||||
|
||||
|
||||
@@ -1407,6 +1441,452 @@
|
||||
free (fat); /* Free up the fat table space reserved during setup_tables */
|
||||
}
|
||||
|
||||
+/* Add a file to the specified directory entry, and also write it into the image */
|
||||
+
|
||||
+static void copy_filename(char *filename, char *base, char *ext) {
|
||||
+
|
||||
+ char *ch = filename;
|
||||
+ int i, len;
|
||||
+
|
||||
+ memset(base, 0x20, 8);
|
||||
+ memset(ext, 0x20, 3);
|
||||
+
|
||||
+ for(len = 0 ; *ch && *ch != '.'; ch++) {
|
||||
+ base[len++] = toupper(*ch);
|
||||
+ if (len == 8) break;
|
||||
+ }
|
||||
+
|
||||
+ for ( ; *ch && *ch != '.'; ch++);
|
||||
+ if (*ch) ch++;
|
||||
+
|
||||
+ for(len = 0 ; *ch; ch++) {
|
||||
+ ext[len++] = toupper(*ch);
|
||||
+ if (len == 3) break;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/* Check for an .attrib.<filename> file, and read the attributes therein */
|
||||
+
|
||||
+/* We are going to be pretty pedantic about this. The file needs 3
|
||||
+ bytes at the beginning, the attributes are listed in this order:
|
||||
+
|
||||
+ (H)idden|(S)ystem|(A)rchived
|
||||
+
|
||||
+ A capital HSA means to enable it, anything else will disable it
|
||||
+ (I recommend a '-') The unix user attributes will still be used
|
||||
+ for write access.
|
||||
+
|
||||
+ For example, to enable system file access for ldlinux.sys, write
|
||||
+ the following to .attrib.ldlinux.sys: -S-
|
||||
+*/
|
||||
+
|
||||
+unsigned char check_attrib_file(char *dir, char *filename) {
|
||||
+
|
||||
+ char attrib[4] = { '-', '-', '-' };
|
||||
+ unsigned char *buffer = 0;
|
||||
+ int ret = ATTR_NONE;
|
||||
+ int fd = -1;
|
||||
+
|
||||
+ buffer = (char *) calloc(1, strlen(dir) + strlen(filename) + 10);
|
||||
+ if (!buffer) return ATTR_NONE;
|
||||
+
|
||||
+ sprintf(buffer, "%s/.attrib.%s", dir, filename);
|
||||
+
|
||||
+ if (access(buffer, R_OK))
|
||||
+ goto exit_attrib;
|
||||
+
|
||||
+ if ((fd = open(buffer, O_RDONLY, 0)) < 0)
|
||||
+ goto exit_attrib;
|
||||
+
|
||||
+ if (read(fd, attrib, 3) < 0)
|
||||
+ goto exit_attrib;
|
||||
+
|
||||
+ if (attrib[0] == 'H') ret |= ATTR_HIDDEN;
|
||||
+ if (attrib[1] == 'S') ret |= ATTR_SYS;
|
||||
+ if (attrib[2] == 'A') ret |= ATTR_ARCH;
|
||||
+
|
||||
+ printf("%s: Setting atrribute %x\n", filename, ret);
|
||||
+
|
||||
+ exit_attrib:
|
||||
+ if (fd >= 0) close(fd);
|
||||
+ if (buffer) free(buffer);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void copy_name(char *buffer, int size, char **pointer) {
|
||||
+ int i;
|
||||
+
|
||||
+ for(i = 0; i < size; i += 2) {
|
||||
+ if (*pointer) {
|
||||
+ buffer[i] = **pointer;
|
||||
+ buffer[i + 1] = 0x00;
|
||||
+ *pointer = **pointer ? *pointer + 1 : 0;
|
||||
+ }
|
||||
+ else {
|
||||
+ buffer[i] = 0xFF;
|
||||
+ buffer[i + 1] = 0xFF;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int add_file(char *filename, struct dir_entry *dir, unsigned char attr)
|
||||
+{
|
||||
+ struct stat stat;
|
||||
+ struct msdos_dir_entry *entry;
|
||||
+ int infile = 0;
|
||||
+ int sectors, clusters;
|
||||
+ struct tm *ctime;
|
||||
+ int c, s;
|
||||
+ int ptr;
|
||||
+ char *buffer, *base;
|
||||
+ int start;
|
||||
+ int usedsec, totalsec;
|
||||
+
|
||||
+ char name83[8], ext83[3];
|
||||
+
|
||||
+ struct msdos_dir_slot *slot;
|
||||
+ int i;
|
||||
+ char *p;
|
||||
+
|
||||
+ /* The root directory is static, everything else grows as needed */
|
||||
+
|
||||
+ if (dir->root) {
|
||||
+ if (dir->count == dir->entries) {
|
||||
+ printf("Error - too many directory entries\n");
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ if (dir->count == dir->entries) {
|
||||
+ if (!dir->table)
|
||||
+ dir->table =
|
||||
+ (struct msdos_dir_entry *) malloc(sizeof(struct msdos_dir_entry));
|
||||
+ else {
|
||||
+ dir->table =
|
||||
+ (struct msdos_dir_entry *) realloc(dir->table, (dir->entries + 1) *
|
||||
+ sizeof(struct msdos_dir_entry));
|
||||
+
|
||||
+ memset(&dir->table[dir->entries], 0, sizeof(struct msdos_dir_entry));
|
||||
+ }
|
||||
+
|
||||
+ dir->entries++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ infile = open(filename, O_RDONLY, 0);
|
||||
+ if (!infile) return;
|
||||
+
|
||||
+ if (fstat(infile, &stat))
|
||||
+ goto exit_add;
|
||||
+
|
||||
+ if (S_ISCHR(stat.st_mode) ||S_ISBLK(stat.st_mode) ||
|
||||
+ S_ISFIFO(stat.st_mode) || S_ISLNK(stat.st_mode)) {
|
||||
+ printf("Error - cannot create a special file in a FATFS\n");
|
||||
+ goto exit_add;
|
||||
+ }
|
||||
+
|
||||
+ /* FIXME: This isn't very pretty */
|
||||
+
|
||||
+ usedsec = start_data_sector + (size_root_dir / sector_size) +
|
||||
+ (last_cluster_written * bs.cluster_size);
|
||||
+
|
||||
+ totalsec = blocks * BLOCK_SIZE / sector_size;
|
||||
+
|
||||
+ /* Figure out how many sectors / clustors the file requires */
|
||||
+
|
||||
+ sectors = ROUND_UP(stat.st_size, sector_size);
|
||||
+ clusters = ROUND_UP(sectors, (int) bs.cluster_size);
|
||||
+
|
||||
+ if (usedsec + sectors > totalsec) {
|
||||
+ printf("Error - %s is too big (%d vs %d)\n", filename, sectors, totalsec - usedsec);
|
||||
+ close(infile);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ printf("ADD %s\n", filename);
|
||||
+
|
||||
+ /* Grab the basename of the file */
|
||||
+ base = basename(filename);
|
||||
+
|
||||
+ /* Extract out the 8.3 name */
|
||||
+ copy_filename(base, name83, ext83);
|
||||
+
|
||||
+ /* Make an extended name slot */
|
||||
+
|
||||
+ slot = (struct msdos_dir_slot *) &dir->table[dir->count++];
|
||||
+ slot->id = 'A';
|
||||
+ slot->attr = 0x0F;
|
||||
+ slot->reserved = 0;
|
||||
+ slot->start = 0;
|
||||
+
|
||||
+ slot->alias_checksum = 0;
|
||||
+
|
||||
+ for(i = 0; i < 8; i++)
|
||||
+ slot->alias_checksum = (((slot->alias_checksum&1)<<7)|((slot->alias_checksum&0xfe)>>1)) + name83[i];
|
||||
+
|
||||
+ for(i = 0; i < 3; i++)
|
||||
+ slot->alias_checksum = (((slot->alias_checksum&1)<<7)|((slot->alias_checksum&0xfe)>>1)) + ext83[i];
|
||||
+
|
||||
+ p = base;
|
||||
+
|
||||
+ copy_name(slot->name0_4, 10, &p);
|
||||
+ copy_name(slot->name5_10, 12, &p);
|
||||
+ copy_name(slot->name11_12, 4, &p);
|
||||
+
|
||||
+
|
||||
+ /* Get the entry from the root filesytem */
|
||||
+ entry = &dir->table[dir->count++];
|
||||
+
|
||||
+ strncpy(entry->name, name83, 8);
|
||||
+ strncpy(entry->ext, ext83, 3);
|
||||
+
|
||||
+
|
||||
+ /* If the user has it read only, then add read only to the incoming
|
||||
+ attribute settings */
|
||||
+
|
||||
+ if (!(stat.st_mode & S_IWUSR)) attr |= ATTR_RO;
|
||||
+ entry->attr = attr;
|
||||
+
|
||||
+ /* Set the access time on the file */
|
||||
+ ctime = localtime(&create_time);
|
||||
+
|
||||
+ entry->time = CT_LE_W((unsigned short)((ctime->tm_sec >> 1) +
|
||||
+ (ctime->tm_min << 5) + (ctime->tm_hour << 11)));
|
||||
+
|
||||
+ entry->date = CT_LE_W((unsigned short)(ctime->tm_mday +
|
||||
+ ((ctime->tm_mon+1) << 5) +
|
||||
+ ((ctime->tm_year-80) << 9)));
|
||||
+
|
||||
+ entry->ctime_ms = 0;
|
||||
+ entry->ctime = entry->time;
|
||||
+ entry->cdate = entry->date;
|
||||
+ entry->adate = entry->date;
|
||||
+ entry->size = stat.st_size;
|
||||
+
|
||||
+ start = last_cluster_written;
|
||||
+
|
||||
+ entry->start = CT_LE_W(start); /* start sector */
|
||||
+ entry->starthi = CT_LE_W((start & 0xFFFF0000) >> 16); /* High start sector (for FAT32) */
|
||||
+
|
||||
+ /* We mark all of the clusters we use in the FAT */
|
||||
+
|
||||
+ for(c = 0; c < clusters; c++ ) {
|
||||
+ int free;
|
||||
+ int next = c == (clusters - 1) ? FAT_EOF : start + c + 1;
|
||||
+ mark_FAT_cluster(start + c, next);
|
||||
+ last_cluster_written++;
|
||||
+ }
|
||||
+
|
||||
+ /* This confused me too - cluster 2 starts after the
|
||||
+ root directory data - search me as to why */
|
||||
+
|
||||
+ ptr = (start_data_sector * sector_size) + size_root_dir;
|
||||
+ ptr += (start - 2) * bs.cluster_size * sector_size;
|
||||
+
|
||||
+ buffer = (char *) malloc(sector_size);
|
||||
+
|
||||
+ if (!buffer) {
|
||||
+ printf("Error - couldn't allocate memory\n");
|
||||
+ goto exit_add;
|
||||
+ }
|
||||
+
|
||||
+ /* Write the file into the file block */
|
||||
+
|
||||
+ seekto(ptr, "datafile");
|
||||
+
|
||||
+ while(1) {
|
||||
+ int size = read(infile, buffer, sector_size);
|
||||
+ if (size <= 0) break;
|
||||
+
|
||||
+ writebuf(buffer, size, "data");
|
||||
+ }
|
||||
+
|
||||
+ exit_add:
|
||||
+ if (infile) close(infile);
|
||||
+}
|
||||
+
|
||||
+/* Add a new directory to the specified directory entry, and in turn populate
|
||||
+ it with its own files */
|
||||
+
|
||||
+/* FIXME: This should check to make sure there is enough size to add itself */
|
||||
+
|
||||
+static void add_directory(char *filename, struct dir_entry *dir) {
|
||||
+
|
||||
+ struct dir_entry *newdir = 0;
|
||||
+ struct msdos_dir_entry *entry;
|
||||
+ struct tm *ctime;
|
||||
+ DIR *rddir = opendir(filename);
|
||||
+ struct dirent *dentry = 0;
|
||||
+ int remain;
|
||||
+ char *data;
|
||||
+
|
||||
+ /* If the directory doesn't exist */
|
||||
+ if (!rddir) return;
|
||||
+
|
||||
+ if (dir->root) {
|
||||
+ if (dir->count == dir->entries) {
|
||||
+ printf("Error - too many directory entries\n");
|
||||
+ goto exit_add_dir;
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ if (dir->count == dir->entries) {
|
||||
+ if (!dir->table)
|
||||
+ dir->table = (struct msdos_dir_entry *) malloc(sizeof(struct msdos_dir_entry));
|
||||
+ else {
|
||||
+ dir->table = (struct msdos_dir_entry *) realloc(dir->table, (dir->entries + 1) *
|
||||
+ sizeof(struct msdos_dir_entry));
|
||||
+
|
||||
+ /* Zero it out to avoid issues */
|
||||
+ memset(&dir->table[dir->entries], 0, sizeof(struct msdos_dir_entry));
|
||||
+ }
|
||||
+ dir->entries++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* Now, create a new directory entry for the new directory */
|
||||
+ newdir = (struct dir_entry *) calloc(1, sizeof(struct dir_entry));
|
||||
+ if (!newdir) goto exit_add_dir;
|
||||
+
|
||||
+ entry = &dir->table[dir->count++];
|
||||
+
|
||||
+ strncpy(entry->name, basename(filename), sizeof(entry->name));
|
||||
+
|
||||
+ entry->attr = ATTR_DIR;
|
||||
+ ctime = localtime(&create_time);
|
||||
+
|
||||
+ entry->time = CT_LE_W((unsigned short)((ctime->tm_sec >> 1) +
|
||||
+ (ctime->tm_min << 5) + (ctime->tm_hour << 11)));
|
||||
+
|
||||
+ entry->date = CT_LE_W((unsigned short)(ctime->tm_mday +
|
||||
+ ((ctime->tm_mon+1) << 5) +
|
||||
+ ((ctime->tm_year-80) << 9)));
|
||||
+
|
||||
+ entry->ctime_ms = 0;
|
||||
+ entry->ctime = entry->time;
|
||||
+ entry->cdate = entry->date;
|
||||
+ entry->adate = entry->date;
|
||||
+
|
||||
+ /* Now, read the directory */
|
||||
+
|
||||
+ while((dentry = readdir(rddir))) {
|
||||
+ struct stat st;
|
||||
+ char *buffer;
|
||||
+
|
||||
+ if (!strcmp(dentry->d_name, ".") || !strcmp(dentry->d_name, ".."))
|
||||
+ continue;
|
||||
+
|
||||
+ /* DOS wouldn't like a typical unix . (dot) file, so we skip those too */
|
||||
+ if (dentry->d_name[0] == '.') continue;
|
||||
+
|
||||
+ buffer = malloc(strlen(filename) + strlen(dentry->d_name) + 3);
|
||||
+ if (!buffer) continue;
|
||||
+
|
||||
+ sprintf(buffer, "%s/%s", filename, dentry->d_name);
|
||||
+ if (!stat(buffer, &st)) {
|
||||
+ if (S_ISDIR(st.st_mode))
|
||||
+ add_directory(buffer, newdir);
|
||||
+ else if (S_ISREG(st.st_mode)) {
|
||||
+ unsigned char attrib = check_attrib_file(filename, dentry->d_name);
|
||||
+ add_file(buffer, newdir, attrib);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ free(buffer);
|
||||
+ }
|
||||
+
|
||||
+ /* Now that the entire directory has been written, go ahead and write the directory
|
||||
+ entry as well */
|
||||
+
|
||||
+ entry->start = CT_LE_W(last_cluster_written);
|
||||
+ entry->starthi = CT_LE_W((last_cluster_written & 0xFFFF0000) >> 16);
|
||||
+ entry->size = newdir->count * sizeof(struct msdos_dir_entry);
|
||||
+
|
||||
+ remain = entry->size;
|
||||
+ data = (char *) newdir->table;
|
||||
+
|
||||
+ while(remain) {
|
||||
+ int size =
|
||||
+ remain > bs.cluster_size * sector_size ? bs.cluster_size * sector_size : remain;
|
||||
+
|
||||
+ int pos = (start_data_sector * sector_size) + size_root_dir;
|
||||
+ pos += (last_cluster_written - 2) * bs.cluster_size * sector_size;
|
||||
+
|
||||
+ seekto(pos, "add_dir");
|
||||
+ writebuf(data, size, "add_dir");
|
||||
+
|
||||
+ remain -= size;
|
||||
+ data += size;
|
||||
+
|
||||
+ mark_FAT_cluster(last_cluster_written, remain ? last_cluster_written + 1 : FAT_EOF);
|
||||
+ last_cluster_written++;
|
||||
+ }
|
||||
+
|
||||
+ exit_add_dir:
|
||||
+ if (rddir) closedir(rddir);
|
||||
+ if (newdir->table) free(newdir->table);
|
||||
+ if (newdir) free(newdir);
|
||||
+}
|
||||
+
|
||||
+/* Given a directory, add all the files and directories to the root directory of the
|
||||
+ image.
|
||||
+*/
|
||||
+
|
||||
+static void add_root_directory(char *dirname)
|
||||
+{
|
||||
+ DIR *dir = opendir(dirname);
|
||||
+ struct dirent *entry = 0;
|
||||
+ struct dir_entry *newdir = 0;
|
||||
+
|
||||
+ if (!dir) {
|
||||
+ printf("Error - directory %s does not exist\n", dirname);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* Create the root directory structure - this is a bit different then
|
||||
+ above, because the table already exists, we just refer to it. */
|
||||
+
|
||||
+ newdir = (struct dir_entry *) calloc(1,sizeof(struct dir_entry));
|
||||
+
|
||||
+ if (!newdir) {
|
||||
+ closedir(dir);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ newdir->entries = root_dir_entries;
|
||||
+ newdir->root = 1;
|
||||
+ newdir->count = 0;
|
||||
+ newdir->table = root_dir;
|
||||
+
|
||||
+ while((entry = readdir(dir))) {
|
||||
+ struct stat st;
|
||||
+ char *buffer;
|
||||
+
|
||||
+ if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
|
||||
+ continue;
|
||||
+
|
||||
+ /* DOS wouldn't like a typical unix . (dot) file, so we skip those too */
|
||||
+ if (entry->d_name[0] == '.') continue;
|
||||
+
|
||||
+ buffer = malloc(strlen(dirname) + strlen(entry->d_name) + 3);
|
||||
+ if (!buffer) continue;
|
||||
+
|
||||
+ sprintf(buffer, "%s/%s", dirname, entry->d_name);
|
||||
+ if (!stat(buffer, &st)) {
|
||||
+ if (S_ISDIR(st.st_mode))
|
||||
+ add_directory(buffer, newdir);
|
||||
+ else if (S_ISREG(st.st_mode)) {
|
||||
+ unsigned char attrib = check_attrib_file(dirname, entry->d_name);
|
||||
+ add_file(buffer, newdir, attrib);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ free(buffer);
|
||||
+ }
|
||||
+
|
||||
+ closedir(dir);
|
||||
+ if (newdir) free(newdir);
|
||||
+}
|
||||
|
||||
/* Report the command usage and return a failure error code */
|
||||
|
||||
@@ -1418,9 +1898,9 @@
|
||||
[-m boot-msg-file] [-n volume-name] [-i volume-id] [-B bootcode]\n\
|
||||
[-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs]\n\
|
||||
[-F fat-size] [-r root-dir-entries] [-R reserved-sectors]\n\
|
||||
- /dev/name [blocks]\n");
|
||||
+ [-d directory] /dev/name [blocks]\n");
|
||||
}
|
||||
-
|
||||
+
|
||||
/*
|
||||
* ++roman: On m68k, check if this is an Atari; if yes, turn on Atari variant
|
||||
* of MS-DOS filesystem by default.
|
||||
@@ -1458,6 +1938,8 @@
|
||||
int c;
|
||||
char *tmp;
|
||||
char *listfile = NULL;
|
||||
+ char *dirname = NULL;
|
||||
+
|
||||
FILE *msgfile;
|
||||
struct stat statbuf;
|
||||
int i = 0, pos, ch;
|
||||
@@ -1477,7 +1959,7 @@
|
||||
printf ("%s " VERSION " (" VERSION_DATE ")\n",
|
||||
program_name);
|
||||
|
||||
- while ((c = getopt (argc, argv, "AcCf:F:Ii:l:m:n:r:R:s:S:v:B:b")) != EOF)
|
||||
+ while ((c = getopt (argc, argv, "AcCd:f:F:Ii:l:m:n:r:R:s:S:v:B:b")) != EOF)
|
||||
/* Scan the command line for options */
|
||||
switch (c)
|
||||
{
|
||||
@@ -1502,6 +1984,10 @@
|
||||
create = TRUE;
|
||||
break;
|
||||
|
||||
+ case 'd':
|
||||
+ dirname = optarg;
|
||||
+ break;
|
||||
+
|
||||
case 'f': /* f : Choose number of FATs */
|
||||
nr_fats = (int) strtol (optarg, &tmp, 0);
|
||||
if (*tmp || nr_fats < 1 || nr_fats > 4)
|
||||
@@ -1796,8 +2282,10 @@
|
||||
else if (listfile)
|
||||
get_list_blocks (listfile);
|
||||
|
||||
- write_tables (); /* Write the file system tables away! */
|
||||
|
||||
+ if (dirname) add_root_directory(dirname);
|
||||
+
|
||||
+ write_tables (); /* Write the file system tables away! */
|
||||
exit (0); /* Terminate with no errors! */
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
--- dosfstools-2.10/dosfsck/boot.c.orig 2004-10-15 08:51:42.394725176 -0600
|
||||
+++ dosfstools-2.10/dosfsck/boot.c 2004-10-15 08:49:16.776862456 -0600
|
||||
@@ -14,6 +14,9 @@
|
||||
#include "io.h"
|
||||
#include "boot.h"
|
||||
|
||||
+#ifndef MSDOS_FAT12
|
||||
+#define MSDOS_FAT12 4084
|
||||
+#endif
|
||||
|
||||
#define ROUND_TO_MULTIPLE(n,m) ((n) && (m) ? (n)+(m)-1-((n)-1)%(m) : 0)
|
||||
/* don't divide by zero */
|
||||
11
meta-extras/packages/evince/evince_0.9.0.bb
Normal file
11
meta-extras/packages/evince/evince_0.9.0.bb
Normal file
@@ -0,0 +1,11 @@
|
||||
DESCRIPTION = "Evince is a document viewer for document formats like PDF, PS, DjVu."
|
||||
LICENSE = "GPL"
|
||||
SECTION = "x11/office"
|
||||
DEPENDS = "gnome-doc-utils poppler libxml2 gtk+ gnome-vfs gconf libglade gnome-keyring"
|
||||
|
||||
inherit gnome pkgconfig gtk-icon-cache
|
||||
|
||||
SRC_URI = "${GNOME_MIRROR}/${PN}/0.9/${PN}-${PV}.tar.bz2 \
|
||||
file://no-icon-theme.diff;patch=1;pnum=0"
|
||||
|
||||
EXTRA_OECONF = "--without-libgnome --disable-thumbnailer"
|
||||
15
meta-extras/packages/evince/evince_svn.bb
Normal file
15
meta-extras/packages/evince/evince_svn.bb
Normal file
@@ -0,0 +1,15 @@
|
||||
DESCRIPTION = "Evince is a document viewer for document formats like PDF, PS, DjVu."
|
||||
LICENSE = "GPL"
|
||||
SECTION = "x11/office"
|
||||
DEPENDS = "gnome-doc-utils poppler libxml2 gtk+ gnome-vfs gconf libglade gnome-keyring"
|
||||
|
||||
PV = "0.9.0+svn${SRCDATE}"
|
||||
|
||||
inherit gnome pkgconfig gtk-icon-cache
|
||||
|
||||
SRC_URI = "svn://svn.gnome.org/svn/evince;module=trunk \
|
||||
file://no-icon-theme.diff;patch=1;pnum=0"
|
||||
|
||||
S = "${WORKDIR}/trunk"
|
||||
|
||||
EXTRA_OECONF = "--without-libgnome --disable-thumbnailer"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user