From 4bf82b48032ee908a5dd3ec02ae0e14d751d3d4ca9fb7a6fe8625192858b8531 Mon Sep 17 00:00:00 2001 From: Robert Schweikert Date: Wed, 20 Nov 2019 14:47:21 +0000 Subject: [PATCH] Accepting request 749936 from home:rjschwei:branches:Cloud:Tools - Clean growpart.spec: * Drop obsolete tags * Use install instead of mkdir+cp+chmod * Fix build on SLE 12 SP4 - Replaced hardcoded systemd paths with macros in spec file - Reference entry for maintenance Tracker bug for the submission set to: bsc#1154357 - Deleted rootgrow source and sub-package build rootgrow is provided on github: https://github.com/SUSE-Enceladus/rootgrow and builds a standalone package now OBS-URL: https://build.opensuse.org/request/show/749936 OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/growpart?expand=0&rev=17 --- growpart.changes | 28 ++++++++++++++++ growpart.spec | 50 +++------------------------- rootgrow | 87 ------------------------------------------------ rootgrow.service | 11 ------ 4 files changed, 33 insertions(+), 143 deletions(-) delete mode 100644 rootgrow delete mode 100644 rootgrow.service diff --git a/growpart.changes b/growpart.changes index b88ef31..3751e99 100644 --- a/growpart.changes +++ b/growpart.changes @@ -1,3 +1,31 @@ +------------------------------------------------------------------- +Tue Oct 29 14:17:46 UTC 2019 - Fabian Vogt + +- Clean growpart.spec: + * Drop obsolete tags + * Use install instead of mkdir+cp+chmod + * Fix build on SLE 12 SP4 + +------------------------------------------------------------------- +Fri Oct 25 14:21:20 UTC 2019 - Ignaz Forster + +- Replaced hardcoded systemd paths with macros in spec file + +------------------------------------------------------------------- +Thu Oct 24 12:40:11 UTC 2019 - Marcus Schaefer + +- Reference entry for maintenance + + Tracker bug for the submission set to: bsc#1154357 + +------------------------------------------------------------------- +Thu Oct 17 14:04:18 UTC 2019 - Marcus Schaefer + +- Deleted rootgrow source and sub-package build + + rootgrow is provided on github: https://github.com/SUSE-Enceladus/rootgrow + and builds a standalone package now + ------------------------------------------------------------------- Wed Jun 12 15:07:49 UTC 2019 - Dominique Leuenberger diff --git a/growpart.spec b/growpart.spec index 0de7555..ddd3669 100644 --- a/growpart.spec +++ b/growpart.spec @@ -1,7 +1,7 @@ # # spec file for package growpart # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -25,13 +25,9 @@ License: GPL-3.0-only Group: System/Management Url: http://launchpad.net/cloud-utils Source0: cloud-utils-%{base_version}.tar.gz -Source1: rootgrow -Source2: rootgrow.service Patch: licenseGPLv3.patch Requires: util-linux -%if 0%{?suse_version} && 0%{?suse_version} > 1220 Requires: gptfdisk -%endif BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildArch: noarch @@ -40,43 +36,14 @@ Grow a partition. This is predominantly useful in the cloud when an instance is started with a larger root partition than the image size. The root partition can be expanded to take up the additional size. -%if 0%{?suse_version} && 0%{?suse_version} > 1220 -%package rootgrow -Version: 1.0.0 -Release: 0 -Summary: Resize root partition -Group: System/Management -Requires: growpart -Requires: python3 -Requires: systemd -# pkg-config is needed to find correct systemd unit dir -BuildRequires: pkg-config -BuildRequires: pkgconfig(systemd) - -%description rootgrow -Provides as script and service togrow the root partition -%endif - %prep -%setup -q -n cloud-utils-%{base_version} -%patch -p1 +%autosetup -p1 -n cloud-utils-%{base_version} %build %install -mkdir -p %{buildroot}/%{_mandir}/man1 -mkdir -p %{buildroot}/%{_sbindir} -cp bin/growpart %{buildroot}/%{_sbindir} -cp man/growpart.1 %{buildroot}/%{_mandir}/man1 -%if 0%{?suse_version} && 0%{?suse_version} > 1220 -mkdir -p %{buildroot}/usr/lib/systemd/system -cp %SOURCE1 %{buildroot}/%{_sbindir} -cp %SOURCE2 %{buildroot}/usr/lib/systemd/system -chmod 755 %{buildroot}/%{_sbindir}/rootgrow -%endif - -%clean -rm -rf $RPM_BUILD_ROOT +install -Dm0755 -t %{buildroot}%{_sbindir} bin/growpart +install -Dm0644 -t %{buildroot}%{_mandir}/man1 man/growpart.1 %files %defattr(-,root,root,-) @@ -84,11 +51,4 @@ rm -rf $RPM_BUILD_ROOT %{_sbindir}/growpart %{_mandir}/man1/* -%if 0%{?suse_version} && 0%{?suse_version} > 1220 -%files rootgrow -%defattr(-,root,root,-) -%{_sbindir}/rootgrow -/usr/lib/systemd/system/rootgrow.service -%endif - %changelog diff --git a/rootgrow b/rootgrow deleted file mode 100644 index eda6e6a..0000000 --- a/rootgrow +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/python3 -import os -import re -import syslog - -split_dev = re.compile('([a-z/]*)(\d*)') -mounts = open('/proc/mounts' ,'r').readlines() - -def get_mount_point(device): - for mount in mounts: - if mount.startswith(device): - return mount.split(' ')[1] - -def is_mount_read_only(mountpoint): - for mount in mounts: - mount_values = mount.split(' ') - if mount_values[1] == mountpoint: - mount_opts = mount_values[3].split(',') - return 'ro' in mount_opts - -def resize_fs(fs_type, device): - if fs_type.startswith('ext'): - cmd = 'resize2fs %s' % device - syslog.syslog( - syslog.LOG_INFO, - 'Resizing: "%s"' %cmd - ) - os.system(cmd) - elif fs_type == 'xfs': - mnt_point = get_mount_point(device) - cmd = 'xfs_growfs %s' % mnt_point - syslog.syslog( - syslog.LOG_INFO, - 'Resizing: "%s"' %cmd - ) - os.system(cmd) - elif fs_type == 'btrfs': - mnt_point = get_mount_point(device) - # If the volume is read-only, the resize operation will fail even - # though it's still probably wanted to do the resize. A feasible - # work-around is to use snapper's .snapshots subdir (if exists) - # instead of the volume path for the resize operation. - if is_mount_read_only(mnt_point): - if os.path.isdir('{}/.snapshots'.format(mnt_point)): - cmd = 'btrfs filesystem resize max {}/.snapshots'.format( - mnt_point) - else: - syslog.syslog( - syslog.LOG_ERR, - "cannot resize read-only btrfs without snapshots" - ) - return - else: - cmd = 'btrfs filesystem resize max {}'.format(mnt_point) - syslog.syslog( - syslog.LOG_INFO, - 'Resizing: "%s"' %cmd - ) - os.system(cmd) - - -for mount in mounts: - if ' / ' in mount: - mount_dev = mount.split(' ')[0] - fs = mount.split(' ')[2] - try: - dev, partition = split_dev.match(mount_dev).groups() - except: - syslog.syslog( - syslog.LOG_ERR, - 'match exception for "%s"' % mount - ) - break - if dev and partition: - cmd = '/usr/sbin/growpart %s %s' %(dev, partition) - syslog.syslog( - syslog.LOG_INFO, - 'Executing: "%s"' % cmd - ) - os.system(cmd) - resize_fs(fs, mount_dev) - else: - syslog.syslog( - syslog.LOG_ERR, - 'could not match device and partition in "%s"' % mount - ) - diff --git a/rootgrow.service b/rootgrow.service deleted file mode 100644 index 23c62f9..0000000 --- a/rootgrow.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Grow the root partition -After=local-fs.target -Wants=local-fs.target - -[Service] -ExecStart=/usr/sbin/rootgrow -Type=oneshot - -[Install] -WantedBy=multi-user.target