Update to 011.0 release

- Drop merged patches
This commit is contained in:
Neal Gompa 2020-08-26 23:14:18 -04:00
parent abf1428674
commit 3111388b3b
5 changed files with 9 additions and 197 deletions

1
.gitignore vendored
View File

@ -21,3 +21,4 @@ appliance-tools-004.5.tar.bz2
/appliance-tools-010.0.tar.bz2
/appliance-tools-010.1.tar.bz2
/appliance-tools-010.2.tar.bz2
/appliance-tools-011.0.tar.bz2

View File

@ -1,160 +0,0 @@
From 4d7c81f7b4ff4ca7b2a84632f2f0b89d5af58bbf Mon Sep 17 00:00:00 2001
From: Neal Gompa <ngompa13@gmail.com>
Date: Wed, 26 Aug 2020 20:53:20 -0400
Subject: [PATCH 1/2] Populate fstab(5) and bootloader configuration for Btrfs
subvolumes
In order for an image to be setup fully on boot, we need to populate
fstab(5) configuration and ensure the bootloader has the right
references for where the Btrfs filesystems are located on the disk.
---
appcreate/appliance.py | 46 ++++++++++++++++++++++++++++++++------
appcreate/partitionedfs.py | 15 +++++++++----
2 files changed, 50 insertions(+), 11 deletions(-)
diff --git a/appcreate/appliance.py b/appcreate/appliance.py
index a1a0a67..03d119a 100644
--- a/appcreate/appliance.py
+++ b/appcreate/appliance.py
@@ -76,23 +76,36 @@ class ApplianceImageCreator(ImageCreator):
self.grub2inst_params = []
def _get_fstab(self):
- s = ""
+ f = ""
+ has_btrfs_subvolumes = False
for mp in self.__instloop.mountOrder:
p = None
for p1 in self.__instloop.partitions:
+ if p1['fstype'] == "btrfs" and not p1['mountpoint'].startswith('/'):
+ # This btrfs filesystem uses subvolumes
+ has_btrfs_subvolumes = True
if p1['mountpoint'] == mp:
p = p1
break
-
+ if p['fstype'] == "btrfs" and not p['mountpoint'].startswith('/'):
+ # There's no mountpoint to export to fstab, so skip
+ continue
if not p['UUID'] is None:
- mountdev = p['UUID']
+ mountdev = "UUID=%s" % p['UUID']
else:
mountdev = "LABEL=_%s" % p['mountpoint']
- s += "%(mountdev)s %(mountpoint)s %(fstype)s defaults,noatime 0 0\n" % {
+ f += "%(mountdev)s %(mountpoint)s %(fstype)s defaults,noatime 0 0\n" % {
'mountdev': mountdev,
'mountpoint': p['mountpoint'],
'fstype': p['fstype'] }
- return s
+ if has_btrfs_subvolumes:
+ for s in self.__instloop.subvolumes:
+ f += "%(mountdev)s %(mountpoint)s %(fstype)s subvol=%(name)s,noatime 0 0\n" % {
+ 'mountdev': "UUID=%s" % s['UUID'],
+ 'mountpoint': s['mountpoint'],
+ 'fstype': "btrfs",
+ 'name': s['name'] }
+ return f
def _create_mkinitrd_config(self):
#write to tell which modules to be included in initrd
@@ -282,6 +295,7 @@ class ApplianceImageCreator(ImageCreator):
cfg.close()
def _get_grub_boot_config(self):
+ btrfsboot = False
bootdevnum = None
rootdevnum = None
rootdev = None
@@ -298,8 +312,17 @@ class ApplianceImageCreator(ImageCreator):
else:
rootdev = "LABEL=_/"
+ for s in self.__instloop.subvolumes:
+ if s['mountpoint'] == "/boot":
+ btrfsboot = True
+ bootdevnum = s['num'] - 1
+
+ if s['mountpoint'] == "/":
+ rootdevnum = s['num'] - 1
+ rootdev = s['UUID']
+
prefix = ""
- if bootdevnum == rootdevnum:
+ if bootdevnum == rootdevnum and not btrfsboot:
prefix = "/boot"
return (bootdevnum, rootdevnum, rootdev, prefix)
@@ -343,6 +366,7 @@ class ApplianceImageCreator(ImageCreator):
cfg.close()
def _get_extlinux_boot_config(self):
+ btrfsboot = False
bootdevnum = None
rootdevnum = None
rootdev = None
@@ -358,8 +382,16 @@ class ApplianceImageCreator(ImageCreator):
rootdev = p['UUID']
else:
rootdev = "LABEL=_/"
+ for s in self.__instloop.subvolumes:
+ if s['mountpoint'] == "/boot":
+ btrfsboot = True
+ bootdevnum = s['num'] - 1
+
+ if s['mountpoint'] == "/":
+ rootdevnum = s['num'] - 1
+ rootdev = s['UUID']
prefix = ""
- if bootdevnum == rootdevnum:
+ if bootdevnum == rootdevnum and not btrfsboot:
prefix = "/boot"
return (bootdevnum, rootdevnum, rootdev, prefix)
diff --git a/appcreate/partitionedfs.py b/appcreate/partitionedfs.py
index 50206c4..9e81d2e 100644
--- a/appcreate/partitionedfs.py
+++ b/appcreate/partitionedfs.py
@@ -66,7 +66,12 @@ class PartitionedMount(Mount):
'num': None}) # Partition number
def add_subvolume(self, parent, mountpoint, name):
- self.subvolumes.append({'parent': parent, 'mountpoint': mountpoint, 'name': name})
+ self.subvolumes.append({'parent': parent, # parent location for subvolume
+ 'mountpoint': mountpoint, # Mount relative to chroot
+ 'name': name, # subvolume name
+ 'device': None, # kpartx device node for partition
+ 'UUID': None, # UUID for partition
+ 'num': None}) # Partition number
def __format_disks(self):
logging.debug("Formatting disks")
@@ -299,11 +304,14 @@ class PartitionedMount(Mount):
others = []
ordered = []
for s in self.subvolumes:
+ s['device'] = subprocess.Popen(["findmnt", "-n", "-o", "SOURCE", "%s%s" % (self.mountdir, s['parent'])], stdout=subprocess.PIPE).communicate()[0].decode("utf-8").strip()
+ s['UUID'] = self.__getuuid(s['device'])
+ s['num'] = int(s['device'].rsplit('p', 1)[1])
if s['mountpoint'] == '/':
ordered.append(s)
else:
others.append(s)
-
+
ordered += others
for s in ordered:
base = "%s%s" % (self.mountdir, s['parent'])
@@ -313,8 +321,7 @@ class PartitionedMount(Mount):
subprocess.call(['btrfs', 'subvol', 'create', path])
subprocess.call(['mkdir', '-p', mountpath])
logging.debug("Mounting Btrfs subvolume %s at path %s" % (s['name'], mountpath))
- device = subprocess.Popen(["findmnt", "-n", "-o", "SOURCE", base], stdout=subprocess.PIPE).communicate()[0].decode("utf-8").strip()
- subprocess.call(['mount', '-t', 'btrfs', '-o', 'subvol=%s' % s['name'], device, mountpath])
+ subprocess.call(['mount', '-t', 'btrfs', '-o', 'subvol=%s' % s['name'], s['device'], mountpath])
def mount(self):
for dev in list(self.disks.keys()):
--
2.26.2

