Accepting request 749938 from Cloud:Tools

OBS-URL: https://build.opensuse.org/request/show/749938
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/growpart?expand=0&rev=8
This commit is contained in:
Dominique Leuenberger 2019-12-02 10:27:10 +00:00 committed by Git OBS Bridge
commit a9bf798fc6
4 changed files with 33 additions and 143 deletions

View File

@ -1,3 +1,31 @@
-------------------------------------------------------------------
Tue Oct 29 14:17:46 UTC 2019 - Fabian Vogt <fvogt@suse.com>
- 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 <iforster@suse.com>
- Replaced hardcoded systemd paths with macros in spec file
-------------------------------------------------------------------
Thu Oct 24 12:40:11 UTC 2019 - Marcus Schaefer <ms@suse.com>
- Reference entry for maintenance
Tracker bug for the submission set to: bsc#1154357
-------------------------------------------------------------------
Thu Oct 17 14:04:18 UTC 2019 - Marcus Schaefer <ms@suse.com>
- 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 <dimstar@opensuse.org>

View File

@ -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

View File

@ -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
)

View File

@ -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