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

Bug#745839: live-build: runs hooks in arbitrary order, should be ASCII order



Package: live-build
Version: 4.0~alpha33-1
Severity: normal
Tags: patch

live-build appears to be intended to run hooks in ASCII order so that their
numeric prefixes can be used to control ordering. Unfortunately, it actually
runs them in whatever order glob.glob() returns, which is readdir() order,
which is unpredictable (and in particular, not sorted by name) on
several filesystems. This is bad if you have hooks whose order matters.

I've been doing my live builds in a (large!) tmpfs, which has random
readdir() order.

Proposed patch attached.

Regards,
    S

-- Package-specific info:

-- System Information:
Debian Release: jessie/sid
  APT prefers proposed-updates
  APT policy: (500, 'proposed-updates'), (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.13-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages live-build depends on:
ii  cdebootstrap  0.5.10
ii  debootstrap   1.0.59
ii  python3       3.3.4-1

Versions of packages live-build recommends:
ii  cpio                            2.11+dfsg-2
ii  live-boot-doc                   4.0~alpha21-1
ii  live-config-doc                 4.0~alpha32-1
ii  live-manual-html [live-manual]  1:4.0~alpha11-1

live-build suggests no packages.

-- no debconf information
>From 9834b3a27e40743d4384be4756bd41125db16c56 Mon Sep 17 00:00:00 2001
From: Simon McVittie <simon.mcvittie@collabora.co.uk>
Date: Fri, 25 Apr 2014 17:08:20 +0100
Subject: [PATCH] Run hooks in sorted order

glob.glob() returns files in filesystem order, which is unpredictable
on many modern filesystems.
---
 components/binary-hooks    | 2 +-
 components/bootstrap-hooks | 2 +-
 components/chroot-hooks    | 2 +-
 components/source-hooks    | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/components/binary-hooks b/components/binary-hooks
index 3e9cf07..d7bb4d7 100755
--- a/components/binary-hooks
+++ b/components/binary-hooks
@@ -80,7 +80,7 @@ def main():
 
 	hooks = glob.glob('config/hooks/*.hook') + glob.glob('config/hooks/*.hook.binary')
 
-	for hook in hooks:
+	for hook in sorted(hooks):
 		if verbose:
 			print('I: Copying config/hooks/*.hook.binary to binary/live-build')
 
diff --git a/components/bootstrap-hooks b/components/bootstrap-hooks
index e27f1ad..9eaa5ea 100755
--- a/components/bootstrap-hooks
+++ b/components/bootstrap-hooks
@@ -80,7 +80,7 @@ def main():
 
 	hooks = glob.glob('config/hooks/*.hook') + glob.glob('config/hooks/*.hook.bootstrap')
 
-	for hook in hooks:
+	for hook in sorted(hooks):
 		if verbose:
 			print('I: Copying config/hooks/*.hook.bootstrap to chroot/live-build')
 
diff --git a/components/chroot-hooks b/components/chroot-hooks
index ab7bb25..a7a2481 100755
--- a/components/chroot-hooks
+++ b/components/chroot-hooks
@@ -80,7 +80,7 @@ def main():
 
 	hooks = glob.glob('config/hooks/*.hook') + glob.glob('config/hooks/*.hook.chroot')
 
-	for hook in hooks:
+	for hook in sorted(hooks):
 		if verbose:
 			print('I: Copying config/hooks/*.hook.chroot to chroot/live-build')
 
diff --git a/components/source-hooks b/components/source-hooks
index 32be58b..672b53f 100755
--- a/components/source-hooks
+++ b/components/source-hooks
@@ -80,7 +80,7 @@ def main():
 
 	hooks = glob.glob('config/hooks/*.hook') + glob.glob('config/hooks/*.hook.source')
 
-	for hook in hooks:
+	for hook in sorted(hooks):
 		if verbose:
 			print('I: Copying config/hooks/*.hook.source to source/live-build')
 
-- 
2.0.0.rc0


Reply to: