From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ia0-f176.google.com (mail-ia0-f176.google.com [209.85.210.176]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id D456DE0049F for ; Thu, 4 Oct 2012 11:59:00 -0700 (PDT) Received: by mail-ia0-f176.google.com with SMTP id h11so409673iae.35 for ; Thu, 04 Oct 2012 11:58:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=Dc1ylzlM6CcKK9xoXiXLAq5QZgLgEn+aEITZ/HoXst8=; b=JJ9DHNYMEYDY1Ur91vRtEcHIPgVkJ1wj3egtwJG0uNJSQXSwhb9DSKfFA0k0NC+8Vr fDRR3XCe5nNggzMIxnYix2NQBPWzs05Hvx7ezTJNTrFGfFI/4QNfnrcg/aQ+F10XNOAH 2XuiN6Hd3IlbxWFOucvncZ2LhjSmlb+dxlV+FNLwMs4J+uBQQpG+lXPAFUHLkcHQhgbu +NsUkfmcOjdiJbteyRUVe+3CwawbOdBC+znp6d58MxAzJnxmp6k+zwiqSMVlEuzJU7Ot SjajHIiAA9WOfv7aHrbum3AfppPh2mcKvO4gqjymT/vjRCPava2vnJD2NxC+EcfbvNxD XKTQ== MIME-Version: 1.0 Received: by 10.42.39.197 with SMTP id i5mr5255828ice.27.1349377138175; Thu, 04 Oct 2012 11:58:58 -0700 (PDT) Sender: rstreif@linuxfoundation.org Received: by 10.64.27.197 with HTTP; Thu, 4 Oct 2012 11:58:58 -0700 (PDT) In-Reply-To: <6796989A-D845-4726-B47B-64B82F380444@gamestop.com> References: <6796989A-D845-4726-B47B-64B82F380444@gamestop.com> Date: Thu, 4 Oct 2012 11:58:58 -0700 X-Google-Sender-Auth: 92kCwGkk_l_xAxow_noK9ebMKgA Message-ID: From: Rudolf Streif To: Patrick Turley X-Gm-Message-State: ALoCoQkMUgZc1T/P9Fs38BCfV/7j5LPcMDTiugwSY+2lueCknom6Qv2aD5J6lxp+JXAVCSefx21f Cc: "yocto@yoctoproject.org" Subject: Re: The BitBake equivalent of "Hello, World!" X-BeenThere: yocto@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Discussion of all things Yocto List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Oct 2012 18:59:01 -0000 Content-Type: multipart/alternative; boundary=90e6ba6e8e1cfd2d2804cb4058a1 --90e6ba6e8e1cfd2d2804cb4058a1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable [Warning: lengthy post, and probably boring to most.] My Bitbake "Hello World" is a little more than a basic "Hello World". It's idea is to incorporate a layer and use a structure similar to what OE and Yocto are using. You can do it simpler if you want to. I did this a while ago with Bitbake 1.12.0. I would think it works with newer versions too although I have not tested it. This is the layout I am using: bbtest/ =E2=94=9C=E2=94=80=E2=94=80 conf =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 bblayers.conf =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 bitbake.conf =E2=94=9C=E2=94=80=E2=94=80 downloads =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 /* need to create but will be popul= ated with downloads */ =E2=94=9C=E2=94=80=E2=94=80 meta-test =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 classes =E2=94=82 =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 base.bbclass =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 conf =E2=94=82 =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 layer.conf =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 recipes-test =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 nano =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 nano.bb =E2=94=94=E2=94=80=E2=94=80 tmp =E2=94=94=E2=94=80=E2=94=80 /* will be created and populated when build= ing */ The first thing Bitbake looks for is a conf/bblayers.conf file in the directory you started it from. This file must provide an initial setting for BBPATH: bblayers.conf: BBPATH :=3D "${TOPDIR}" BBFILES ?=3D "" BBLAYERS =3D " \ ${TOPDIR}/meta-test \ " Without BBPATH Bitbake will not find any conf/.conf files and recipe files at all. It will also not find bitbake.conf. I simply copied bitbake.conf from the Bitbake download and edited DL_DIR: bitbake.conf: # comments omitted B =3D "${S}" CVSDIR =3D "${DL_DIR}/cvs" DEPENDS =3D "" DEPLOY_DIR =3D "${TMPDIR}/deploy" DEPLOY_DIR_IMAGE =3D "${DEPLOY_DIR}/images" DL_DIR =3D "${TOPDIR}/downloads" FETCHCOMMAND =3D "" FETCHCOMMAND_cvs =3D "/usr/bin/env cvs -d${CVSROOT} co ${CVSCOOPTS} ${CVSMODULE}" FETCHCOMMAND_svn =3D "/usr/bin/env svn co ${SVNCOOPTS} ${SVNROOT} ${SVNMODULE}" FETCHCOMMAND_wget =3D "/usr/bin/env wget -t 5 --passive-ftp -P ${DL_DIR} ${URI}" FILESDIR =3D "${@bb.utils.which(bb.data.getVar('FILESPATH', d, 1), '.')}" FILESPATH =3D "${FILE_DIRNAME}/${PF}:${FILE_DIRNAME}/${P}:${FILE_DIRNAME}/${PN}:${FILE_DI= RNAME}/files:${FILE_DIRNAME}" FILE_DIRNAME =3D "${@os.path.dirname(bb.data.getVar('FILE', d))}" GITDIR =3D "${DL_DIR}/git" IMAGE_CMD =3D "_NO_DEFINED_IMAGE_TYPES_" IMAGE_ROOTFS =3D "${TMPDIR}/rootfs" MKTEMPCMD =3D "mktemp -q ${TMPBASE}" MKTEMPDIRCMD =3D "mktemp -d -q ${TMPBASE}" OVERRIDES =3D "local:${MACHINE}:${TARGET_OS}:${TARGET_ARCH}" P =3D "${PN}-${PV}" PERSISTENT_DIR =3D "${TMPDIR}/cache" PF =3D "${PN}-${PV}-${PR}" PN =3D "${@bb.parse.BBHandler.vars_from_file(bb.data.getVar('FILE',d),d)[0] or 'defaultpkgname'}" PR =3D "${@bb.parse.BBHandler.vars_from_file(bb.data.getVar('FILE',d),d)[2] or 'r0'}" PROVIDES =3D "" PV =3D "${@bb.parse.BBHandler.vars_from_file(bb.data.getVar('FILE',d),d)[1] or '1.0'}" RESUMECOMMAND =3D "" RESUMECOMMAND_wget =3D "/usr/bin/env wget -c -t 5 --passive-ftp -P ${DL_DIR= } ${URI}" S =3D "${WORKDIR}/${P}" SRC_URI =3D "file://${FILE}" STAMP =3D "${TMPDIR}/stamps/${PF}" SVNDIR =3D "${DL_DIR}/svn" T =3D "${WORKDIR}/temp" TARGET_ARCH =3D "${BUILD_ARCH}" TMPDIR =3D "${TOPDIR}/tmp" UPDATECOMMAND =3D "" UPDATECOMMAND_cvs =3D "/usr/bin/env cvs -d${CVSROOT} update ${CVSCOOPTS}" UPDATECOMMAND_svn =3D "/usr/bin/env svn update ${SVNCOOPTS}" WORKDIR =3D "${TMPDIR}/work/${PF}" PERSISTENT_DIR =3D "${TMPDIR}/cache" That's more than you need but it's convenient. Bitbake will require a base.bbclass file somewhere in a classes subdirectory of BBPATH. I used the base.bbclass file from the Bitbake download. As a minimum it should contain a do_build task. That's the target that Bitbake invokes by default if you do not use the -c option explicitly. It's empty and does not do anything but it functions as an anchor for tasks you define in your recipes: base.bbclass: # comments omitted die() { bbfatal "$*" } bbnote() { echo "NOTE:" "$*" } bbwarn() { echo "WARNING:" "$*" } bbfatal() { echo "FATAL:" "$*" exit 1 } addtask showdata do_showdata[nostamp] =3D "1" python do_showdata() { import sys # emit variables and shell functions bb.data.emit_env(sys.__stdout__, d, True) # emit the metadata which isnt valid shell for e in bb.data.keys(d): if bb.data.getVarFlag(e, 'python', d): sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, bb.data.getVar(e, d, 1))) } addtask listtasks do_listtasks[nostamp] =3D "1" python do_listtasks() { import sys for e in bb.data.keys(d): if bb.data.getVarFlag(e, 'task', d): sys.__stdout__.write("%s\n" % e) } addtask build do_build[dirs] =3D "${TOPDIR}" do_build[nostamp] =3D "1" python base_do_build () { bb.note("The included, default BB base.bbclass does not define a useful default task.") bb.note("Try running the 'listtasks' task against a .bb to see what tasks are defined.") } EXPORT_FUNCTIONS do_clean do_mrproper do_build Again, it's more than you need. It's just convenient to use it. I put this file inside the layer but you can also create a classes directory in ${TOPDIR} (bbtest in this example). Next, create a layer (meta-bbtest in my example, name does not matter, meta-* is convention). It needs a conf/layer.con file: layer.conf: # We have a metadata layer directory, add to BBPATH BBPATH .=3D ":${LAYERDIR}" # We have a recipe directory, add to BBFILES BBFILES +=3D "${LAYERDIR}/recipes-*/*/*.bb \ ${LAYERDIR}/recipes-*/*/*.bbappend" BBFILE_COLLECTIONS +=3D "test" BBFILE_PATTERN_test :=3D "^${LAYERDIR}/" BBFILE_PRIORITY_test =3D "5" The path expression for the recipes is more complex than necessary, it just follows the convention. Finally a recipe to build the Nano editor: DESCRIPTION =3D "Recipe to build the 'nano' editor" PN =3D "nano" PV =3D "2.2.6" SRC_URI =3D "http://www.nano-editor.org/dist/v2.2/nano-2.2.6.tar.gz" python do_fetch() { bb.note("Downloading source tarball from ${SRC_URI} ...") src_uri =3D (bb.data.getVar('SRC_URI', d, True) or "").split() if len(src_uri) =3D=3D 0: bb.fatal("Empty URI") try: bb.fetch.init(src_uri, d) bb.fetch.go(d) except FetchError: bb.fatal("Could not fetch source tarball.") bb.note("Download successful.") } addtask fetch before do_build python do_unpack() { bb.note("Unpacking source tarball ...") os.system("tar x -C ${WORKDIR} -f ${DL_DIR}/${P}.tar.gz") bb.note("Unpacked source tarball.") } addtask unpack before do_build after do_fetch python do_configure() { bb.note("Configuring source package ...") os.system("cd ${WORKDIR}/${P} && ./configure") bb.note("Configured source package.") } addtask configure before do_build after do_unpack python do_compile() { bb.note("Compiling package...") os.system("cd ${WORKDIR}/${P} && make") bb.note("Compiled package.") } addtask compile before do_build after do_configure Nano is an autotooled package. This recipe simply at a very basic level does what you would do manually. OECore's autotools.bbclass is much more sophisticated and so are the fetcher class files. :rjs --90e6ba6e8e1cfd2d2804cb4058a1 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
[Warning: lengthy post, and probably boring to most.]

My Bitbake "Hello World" is a little more than a basic "= Hello World". It's idea is to incorporate a layer and use a struct= ure similar to what OE and Yocto are using. You can do it simpler if you wa= nt to. I did this a while ago with Bitbake 1.12.0. I would think it works w= ith newer versions too although I have not tested it. This is the layout I = am using:

bbtest/
=E2=94=9C=E2=94=80=E2=94=80 conf
=E2=94=82 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80 bblayers.conf
= =E2=94=82 =C2=A0 =E2=94=94=E2=94=80=E2=94=80 bitbake.conf
=E2=94= =9C=E2=94=80=E2=94=80 downloads
=E2=94=82 =C2=A0=C2=A0=E2=94=94= =E2=94=80=E2=94=80 /* need to create but will be populated with downloads *= /
=E2=94=9C=E2=94=80=E2=94=80 meta-test
=E2=94=82 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80 classes
=E2=94= =82 =C2=A0 =E2=94=82 =C2=A0 =E2=94=94=E2=94=80=E2=94=80 base.bbclass
<= div>=E2=94=82 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80 conf =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0
=E2=94=82 = =C2=A0 =E2=94=82 =C2=A0 =E2=94=94=E2=94=80=E2=94=80 layer.conf =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0=C2=A0
=E2=94=82 =C2=A0 =E2=94=94=E2=94=80=E2=94=80 recipes-test =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0
=E2=94=82 =C2=A0 =C2=A0 =C2= =A0=C2=A0=E2=94=94=E2=94=80=E2=94=80 nano =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0=C2=A0
=E2=94=82 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =E2=94=94=E2=94=80=E2=94=80 nano.bb =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
=
=E2=94=94=E2=94=80=E2=94=80 tmp =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
=C2=A0 =C2=A0 =E2=94=94=E2=94=80=E2=94=80 /* will be created and popul= ated when building */

The first thing Bitbake look= s for is a conf/bblayers.conf file in the directory you started it from. Th= is file must provide an initial setting for BBPATH:

bblayers.conf:

BBPATH := =3D "${TOPDIR}"
BBFILES ?=3D ""
BBL= AYERS =3D " \
=C2=A0 ${TOPDIR}/meta-test \
=C2=A0 = "

Without BBPATH Bitbake will not find any conf/<filen= ame>.conf files and recipe files at all. It will also not find bitbake.c= onf. I simply copied bitbake.conf from the Bitbake download and edited DL_D= IR:

bitbake.conf:

# comments omitt= ed
B =3D "${S}" =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0
CVSDIR =3D "${DL_DIR}/cvs" =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=
DEPENDS =3D "" =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0
DEPLOY_DIR =3D "${TMPDIR}/deploy"
DEPLOY_DIR_IMAGE= =3D "${DEPLOY_DIR}/images"
DL_DIR =3D "${TOPDIR}/= downloads"
FETCHCOMMAND =3D ""
FETCHCOMM= AND_cvs =3D "/usr/bin/env cvs -d${CVSROOT} co ${CVSCOOPTS} ${CVSMODULE= }"
FETCHCOMMAND_svn =3D "/usr/bin/env svn co ${SVNCOOPTS} ${SVNROOT}= ${SVNMODULE}"
FETCHCOMMAND_wget =3D "/usr/bin/env wget= -t 5 --passive-ftp -P ${DL_DIR} ${URI}"
FILESDIR =3D "= ${@bb.utils.which(bb.data.getVar('FILESPATH', d, 1), '.')}&= quot;
FILESPATH =3D "${FILE_DIRNAME}/${PF}:${FILE_DIRNAME}/${P}:${FILE_= DIRNAME}/${PN}:${FILE_DIRNAME}/files:${FILE_DIRNAME}"
FILE_D= IRNAME =3D "${@os.path.dirname(bb.data.getVar('FILE', d))}&quo= t;
GITDIR =3D "${DL_DIR}/git"
IMAGE_CMD =3D "_NO= _DEFINED_IMAGE_TYPES_"
IMAGE_ROOTFS =3D "${TMPDIR}/root= fs"
MKTEMPCMD =3D "mktemp -q ${TMPBASE}"
MKTEMPDIRCMD =3D "mktemp -d -q ${TMPBASE}"
OVERRIDES =3D "local:${MACHINE}:${TARGET_OS}:${TARGET_ARCH}"=
P =3D "${PN}-${PV}"
PERSISTENT_DIR =3D "= ;${TMPDIR}/cache"
PF =3D "${PN}-${PV}-${PR}"
=
PN =3D "${@bb.parse.BBHandler.vars_from_file(bb.data.getVar('FILE&= #39;,d),d)[0] or 'defaultpkgname'}"
PR =3D "${@= bb.parse.BBHandler.vars_from_file(bb.data.getVar('FILE',d),d)[2] or= 'r0'}"
PROVIDES =3D ""
PV =3D "${@bb.parse.BBHandler= .vars_from_file(bb.data.getVar('FILE',d),d)[1] or '1.0'}&qu= ot;
RESUMECOMMAND =3D ""
RESUMECOMMAND_wget = =3D "/usr/bin/env wget -c -t 5 --passive-ftp -P ${DL_DIR} ${URI}"=
S =3D "${WORKDIR}/${P}"
SRC_URI =3D "file://$= {FILE}"
STAMP =3D "${TMPDIR}/stamps/${PF}"
SVNDIR =3D "${DL_DIR}/svn"
T =3D "${WORKDIR}/te= mp"
TARGET_ARCH =3D "${BUILD_ARCH}"
TMPDIR =3D "$= {TOPDIR}/tmp"
UPDATECOMMAND =3D ""
UPDAT= ECOMMAND_cvs =3D "/usr/bin/env cvs -d${CVSROOT} update ${CVSCOOPTS}&qu= ot;
UPDATECOMMAND_svn =3D "/usr/bin/env svn update ${SVNCOOPTS}"=
WORKDIR =3D "${TMPDIR}/work/${PF}"
PERSISTEN= T_DIR =3D "${TMPDIR}/cache"

That&#= 39;s more than you need but it's convenient.

Bitbake will require a base.bbclass file somewhere in a= classes subdirectory of BBPATH. I used the base.bbclass file from the Bitb= ake download. As a minimum it should contain a do_build task. That's th= e target that Bitbake invokes by default if you do not use the -c option ex= plicitly. It's empty and does not do anything but it functions as an an= chor for tasks you define in your recipes:

base.bbclass:

# comments = omitted
die() {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = bbfatal "$*"
}

bbnote() {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 echo "NOTE:" "$*"
}

bbwarn() {
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 echo "WARNING:" "$*"
}

<= /div>
bbfatal() {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 echo "FATA= L:" "$*"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 exit 1
}

addtask showdata
do_showdata[nost= amp] =3D "1"
python do_showdata() {
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 import sys
=C2=A0 =C2=A0 =C2=A0 =C2=A0 # emi= t variables and shell functions
=C2=A0 =C2=A0 =C2=A0 =C2=A0 bb.data.emit_env(sys.__stdout__, d, True)
=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 # emit the metadata which isnt valid shell=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 for e in bb.data.keys(d):
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if bb.data.getVarFl= ag(e, 'python', d):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e= , bb.data.getVar(e, d, 1)))
}