View File

@ -1,29 +0,0 @@
From 18f0b3a4712823cf90c4af7541f678a69ca53adb Mon Sep 17 00:00:00 2001
From: Neal Gompa <ngompa13@gmail.com>
Date: Wed, 26 Aug 2020 21:10:30 -0400
Subject: [PATCH 2/2] appcreate/partitionedfs: Ensure __getuuid() actually gets
the UUID
With Btrfs, UUID and UUID_SUB are both provided by blkid(8). In order
for the right value to be selected, we need to be a tiny bit stricter to
ensure we get the right UUID value.
---
appcreate/partitionedfs.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/appcreate/partitionedfs.py b/appcreate/partitionedfs.py
index 9e81d2e..1e9fdde 100644
--- a/appcreate/partitionedfs.py
+++ b/appcreate/partitionedfs.py
@@ -398,7 +398,7 @@ class PartitionedMount(Mount):
devdata = subprocess.Popen(["/sbin/blkid", partition], stdout=subprocess.PIPE)
devdataout = devdata.communicate()[0].decode("utf-8").split()
for data in devdataout:
- if data.startswith("UUID"):
+ if data.startswith("UUID="):
UUID = data.replace('"', '')
continue
return UUID
--
2.26.2

View File

@ -20,17 +20,13 @@
Name: appliance-tools
Summary: Tools for building Appliances
Version: 010.2
Release: 3%{?dist}
Version: 011.0
Release: 1%{?dist}
License: GPLv2
URL: https://pagure.io/appliance-tools
Source0: https://releases.pagure.org/%{name}/%{name}-%{version}.tar.bz2
# Patches proposed to fix rhbz#1855034
Patch0001: 0001-Populate-fstab-5-and-bootloader-configuration-for-Bt.patch
Patch0002: 0002-appcreate-partitionedfs-Ensure-__getuuid-actually-ge.patch
# Ensure system deps are installed (rhbz#1409536)
Requires: python%{python_pkgversion}-imgcreate %{?min_imgcrate_evr:>= %{min_imgcreate_evr}}
Requires: python%{python_pkgversion}-progress
@ -77,7 +73,11 @@ rm -rf %{buildroot}%{_datadir}/doc/%{name}
%{python_sitelib}/ec2convert/
%changelog
* Wed Aug 26 2020 Neal Gompa <ngompa13@gmail.com> - 010-2-3
* Wed Aug 26 2020 Neal Gompa <ngompa13@gmail.com> - 011.0-1
- Update to 011.0 release
- Drop merged patches
* Wed Aug 26 2020 Neal Gompa <ngompa13@gmail.com> - 010.2-3
- Refresh patches for fixing bootloader config for btrfs
* Wed Aug 26 2020 Neal Gompa <ngompa13@gmail.com> - 010.2-2

View File

@ -1 +1 @@
SHA512 (appliance-tools-010.2.tar.bz2) = 462d7beea51cb5e2e79a09a687d62d769cf9535f984835fa8502bd5c93af915115899994f1870bb89a7973abc7898e081d8451b887d9e22074b7ae4846b2f146
SHA512 (appliance-tools-011.0.tar.bz2) = d8d63175c54e5e057fdce1d30937dffc2a21f06ad10686ea0e44125266285d7b624177eba0da7620432e76b06292794a72ef2f25963e1a85e580edaae0d37de9