added my Recipes
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
From 713cf821ebe17f9e1771502a85e0905ea04dafae Mon Sep 17 00:00:00 2001
|
||||
From: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
Date: Fri, 23 Nov 2018 17:03:58 +0800
|
||||
Subject: [PATCH 02/11] run_program support timeout
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
---
|
||||
blivet/util.py | 70 ++++++++++++++++++++++++++++++++++------------------------
|
||||
1 file changed, 41 insertions(+), 29 deletions(-)
|
||||
|
||||
diff --git a/blivet/util.py b/blivet/util.py
|
||||
index 4eac8b9..4f05076 100644
|
||||
--- a/blivet/util.py
|
||||
+++ b/blivet/util.py
|
||||
@@ -158,6 +158,30 @@ class Path(str):
|
||||
def __hash__(self):
|
||||
return self._path.__hash__()
|
||||
|
||||
+def timeout_command(argv, timeout, *args, **kwargs):
|
||||
+ """call shell-command and either return its output or kill it
|
||||
+ if it doesn't normally exit within timeout seconds and return None"""
|
||||
+ import subprocess, datetime, os, time, signal
|
||||
+ start = datetime.datetime.now()
|
||||
+
|
||||
+ try:
|
||||
+ proc = subprocess.Popen(argv, *args, **kwargs)
|
||||
+ while proc.poll() is None:
|
||||
+ time.sleep(0.1)
|
||||
+ now = datetime.datetime.now()
|
||||
+ if (now - start).seconds> timeout:
|
||||
+ os.kill(proc.pid, signal.SIGKILL)
|
||||
+ os.waitpid(-1, os.WNOHANG)
|
||||
+ program_log.debug("%d seconds timeout" % timeout)
|
||||
+ return (-1, None)
|
||||
+
|
||||
+
|
||||
+ except OSError as e:
|
||||
+ program_log.error("Error running %s: %s", argv[0], e.strerror)
|
||||
+ raise
|
||||
+
|
||||
+ program_log.debug("Return code: %d", proc.returncode)
|
||||
+ return (proc.returncode, proc.stdout.read())
|
||||
|
||||
def _run_program(argv, root='/', stdin=None, env_prune=None, stderr_to_stdout=False, binary_output=False):
|
||||
if env_prune is None:
|
||||
@@ -180,35 +204,23 @@ def _run_program(argv, root='/', stdin=None, env_prune=None, stderr_to_stdout=Fa
|
||||
stderr_dir = subprocess.STDOUT
|
||||
else:
|
||||
stderr_dir = subprocess.PIPE
|
||||
- try:
|
||||
- proc = subprocess.Popen(argv, # pylint: disable=subprocess-popen-preexec-fn
|
||||
- stdin=stdin,
|
||||
- stdout=subprocess.PIPE,
|
||||
- stderr=stderr_dir,
|
||||
- close_fds=True,
|
||||
- preexec_fn=chroot, cwd=root, env=env)
|
||||
-
|
||||
- out, err = proc.communicate()
|
||||
- if not binary_output and six.PY3:
|
||||
- out = out.decode("utf-8")
|
||||
- if out:
|
||||
- if not stderr_to_stdout:
|
||||
- program_log.info("stdout:")
|
||||
- for line in out.splitlines():
|
||||
- program_log.info("%s", line)
|
||||
-
|
||||
- if not stderr_to_stdout and err:
|
||||
- program_log.info("stderr:")
|
||||
- for line in err.splitlines():
|
||||
- program_log.info("%s", line)
|
||||
-
|
||||
- except OSError as e:
|
||||
- program_log.error("Error running %s: %s", argv[0], e.strerror)
|
||||
- raise
|
||||
-
|
||||
- program_log.debug("Return code: %d", proc.returncode)
|
||||
-
|
||||
- return (proc.returncode, out)
|
||||
+
|
||||
+ res, out = timeout_command(argv, 10,
|
||||
+ stdin=stdin,
|
||||
+ stdout=subprocess.PIPE,
|
||||
+ stderr=stderr_dir,
|
||||
+ close_fds=True,
|
||||
+ preexec_fn=chroot, cwd=root, env=env)
|
||||
+ if not binary_output and six.PY3:
|
||||
+ out = out.decode("utf-8")
|
||||
+ if out:
|
||||
+ if not stderr_to_stdout:
|
||||
+ program_log.info("stdout:")
|
||||
+ for line in out.splitlines():
|
||||
+ program_log.info("%s", line)
|
||||
+
|
||||
+ return (res, out)
|
||||
+
|
||||
|
||||
|
||||
def run_program(*args, **kwargs):
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
From 5d5436dfa3bdde7b4e87ce5a40cbc724199847d6 Mon Sep 17 00:00:00 2001
|
||||
From: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
Date: Mon, 8 May 2017 16:18:02 +0800
|
||||
Subject: [PATCH 03/11] support infinit timeout
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
---
|
||||
blivet/util.py | 12 ++++++++----
|
||||
1 file changed, 8 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/blivet/util.py b/blivet/util.py
|
||||
index 4f05076..7e89949 100644
|
||||
--- a/blivet/util.py
|
||||
+++ b/blivet/util.py
|
||||
@@ -158,6 +158,7 @@ class Path(str):
|
||||
def __hash__(self):
|
||||
return self._path.__hash__()
|
||||
|
||||
+# timeout = -1 means infinite timeout, always wait.
|
||||
def timeout_command(argv, timeout, *args, **kwargs):
|
||||
"""call shell-command and either return its output or kill it
|
||||
if it doesn't normally exit within timeout seconds and return None"""
|
||||
@@ -169,7 +170,7 @@ def timeout_command(argv, timeout, *args, **kwargs):
|
||||
while proc.poll() is None:
|
||||
time.sleep(0.1)
|
||||
now = datetime.datetime.now()
|
||||
- if (now - start).seconds> timeout:
|
||||
+ if timeout != -1 and (now - start).seconds> timeout:
|
||||
os.kill(proc.pid, signal.SIGKILL)
|
||||
os.waitpid(-1, os.WNOHANG)
|
||||
program_log.debug("%d seconds timeout" % timeout)
|
||||
@@ -183,7 +184,7 @@ def timeout_command(argv, timeout, *args, **kwargs):
|
||||
program_log.debug("Return code: %d", proc.returncode)
|
||||
return (proc.returncode, proc.stdout.read())
|
||||
|
||||
-def _run_program(argv, root='/', stdin=None, env_prune=None, stderr_to_stdout=False, binary_output=False):
|
||||
+def _run_program(argv, root='/', stdin=None, env_prune=None, stderr_to_stdout=False, binary_output=False, timeout=10):
|
||||
if env_prune is None:
|
||||
env_prune = []
|
||||
|
||||
@@ -192,7 +193,10 @@ def _run_program(argv, root='/', stdin=None, env_prune=None, stderr_to_stdout=Fa
|
||||
os.chroot(root)
|
||||
|
||||
with program_log_lock: # pylint: disable=not-context-manager
|
||||
- program_log.info("Running... %s", " ".join(argv))
|
||||
+ if timeout != -1:
|
||||
+ program_log.info("Running... %s", " ".join(argv))
|
||||
+ else:
|
||||
+ program_log.info("Running... %s ...infinite timeout", " ".join(argv))
|
||||
|
||||
env = os.environ.copy()
|
||||
env.update({"LC_ALL": "C",
|
||||
@@ -205,7 +209,7 @@ def _run_program(argv, root='/', stdin=None, env_prune=None, stderr_to_stdout=Fa
|
||||
else:
|
||||
stderr_dir = subprocess.PIPE
|
||||
|
||||
- res, out = timeout_command(argv, 10,
|
||||
+ res, out = timeout_command(argv, timeout,
|
||||
stdin=stdin,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=stderr_dir,
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
From 3bb8d08bdec2f79bb13c0a44b81718d26e5bdabc Mon Sep 17 00:00:00 2001
|
||||
From: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
Date: Mon, 8 May 2017 16:30:20 +0800
|
||||
Subject: [PATCH 04/11] fix new.roots object is not iterable
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
---
|
||||
blivet/blivet.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/blivet/blivet.py b/blivet/blivet.py
|
||||
index ea08837..91c92b2 100644
|
||||
--- a/blivet/blivet.py
|
||||
+++ b/blivet/blivet.py
|
||||
@@ -1206,7 +1206,7 @@ class Blivet(object):
|
||||
p = partition.disk.format.parted_disk.getPartitionByPath(partition.path)
|
||||
partition.parted_partition = p
|
||||
|
||||
- for root in new.roots:
|
||||
+ for root in new.roots or []:
|
||||
root.swaps = [new.devicetree.get_device_by_id(d.id, hidden=True) for d in root.swaps]
|
||||
root.swaps = [s for s in root.swaps if s]
|
||||
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
From f783b9b00da5df176fcd7927b752f574ca6db319 Mon Sep 17 00:00:00 2001
|
||||
From: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
Date: Fri, 26 Aug 2016 02:02:49 -0400
|
||||
Subject: [PATCH 05/11] fix incorrect timeout while system time changed
|
||||
|
||||
While system time changed by NTP, invoking timeout_command
|
||||
breaks with incorrect timeout.
|
||||
--------
|
||||
|05:40:55,872 INFO program: Running... mount -t ext2 -o
|
||||
defaults,ro /dev/sda2 /mnt/sysimage
|
||||
|01:40:55,086 DEBUG program: 10 seconds timeout
|
||||
--------
|
||||
|
||||
Use numbert count to replace current time count could workaround
|
||||
the issue.
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
---
|
||||
blivet/util.py | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/blivet/util.py b/blivet/util.py
|
||||
index 7e89949..5571e73 100644
|
||||
--- a/blivet/util.py
|
||||
+++ b/blivet/util.py
|
||||
@@ -163,14 +163,14 @@ def timeout_command(argv, timeout, *args, **kwargs):
|
||||
"""call shell-command and either return its output or kill it
|
||||
if it doesn't normally exit within timeout seconds and return None"""
|
||||
import subprocess, datetime, os, time, signal
|
||||
- start = datetime.datetime.now()
|
||||
+ count = 0
|
||||
|
||||
try:
|
||||
proc = subprocess.Popen(argv, *args, **kwargs)
|
||||
while proc.poll() is None:
|
||||
time.sleep(0.1)
|
||||
- now = datetime.datetime.now()
|
||||
- if timeout != -1 and (now - start).seconds> timeout:
|
||||
+ count += 1
|
||||
+ if timeout != -1 and count > timeout*10:
|
||||
os.kill(proc.pid, signal.SIGKILL)
|
||||
os.waitpid(-1, os.WNOHANG)
|
||||
program_log.debug("%d seconds timeout" % timeout)
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
From 8932ae933f2b6acf5e98c9956beff69ae430eed2 Mon Sep 17 00:00:00 2001
|
||||
From: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
Date: Mon, 8 May 2017 16:33:15 +0800
|
||||
Subject: [PATCH 06/11] tweak btrfs packages
|
||||
|
||||
In oe-cre/yocto, we name btrfs package with btrfs-tools,
|
||||
rather than btrfs-progs.
|
||||
|
||||
Upstream-Status: Inappropriate [oe specific]
|
||||
|
||||
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
---
|
||||
blivet/devices/btrfs.py | 2 +-
|
||||
blivet/formats/fs.py | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/blivet/devices/btrfs.py b/blivet/devices/btrfs.py
|
||||
index cada940..7e4d4b8 100644
|
||||
--- a/blivet/devices/btrfs.py
|
||||
+++ b/blivet/devices/btrfs.py
|
||||
@@ -55,7 +55,7 @@ class BTRFSDevice(StorageDevice):
|
||||
|
||||
""" Base class for BTRFS volume and sub-volume devices. """
|
||||
_type = "btrfs"
|
||||
- _packages = ["btrfs-progs"]
|
||||
+ _packages = ["btrfs-tools"]
|
||||
_external_dependencies = [availability.BLOCKDEV_BTRFS_PLUGIN]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
|
||||
index 81e367f..55e5d57 100644
|
||||
--- a/blivet/formats/fs.py
|
||||
+++ b/blivet/formats/fs.py
|
||||
@@ -926,7 +926,7 @@ class BTRFS(FS):
|
||||
_formattable = True
|
||||
_linux_native = True
|
||||
_supported = True
|
||||
- _packages = ["btrfs-progs"]
|
||||
+ _packages = ["btrfs-tools"]
|
||||
_min_size = Size("256 MiB")
|
||||
_max_size = Size("16 EiB")
|
||||
_mkfs_class = fsmkfs.BTRFSMkfs
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
From f53481dc4a56b8a996628733553e080bb0aafdd7 Mon Sep 17 00:00:00 2001
|
||||
From: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
Date: Fri, 23 Nov 2018 17:07:22 +0800
|
||||
Subject: [PATCH 07/11] invoking mount with infinite timeout
|
||||
|
||||
This large timeout is needed when running on machines with
|
||||
lots of disks, or with slow disks.
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
---
|
||||
blivet/util.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/blivet/util.py b/blivet/util.py
|
||||
index 5571e73..02c8033 100644
|
||||
--- a/blivet/util.py
|
||||
+++ b/blivet/util.py
|
||||
@@ -258,7 +258,7 @@ def mount(device, mountpoint, fstype, options=None):
|
||||
makedirs(mountpoint)
|
||||
|
||||
argv = ["mount", "-t", fstype, "-o", options, device, mountpoint]
|
||||
- return run_program(argv)
|
||||
+ return run_program(argv, timeout=-1)
|
||||
|
||||
|
||||
def umount(mountpoint):
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
From 12e2579333258d1a690f8718e91b0f217078e886 Mon Sep 17 00:00:00 2001
|
||||
From: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
Date: Mon, 8 May 2017 03:54:12 -0400
|
||||
Subject: [PATCH 08/11] use oe variable to replace hardcoded dir
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
|
||||
Rebase for python3-blivet 3.4.0.
|
||||
|
||||
Signed-off-by: Kai Kang <kai.kang@windriver.com>
|
||||
---
|
||||
setup.py | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/setup.py b/setup.py
|
||||
index b745a79..b5b4258 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -61,10 +61,10 @@ class blivet_sdist(sdist):
|
||||
|
||||
|
||||
data_files = [
|
||||
- ('/etc/dbus-1/system.d', ['dbus/blivet.conf']),
|
||||
- ('/usr/share/dbus-1/system-services', ['dbus/com.redhat.Blivet0.service']),
|
||||
- ('/usr/libexec', ['dbus/blivetd']),
|
||||
- ('/usr/lib/systemd/system', ['dbus/blivet.service'])
|
||||
+ (os.environ.get('sysconfdir')+'/dbus-1/system.d', ['dbus/blivet.conf']),
|
||||
+ (os.environ.get('datadir')+'/dbus-1/system-services', ['dbus/com.redhat.Blivet0.service']),
|
||||
+ (os.environ.get('libexecdir'), ['dbus/blivetd']),
|
||||
+ (os.environ.get('systemd_system_unitdir'), ['dbus/blivet.service'])
|
||||
]
|
||||
|
||||
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
From 9624b6d0dda40aaecbaf9530be819943575a2ec6 Mon Sep 17 00:00:00 2001
|
||||
From: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
Date: Thu, 1 Jun 2017 16:05:27 +0800
|
||||
Subject: [PATCH 09/11] invoking fsck with infinite timeout
|
||||
|
||||
This large timeout is needed when running on machines with
|
||||
lots of disks, or with slow disks.
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
---
|
||||
blivet/tasks/fsck.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/blivet/tasks/fsck.py b/blivet/tasks/fsck.py
|
||||
index 5274f13..6e074c4 100644
|
||||
--- a/blivet/tasks/fsck.py
|
||||
+++ b/blivet/tasks/fsck.py
|
||||
@@ -77,7 +77,7 @@ class FSCK(task.BasicApplication, fstask.FSTask):
|
||||
raise FSError("\n".join(error_msgs))
|
||||
|
||||
try:
|
||||
- rc = util.run_program(self._fsck_command)
|
||||
+ rc = util.run_program(self._fsck_command, timeout=-1)
|
||||
except OSError as e:
|
||||
raise FSError("filesystem check failed: %s" % e)
|
||||
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
From 33844f6773a676bd57240954e402ae9a843663a4 Mon Sep 17 00:00:00 2001
|
||||
From: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
Date: Fri, 16 Jun 2017 15:43:00 +0800
|
||||
Subject: [PATCH 10/11] invoking mkfs with infinite timeout
|
||||
|
||||
This large timeout is needed when running on machines with
|
||||
lots of disks, or with slow disks.
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
|
||||
Rebase for python3-blivet 3.4.0.
|
||||
|
||||
Signed-off-by: Kai Kang <kai.kang@windriver.com>
|
||||
---
|
||||
blivet/tasks/fsmkfs.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/blivet/tasks/fsmkfs.py b/blivet/tasks/fsmkfs.py
|
||||
index e4a6aaa8..9730f7e5 100644
|
||||
--- a/blivet/tasks/fsmkfs.py
|
||||
+++ b/blivet/tasks/fsmkfs.py
|
||||
@@ -203,7 +203,7 @@ class FSMkfs(task.BasicApplication, FSMkfsTask):
|
||||
options = options or []
|
||||
cmd = self._mkfs_command(options, label, set_uuid, nodiscard)
|
||||
try:
|
||||
- ret = util.run_program(cmd)
|
||||
+ ret = util.run_program(cmd, timeout=-1)
|
||||
except OSError as e:
|
||||
raise FSError(e)
|
||||
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
From 21ca2b859a49e96a230d55a7866dfc7ed5d1366c Mon Sep 17 00:00:00 2001
|
||||
From: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
Date: Tue, 6 Mar 2018 17:28:56 +0800
|
||||
Subject: [PATCH 11/11] invoking dd with infinite timeout
|
||||
|
||||
This large timeout is needed when running on machines with
|
||||
lots of disks, or with slow disks.
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
---
|
||||
blivet/devices/partition.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/blivet/devices/partition.py b/blivet/devices/partition.py
|
||||
index 623e1c9..141d8ad 100644
|
||||
--- a/blivet/devices/partition.py
|
||||
+++ b/blivet/devices/partition.py
|
||||
@@ -618,7 +618,7 @@ class PartitionDevice(StorageDevice):
|
||||
cmd = ["dd", "if=/dev/zero", "of=%s" % device, "bs=%d" % bs,
|
||||
"seek=%d" % start, "count=%d" % count]
|
||||
try:
|
||||
- util.run_program(cmd)
|
||||
+ util.run_program(cmd, timeout=-1)
|
||||
except OSError as e:
|
||||
log.error(str(e))
|
||||
finally:
|
||||
--
|
||||
2.7.4
|
||||
|
||||
Reference in New Issue
Block a user