[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

snp, picking any file in package



Hi,

I have trouble to see how this line in snp.conf could be made to work:
OS_FILE file    *

i.e. i want to install all (or a regex of) files in a package.
Any suggestions?



When building a rootfs-image, the filesystem is loop-mounted. The
current code, however, does use loop0 unconditionally. Please find
attached patch to correct this.

When perusing a binary of busybox, the list of supported applets in
busybox is not correct because the list of applets available through
busybox is hard-coded. Attached is a proposal which looks at the
actual applets the busybox installed in the image supports, tries to
lookup the paths in the host image and puts applets which are not found
in the host image into /sbin.

Thank you.
diff -X ../excl -rup upstream/emdebsys/snp/snp.py ./emdebsys/snp/snp.py
--- upstream/emdebsys/snp/snp.py	2002-02-21 19:35:26.000000000 +0100
+++ ./emdebsys/snp/snp.py	2005-01-04 11:00:58.000000000 +0100
@@ -38,6 +38,7 @@ import shutil
 import glob
 import tempfile
 import types
+import commands
 from UserDict import UserDict
 from types import *
 
@@ -1118,6 +1120,21 @@ class Sources_List:
             print d.path_package[b].name
 
     # ---------------------------------------------------------------------
+    # 
+    def get_free_loopdevice(self):
+        """ get first free loopdevice """
+        _start, _end, _found=(0, 7, -1)
+        for lo in range(_start, _end):
+            _dev="/dev/loop%d" %(lo)
+            stat,out=commands.getstatusoutput("losetup %s 2>&1 >& /dev/null" % \
+                                              (_dev))
+            if stat == 256:
+                _found = lo
+                break
+        return _found
+
+
+    # ---------------------------------------------------------------------
     # TODO: this need some cleanup (lesser warning to stdout/stderr)
     #       but it's working :-)
     def build_rootfs_image(s):
@@ -1128,7 +1145,12 @@ class Sources_List:
         doit("(cd %s ; tar czf %s .)" % (Options.rootfs_dir,
                                          Options.rootfs_tgz))
 
-        loop          = "/dev/loop0"
+        loopdevnum    = s.get_free_loopdevice()
+	if loopdevnum == -1:
+	    Log("Cannot find free loopdevice", Log.ERROR)
+	    sys.exit(1)
+        loop          = "/dev/loop%d" %(loopdevnum)
+	Log("Using loopdevice %s" %loop, Log.INFO)
         rootfs_mnt    = tempfile.mktemp(".img") # Temporary mount...
 
         doit("dd if=/dev/zero of=%s bs=1024 count=%d" % \

diff -X ../excl -rup upstream/emdebsys/scripts/OS_BUSYBOX ./emdebsys/scripts/OS_BUSYBOX
--- upstream/emdebsys/scripts/OS_BUSYBOX	2002-01-10 14:57:20.000000000 +0100
+++ emdebsys/scripts/OS_BUSYBOX	2005-01-04 18:20:46.000000000 +0100
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 
 import os,sys,string
+import commands
 
 # taken from the busybox tgz (busybox.links)
 links = [
@@ -98,6 +99,37 @@ rootfs = os.environ["OS_ROOTFS"]
 bin=rootfs + "/bin"
 os.chdir(bin)
 
+binpath = os.environ["PATH"].split(":")
+links = []
+_bins = {}
+
+def printpath(arg, dirname, names):
+  for f in names:
+      if arg.has_key(f):
+        fil = "%s/%s"%(dirname,f)
+        if os.path.isfile(fil):
+#         print "pick '%s'"%(fil)
+          arg[f]=fil
+
+stat,out=commands.getstatusoutput("%s/busybox 2>&1 | awk '{if(/^Curr/){i=1;};if(((i>0)&&(!/^Currently/))&&(!/^$/)){print}}'"%(bin))
+
+for l in out.split(","):
+    _bins[[l.strip()][0]]=None
+
+for d in binpath:
+    if d.startswith("~"): continue
+#   print "Searching in: %s"%(d)
+    os.path.walk(d, printpath, _bins)
+
+for key, value in _bins.iteritems():
+    if value == None:
+        _bins[key] = "/sbin/%s"%(key)
+#       print "substituting '%s'"%(_bins[key])
+
+links=_bins.values()
+#print "Using: %s"%(links)
+
+
 for l in links:
     link = ".." + l
     dir=os.path.dirname(link)

Reply to: