Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2011-05-16 19:38:02 (GMT)
committer Daniel Drake <dsd@laptop.org>2011-05-16 20:25:20 (GMT)
commitda680b0bde03a16ae824fffa228ae42822be0686 (patch)
treefb1e5f2c8340ed1daf8554534b933f40a4d1589f /lib
parentd614daeee5330bdc1de78394a89c873b497f9d19 (diff)
Install sugar bundles using sugar-install-bundle (#10427)
Also improves consistency between the 3 bundle-fetching modules. Based on work by Jerry Vonau.
Diffstat (limited to 'lib')
-rw-r--r--lib/ooblib.py19
-rw-r--r--lib/shlib.sh18
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/ooblib.py b/lib/ooblib.py
index eea30a3..76845d5 100644
--- a/lib/ooblib.py
+++ b/lib/ooblib.py
@@ -2,6 +2,7 @@
# Licensed under the terms of the GNU GPL v2 or later; see COPYING for details.
import os
+import shutil
import urllib2
from xml.etree.ElementTree import ElementTree
@@ -74,3 +75,21 @@ def get_repomd(baseurl):
except:
pass
return md
+
+def ln_or_cp(src, dest):
+ src_dev = os.stat(src).st_dev
+ dest_dev = os.stat(dest).st_dev
+
+ if src_dev == dest_dev:
+ if os.path.isdir(dest):
+ dest = os.path.join(dest, os.path.basename(src))
+ os.link(src, dest)
+ else:
+ shutil.copy(src, dest)
+
+def install_sugar_bundle(path):
+ bundlesdir = os.path.join(intermediatesdir, "shared", "sugar-bundles")
+ if not os.path.exists(bundlesdir):
+ os.makedirs(bundlesdir)
+ ln_or_cp(path, bundlesdir)
+
diff --git a/lib/shlib.sh b/lib/shlib.sh
index 0d23985..5075154 100644
--- a/lib/shlib.sh
+++ b/lib/shlib.sh
@@ -31,3 +31,21 @@ image_name() {
printf $name_tmpl $(read_buildnr)
}
+# hard link a file, but fall-back on copy if a device boundary is being crossed
+ln_or_cp() {
+ local src=$1
+ local dest=$2
+ local src_dev=$(stat -c "%D" "$src")
+ local dest_dev=$(stat -c "%D" "$dest")
+ if [ "$src_dev" = "$dest_dev" ]; then
+ cp -l "$src" "$dest"
+ else
+ cp "$src" "$dest"
+ fi
+}
+
+install_sugar_bundle() {
+ mkdir -p "$intermediatesdir/shared/sugar-bundles"
+ ln_or_cp "$1" "$intermediatesdir/shared/sugar-bundles"
+}
+