All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] package_deb: create md5sums control files
@ 2009-08-17 19:21 Michael Smith
  2009-08-31 16:38 ` Michael Smith
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Smith @ 2009-08-17 19:21 UTC (permalink / raw)
  To: openembedded-devel

These are created with the package and get installed in
/var/dpkg/info. Afterward it's a great way to find modified files
for backup with a little shell script magic.

It feels a bit weird to still use MD5, but that seems to be the
convention in the Debian world.

Signed-off-by: Michael Smith <msmith@cbnco.com>
---
 classes/package.bbclass     |   45 +++++++++++++++++++++++++++++++++++++++++++
 classes/package_deb.bbclass |    7 ++++++
 2 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/classes/package.bbclass b/classes/package.bbclass
index f6bd7c5..e3f55b5 100644
--- a/classes/package.bbclass
+++ b/classes/package.bbclass
@@ -202,6 +202,51 @@ def runstrip(file, d):
 
     return 1
 
+def write_package_md5sums (root, outfile, ignorepaths):
+    # For each regular file under root, writes an md5sum to outfile.
+    # With thanks to patch.bbclass.
+    import bb, os
+
+    try:
+        # Python 2.5+
+        import hashlib
+        ctor = hashlib.md5
+    except ImportError:
+        import md5
+        ctor = md5.new
+
+    outf = file(outfile, 'w')
+
+    # Each output line looks like: "<hex...>  <filename without leading slash>"
+    striplen = len(root)
+    if not root.endswith('/'):
+        striplen += 1
+
+    for walkroot, dirs, files in os.walk(root):
+        # Skip e.g. the DEBIAN directory
+        if walkroot[striplen:] in ignorepaths:
+            dirs[:] = []
+            continue
+
+        for name in files:
+            fullpath = os.path.join(walkroot, name)
+            if os.path.islink(fullpath) or (not os.path.isfile(fullpath)):
+                continue
+
+            m = ctor()
+            f = file(fullpath, 'rb')
+            while True:
+                d = f.read(8192)
+                if not d:
+                    break
+                m.update(d)
+            f.close()
+
+            print >> outf, "%s  %s" % (m.hexdigest(), fullpath[striplen:])
+            
+    outf.close()
+
+
 #
 # Package data handling routines
 #
diff --git a/classes/package_deb.bbclass b/classes/package_deb.bbclass
index e5339a9..4a17010 100644
--- a/classes/package_deb.bbclass
+++ b/classes/package_deb.bbclass
@@ -243,6 +243,13 @@ python do_package_deb () {
                 conffiles.write('%s\n' % f)
             conffiles.close()
 
+        try:
+            write_package_md5sums(root, os.path.join(controldir, 'md5sums'),
+                                  ['DEBIAN'])
+        except:
+            bb.utils.unlockfile(lf)
+            raise
+
         os.chdir(basedir)
         ret = os.system("PATH=\"%s\" fakeroot dpkg-deb -b %s %s" % (bb.data.getVar("PATH", localdata, 1), root, pkgoutdir))
         if ret != 0:
-- 
1.6.3




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] package_deb: create md5sums control files
  2009-08-17 19:21 [PATCH] package_deb: create md5sums control files Michael Smith
@ 2009-08-31 16:38 ` Michael Smith
  2009-08-31 17:00   ` Chris Larson
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Smith @ 2009-08-31 16:38 UTC (permalink / raw)
  To: openembedded-devel

OK to commit?

Mike

Michael Smith wrote:
> These are created with the package and get installed in
> /var/dpkg/info. Afterward it's a great way to find modified files
> for backup with a little shell script magic.
> 
> It feels a bit weird to still use MD5, but that seems to be the
> convention in the Debian world.
> 
> Signed-off-by: Michael Smith <msmith at cbnco.com>
> ---
>  classes/package.bbclass     |   45 +++++++++++++++++++++++++++++++++++++++++++
>  classes/package_deb.bbclass |    7 ++++++
>  2 files changed, 52 insertions(+), 0 deletions(-)
> 
> diff --git a/classes/package.bbclass b/classes/package.bbclass
> index f6bd7c5..e3f55b5 100644
> --- a/classes/package.bbclass
> +++ b/classes/package.bbclass
> @@ -202,6 +202,51 @@ def runstrip(file, d):
>  
>      return 1
>  
> +def write_package_md5sums (root, outfile, ignorepaths):
> +    # For each regular file under root, writes an md5sum to outfile.
> +    # With thanks to patch.bbclass.
> +    import bb, os
> +
> +    try:
> +        # Python 2.5+
> +        import hashlib
> +        ctor = hashlib.md5
> +    except ImportError:
> +        import md5
> +        ctor = md5.new
> +
> +    outf = file(outfile, 'w')
> +
> +    # Each output line looks like: "<hex...>  <filename without leading slash>"
> +    striplen = len(root)
> +    if not root.endswith('/'):
> +        striplen += 1
> +
> +    for walkroot, dirs, files in os.walk(root):
> +        # Skip e.g. the DEBIAN directory
> +        if walkroot[striplen:] in ignorepaths:
> +            dirs[:] = []
> +            continue
> +
> +        for name in files:
> +            fullpath = os.path.join(walkroot, name)
> +            if os.path.islink(fullpath) or (not os.path.isfile(fullpath)):
> +                continue
> +
> +            m = ctor()
> +            f = file(fullpath, 'rb')
> +            while True:
> +                d = f.read(8192)
> +                if not d:
> +                    break
> +                m.update(d)
> +            f.close()
> +
> +            print >> outf, "%s  %s" % (m.hexdigest(), fullpath[striplen:])
> +            
> +    outf.close()
> +
> +
>  #
>  # Package data handling routines
>  #
> diff --git a/classes/package_deb.bbclass b/classes/package_deb.bbclass
> index e5339a9..4a17010 100644
> --- a/classes/package_deb.bbclass
> +++ b/classes/package_deb.bbclass
> @@ -243,6 +243,13 @@ python do_package_deb () {
>                  conffiles.write('%s\n' % f)
>              conffiles.close()
>  
> +        try:
> +            write_package_md5sums(root, os.path.join(controldir, 'md5sums'),
> +                                  ['DEBIAN'])
> +        except:
> +            bb.utils.unlockfile(lf)
> +            raise
> +
>          os.chdir(basedir)
>          ret = os.system("PATH=\"%s\" fakeroot dpkg-deb -b %s %s" % (bb.data.getVar("PATH", localdata, 1), root, pkgoutdir))
>          if ret != 0:




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] package_deb: create md5sums control files
  2009-08-31 16:38 ` Michael Smith
