]> code.ossystems Code Review - openembedded-core.git/commitdiff
packaged-staging: basic support for pulling staging packages from a mirror
authorJoshua Lock <josh@linux.intel.com>
Fri, 29 Jan 2010 12:27:30 +0000 (12:27 +0000)
committerJoshua Lock <josh@linux.intel.com>
Fri, 29 Jan 2010 12:33:46 +0000 (12:33 +0000)
Add simple support for trying to fetch staging packages from a http, https  or
ftp mirror if they do not already exist in PSTAGE_DIR.

As documented in local.conf.sample
"Poky can try and fetch packaged-staging packages from a http, https or ftp
mirror. Set this variable to the root of a pstage directory on a server."

If the PSTAGE_MIRROR variable is not set, or the package cannot be found on
the mirror it will be built as usual.

Signed-off-by: Joshua Lock <josh@linux.intel.com>
build/conf/local.conf.sample
meta/classes/packaged-staging.bbclass

index 149c73d6645b75ce6a4abcbe65f9d1fb6be5b883..14af548efd83f5b1d6522bc3ed14ed18941258d2 100644 (file)
@@ -159,3 +159,7 @@ ENABLE_BINARY_LOCALE_GENERATION = "1"
 # on an x86_64 host.
 # Supported values are i586 and x86_64
 #SDKMACHINE="i586"
+
+# Poky can try and fetch packaged-staging packages from a http, https or ftp
+# mirror. Set this variable to the root of a pstage directory on a server.
+#PSTAGE_MIRROR ?= "http://someserver.tld/share/pstage"
index 74855c4ab3c146c69366230476ddb90886286336..4789ecc3b18ba6b3e7d0671c0d28de8b9541e9aa 100644 (file)
@@ -135,7 +135,9 @@ do_clean_prepend() {
 
        stagepkg = bb.data.expand("${PSTAGE_PKG}", d)
        bb.note("Removing staging package %s" % stagepkg)
-       os.system('rm -rf ' + stagepkg)
+        # Add a wildcard to the end of stagepkg to also get its md5
+        # if it's a fetched package
+       os.system('rm -rf ' + stagepkg + '*')
 }
 
 staging_helper () {
@@ -159,6 +161,27 @@ staging_helper () {
        fi
 }
 
+def staging_fetch(stagepkg, d):
+    import bb.fetch
+
+    # only try and fetch if the user has configured a mirror
+    if bb.data.getVar('PSTAGE_MIRROR', d) != "":
+        # Copy the data object and override DL_DIR and SRC_URI
+        pd = d.createCopy()
+        dldir = bb.data.expand("${PSTAGE_DIR}/${PSTAGE_PKGPATH}", pd)
+        mirror = bb.data.expand("${PSTAGE_MIRROR}/${PSTAGE_PKGPATH}/", pd)
+        srcuri = mirror + os.path.basename(stagepkg)
+        bb.data.setVar('DL_DIR', dldir, pd)
+        bb.data.setVar('SRC_URI', srcuri, pd)
+
+        # Try a fetch from the pstage mirror, if it fails just return and
+        # we will build the package
+        try:
+            bb.fetch.init([srcuri], pd)
+            bb.fetch.go(pd, [srcuri])
+        except:
+            return
+
 PSTAGE_TASKS_COVERED = "fetch unpack munge patch configure qa_configure rig_locales compile sizecheck install deploy package populate_sysroot package_write_deb package_write_ipk package_write package_stage qa_staging"
 
 SCENEFUNCS += "packagestage_scenefunc"
@@ -174,6 +197,8 @@ python packagestage_scenefunc () {
     pstage_cleanpackage(removepkg, d)
 
     stagepkg = bb.data.expand("${PSTAGE_PKG}", d)
+    if not os.path.exists(stagepkg):
+        staging_fetch(stagepkg, d)
 
     if os.path.exists(stagepkg):
         path = bb.data.getVar("PATH", d, 1)