addtask li= sttasks
do_listtasks[nostamp] =3D "1"
python do_listtasks() {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 import s= ys
=C2=A0 =C2=A0 =C2=A0 =C2=A0 for e in bb.data.keys(d):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if bb.data.getVar= Flag(e, 'task', d):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sys.__stdout__.write("= ;%s\n" % e)
}

addtask build
do_build[dirs] =3D = "${TOPDIR}"
do_build[nostamp] =3D "1"
python base_do_build () {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 bb.note(= "The included, default BB base.bbclass does not define a useful defaul= t task.")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 bb.note("Try running the 'listtas= ks' task against a .bb to see what tasks are defined.")
= }

EXPORT_FUNCTIONS do_clean do_mrproper do_build

Again, it's more than you need. It's just convenient to = use it. I put this file inside the layer but you can also create a classes = directory in ${TOPDIR} (bbtest in this example). Next, create a layer (meta= -bbtest in my example, name does not matter, meta-* is convention). It need= s a conf/layer.con file:

layer.conf:

# We have a m= etadata layer directory, add to BBPATH
BBPATH .=3D ":${LAYER= DIR}"

# We have a recipe directory, add to BB= FILES
BBFILES +=3D "${LAYERDIR}/recipes-*/*/*.bb \
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS +=3D "test"
B= BFILE_PATTERN_test :=3D "^${LAYERDIR}/"
BBFILE_PRIORITY_test =3D "5"