@ 2009-08-31 17:00   ` Chris Larson
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Larson @ 2009-08-31 17:00 UTC (permalink / raw)
  To: openembedded-devel

Looks okay to me.  Not tested, but looks sane. :)

Acked-by: Chris Larson <clarson@kergoth.com>

On Mon, Aug 31, 2009 at 9:38 AM, Michael Smith<msmith@cbnco.com> wrote:
> OK to commit?
>
> Mike
>
> Michael Smith wrote:
>>
>> These are created with the package and get installed in
>> /var/dpkg/info. Afterward it's a great way to find modified files
>> for backup with a little shell script magic.
>>
>> It feels a bit weird to still use MD5, but that seems to be the
>> convention in the Debian world.
>>
>> Signed-off-by: Michael Smith <msmith at cbnco.com>
>> ---
>>  classes/package.bbclass     |   45
>> +++++++++++++++++++++++++++++++++++++++++++
>>  classes/package_deb.bbclass |    7 ++++++
>>  2 files changed, 52 insertions(+), 0 deletions(-)
>>
>> diff --git a/classes/package.bbclass b/classes/package.bbclass
>> index f6bd7c5..e3f55b5 100644
>> --- a/classes/package.bbclass
>> +++ b/classes/package.bbclass
>> @@ -202,6 +202,51 @@ def runstrip(file, d):
>>       return 1
>>  +def write_package_md5sums (root, outfile, ignorepaths):
>> +    # For each regular file under root, writes an md5sum to outfile.
>> +    # With thanks to patch.bbclass.
>> +    import bb, os
>> +
>> +    try:
>> +        # Python 2.5+
>> +        import hashlib
>> +        ctor = hashlib.md5
>> +    except ImportError:
>> +        import md5
>> +        ctor = md5.new
>> +
>> +    outf = file(outfile, 'w')
>> +
>> +    # Each output line looks like: "<hex...>  <filename without leading
>> slash>"
>> +    striplen = len(root)
>> +    if not root.endswith('/'):
>> +        striplen += 1
>> +
>> +    for walkroot, dirs, files in os.walk(root):
>> +        # Skip e.g. the DEBIAN directory
>> +        if walkroot[striplen:] in ignorepaths:
>> +            dirs[:] = []
>> +            continue
>> +
>> +        for name in files:
>> +            fullpath = os.path.join(walkroot, name)
>> +            if os.path.islink(fullpath) or (not
>> os.path.isfile(fullpath)):
>> +                continue
>> +
>> +            m = ctor()
>> +            f = file(fullpath, 'rb')
>> +            while True:
>> +                d = f.read(8192)
>> +                if not d:
>> +                    break
>> +                m.update(d)
>> +            f.close()
>> +
>> +            print >> outf, "%s  %s" % (m.hexdigest(),
>> fullpath[striplen:])
>> +            +    outf.close()
>> +
>> +
>>  #
>>  # Package data handling routines
>>  #
>> diff --git a/classes/package_deb.bbclass b/classes/package_deb.bbclass
>> index e5339a9..4a17010 100644
>> --- a/classes/package_deb.bbclass
>> +++ b/classes/package_deb.bbclass
>> @@ -243,6 +243,13 @@ python do_package_deb () {
>>                 conffiles.write('%s\n' % f)
>>             conffiles.close()
>>  +        try:
>> +            write_package_md5sums(root, os.path.join(controldir,
>> 'md5sums'),
>> +                                  ['DEBIAN'])
>> +        except:
>> +            bb.utils.unlockfile(lf)
>> +            raise
>> +
>>         os.chdir(basedir)
>>         ret = os.system("PATH=\"%s\" fakeroot dpkg-deb -b %s %s" %
>> (bb.data.getVar("PATH", localdata, 1), root, pkgoutdir))
>>         if ret != 0:
>
>
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
>



-- 
Chris Larson
clarson at kergoth dot com
clarson at mvista dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Software Engineer
MontaVista Software, Inc.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-31 17:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-17 19:21 [PATCH] package_deb: create md5sums control files Michael Smith
2009-08-31 16:38 ` Michael Smith
2009-08-31 17:00   ` Chris Larson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.