= The path expression for the recipes is more complex than necessary, it just= follows the convention. Finally a recipe to build the Nano editor:

DESCRIPTION =3D "Recipe to build the 'nan= o' editor"

PN =3D "nano"
<= div>PV =3D "2.2.6"


python do_fetch() {
=C2=A0 =C2=A0bb.note(&quo= t;Downloading source tarball from ${SRC_URI} ...")

=C2=A0 =C2=A0src_uri =3D (bb.data.getVar('SRC_URI', d, True) = or "").split()
=C2=A0 =C2=A0if len(src_uri) =3D=3D 0:
=C2=A0 =C2=A0 =C2=A0 = bb.fatal("Empty URI")

=C2=A0 =C2=A0try:<= /div>
=C2=A0 =C2=A0 =C2=A0 bb.fetch.init(src_uri, d)
=C2=A0 = =C2=A0 =C2=A0 bb.fetch.go(d)
=C2=A0 =C2=A0except FetchError:
=C2=A0 =C2=A0 =C2=A0 bb.fatal("Could not fetch source tarball.&qu= ot;)

=C2=A0 =C2=A0bb.note("Download successfu= l.")
}

addtask fetch before do_buil= d


python do_unpack() {
=C2=A0 =C2=A0bb.note(&qu= ot;Unpacking source tarball ...")

=C2=A0 =C2= =A0os.system("tar x -C ${WORKDIR} -f ${DL_DIR}/${P}.tar.gz")

=C2=A0 =C2=A0bb.note("Unpacked source tarball.")
}

addtask unpack before do_build after do_fetch


python do_configure() {
=C2=A0 = =C2=A0bb.note("Configuring source package ...")

=C2=A0 =C2=A0os.system("cd ${WORKDIR}/${P} &&a= mp; ./configure")

=C2=A0 =C2=A0bb.note("= Configured source package.")
}

addt= ask configure before do_build after do_unpack


python do_compile() {
=C2=A0 = =C2=A0bb.note("Compiling package...")

= =C2=A0 =C2=A0os.system("cd ${WORKDIR}/${P} && make")

=C2=A0 =C2=A0bb.note("Compiled package.")
}
<= br>
addtask compile before do_build after do_configure


Nano is an autotooled package. This rec= ipe simply at a very basic level does what you would do manually. OECore= 9;s autotools.bbclass is much more sophisticated and so are the fetcher cla= ss files.

:rjs


--90e6ba6e8e1cfd2d2804cb4058a1--