diff --git a/0001-fix-compilation-error.patch b/0001-fix-compilation-error.patch new file mode 100644 index 0000000000000000000000000000000000000000..2efef48890cd770120f9bc892b643481b2e5d440 --- /dev/null +++ b/0001-fix-compilation-error.patch @@ -0,0 +1,57 @@ + lib/events/libdmraid-events-isw.c | 6 +++--- + lib/format/ataraid/jm.c | 4 ++-- + lib/metadata/metadata.c | 2 +- + 3 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/lib/events/libdmraid-events-isw.c b/lib/events/libdmraid-events-isw.c +index c092762..d5efe22 100644 +--- a/lib/events/libdmraid-events-isw.c ++++ b/lib/events/libdmraid-events-isw.c +@@ -824,13 +824,13 @@ static void _log_either(enum log_type log_type, + + sz = _log_all_devs(log_type, rs, NULL, 0); + if (!sz) { +- syslog(LOG_ERR, msg[0]); ++ syslog(LOG_ERR, "%s", msg[0]); + return; + } + + str = dm_malloc(++sz); + if (!str) { +- syslog(LOG_ERR, msg[1]); ++ syslog(LOG_ERR, "%s", msg[1]); + return; + } + +diff --git a/lib/format/ataraid/jm.c b/lib/format/ataraid/jm.c +index 38a5194..6a2c38b 100644 +--- a/lib/format/ataraid/jm.c ++++ b/lib/format/ataraid/jm.c +@@ -33,10 +33,9 @@ name(struct lib_context *lc, struct raid_dev *rd, unsigned int subset) + /* Sanitize name, make sure it's null terminated */ + strncpy(buf, name, JM_NAME_LEN); + i = strlen(buf); +- while (i && isspace(buf[i])) { ++ while (i-- && isspace(buf[i])) { + name[i]='\0'; + buf[i]='\0'; +- --i; + } + + len = strlen(buf) + sizeof(HANDLER) + (jm->mode == JM_T_RAID01 ? 3 : 2); +diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c +index eacdb39..9e219ad 100644 +--- a/lib/metadata/metadata.c ++++ b/lib/metadata/metadata.c +@@ -1433,7 +1433,7 @@ create_raidset(struct lib_context *lc, struct raid_set_descr *rsd) + rd->sectors = 0; + list_add_tail(&rd->devs, &rs->devs); + n++; +- } while (end++ != '\0'); ++ } while (end++ != NULL); + + rs->total_devs = rs->found_devs = n; + rs_tmp = rs; +-- +2.35.1 + diff --git a/anolis-dmraid-activation b/anolis-dmraid-activation new file mode 100644 index 0000000000000000000000000000000000000000..8b1a08b1bd4535dd255966d55edd316a4a649aba --- /dev/null +++ b/anolis-dmraid-activation @@ -0,0 +1,28 @@ +#!/bin/bash +# +# Activation of dmraid sets. +# +. /etc/init.d/functions + +[ -z "${cmdline}" ] && cmdline=$(cat /proc/cmdline) + +if ! strstr "$cmdline" nodmraid && [ -x /sbin/dmraid ]; then + modprobe dm-mirror >/dev/null 2>&1 + dmraidsets=$(LC_ALL=C /sbin/dmraid -s -c -i) + if [ "$?" = "0" ]; then + SAVEIFS=$IFS + IFS=$(echo -en "\n\b") + for dmname in $dmraidsets; do + if [[ "$dmname" == isw_* ]] && \ + ! strstr "$cmdline" noiswmd; then + continue + fi + /sbin/dmraid -ay -i --rm_partitions -p "$dmname" >/dev/null 2>&1 + /sbin/kpartx -u -a "/dev/mapper/$dmname" + done + IFS=$SAVEIFS + # dmraid says "no block devices found" on machines with an eMMC + elif [ "$dmraidsets" = "no raid disks" -o "$dmraidsets" = "no block devices found" ]; then + systemctl disable dmraid-activation.service + fi +fi diff --git a/dmraid-1.0.0.rc16-3.tar.bz2 b/dmraid-1.0.0.rc16-3.tar.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..dd3dfdddbe87d4a02b391bbc7bc0fefad0249f2a Binary files /dev/null and b/dmraid-1.0.0.rc16-3.tar.bz2 differ diff --git a/dmraid-activation.service b/dmraid-activation.service new file mode 100644 index 0000000000000000000000000000000000000000..9494ae7e0eb6f548230c7c05597d8761356d7c81 --- /dev/null +++ b/dmraid-activation.service @@ -0,0 +1,14 @@ +[Unit] +Description=Activation of DM RAID sets +DefaultDependencies=no +Conflicts=shutdown.target +After=systemd-udev-settle.service +Before=lvm2-activation-early.service cryptsetup.target local-fs-pre.target shutdown.target +Wants=systemd-udev-settle.service + +[Service] +ExecStart=/lib/systemd/anolis-dmraid-activation +Type=oneshot + +[Install] +WantedBy=sysinit.target diff --git a/dmraid.spec b/dmraid.spec new file mode 100644 index 0000000000000000000000000000000000000000..dd58812da6ad3afe9f463f208fc551150f4e9a60 --- /dev/null +++ b/dmraid.spec @@ -0,0 +1,172 @@ +%define anolis_release 1 +%define dmraid_release 3 +Summary: Device-mapper RAID tool and library +Name: dmraid +Version: 1.0.0.rc16 +Release: %{anolis_release}%{dist} +License: GPLv2+ +URL: http://people.redhat.com/heinzm/sw/dmraid + +BuildRequires: device-mapper-devel >= 1.02.02 +BuildRequires: device-mapper-event-devel +BuildRequires: libselinux-devel +BuildRequires: libsepol-devel +BuildRequires: systemd-rpm-macros +BuildRequires: gcc +BuildRequires: make +Requires: device-mapper >= 1.02.02 +Requires: dmraid-libs = %{version}-%{release} +Requires: kpartx +Requires: systemd +Requires(post): systemd >= 195 +Recommends: dmraid-events = %{version}-%{release} +# Splitting libraries out to -libs subpackage +Conflicts: dmraid < 1.0.0.rc16 +Obsoletes: dmraid < 1.0.0.rc16 + +# This was:https://people.redhat.com/heinzm/sw/dmraid/src/dmraid-1.0.0.rc16.tar.bz2 +# but that link no longer works +Source0: %{name}-%{version}-%{dmraid_release}.tar.bz2 +Source1: anolis-dmraid-activation +Source2: dmraid-activation.service + +Patch0: 0001-fix-compilation-error.patch + +%description +DMRAID supports RAID device discovery, RAID set activation, creation, +removal, rebuild and display of properties for ATARAID/DDF1 metadata on +Linux >= 2.4 using device-mapper. + +%package -n dmraid-libs +Summary: System libraries for dmraid +# Splitting libraries out to -libs subpackage +Conflicts: dmraid < 1.0.0.rc16 +Obsoletes: dmraid < 1.0.0.rc16 + +%description -n dmraid-libs +dmraid-libs provides the system libraries for RAID device discovery, +RAID set activation and display of properties for ATARAID volumes. + +%package -n dmraid-devel +Summary: Development libraries and headers for dmraid +Requires: dmraid-libs = %{version}-%{release} +Requires: sgpio + +%description -n dmraid-devel +dmraid-devel provides a library interface for RAID device discovery, +RAID set activation and display of properties for ATARAID volumes. + +%package -n dmraid-events +Summary: Device-mapper event tool (dmevent_tool) and DSO +Requires: dmraid-libs = %{version}-%{release} +Requires: dmraid = %{version}-%{release} +Requires: device-mapper-event +Requires: sgpio + +%description -n dmraid-events +Provides a dmeventd DSO and the dmevent_tool to register devices with it +for device monitoring. All active RAID sets should be manually registered +with dmevent_tool. + +%package -n dmraid-events-logwatch +Summary: Logwatch-based email reporting for dmraid +Requires: dmraid-events = %{version}-%{release} +Requires: crontabs +Requires: logwatch + +%description -n dmraid-events-logwatch +Provides device failure reporting via logwatch-based email reporting. +Device failure reporting has to be activated manually by activating the +/etc/cron.d/dmeventd-logwatch entry and by calling the dmevent_tool +(see manual page for examples) for any active RAID sets. + +%prep +%autosetup -n dmraid/%{version}-%{dmraid_release}/dmraid/ -p1 + +%build +%global _libdir /%{_lib} + +%configure --enable-debug --enable-libselinux --enable-libsepol --disable-static_link --enable-led --enable-intel_led +# parallel make is broken, do not pass smp flags +make + +%install +# TODO: Do we really need to create all these dirs ourselves here? Should make install do that? +# - it is necessary to create directories for logwatch files, and likely for +# others not installed by make +install -m 755 -d %{buildroot}{%{_libdir},%{_sbindir},%{_bindir},%{_libdir},%{_includedir}/dmraid/,/etc/cron.d/,/etc/logwatch/conf/services/,/etc/logwatch/scripts/services/,/var/cache/logwatch/dmeventd} +make DESTDIR=%{buildroot} install + +# Provide convenience link from dmevent_tool +(cd %{buildroot}%{_sbindir} ; ln -f dmevent_tool dm_dso_reg_tool) +(cd %{buildroot}%{_mandir}/man8 ; ln -f dmevent_tool.8 dm_dso_reg_tool.8) + +install -p -m 644 include/dmraid/*.h %{buildroot}%{_includedir}/dmraid/ + +# Install the libdmraid and libdmraid-events (for dmeventd) DSO +# Create version symlink to libdmraid.so.1 we link against +install -p -m 755 lib/libdmraid.so %{buildroot}%{_libdir}/libdmraid.so.%{version} +(cd %{buildroot}%{_libdir} ; ln -sf libdmraid.so.%{version} libdmraid.so ; ln -sf libdmraid.so.%{version} libdmraid.so.1) +install -p -m 755 lib/libdmraid-events-isw.so %{buildroot}%{_libdir}/libdmraid-events-isw.so.%{version} +(cd %{buildroot}%{_libdir} ; ln -sf libdmraid-events-isw.so.%{version} libdmraid-events-isw.so ; ln -sf libdmraid-events-isw.so.%{version} libdmraid-events-isw.so.1) + +# Install logwatch config file and script for dmeventd +install -p -m 644 logwatch/dmeventd.conf %{buildroot}/etc/logwatch/conf/services/dmeventd.conf +install -p -m 755 logwatch/dmeventd %{buildroot}/etc/logwatch/scripts/services/dmeventd +install -p -m 644 logwatch/dmeventd_cronjob.txt %{buildroot}/etc/cron.d/dmeventd-logwatch +install -p -m 0700 /dev/null %{buildroot}/var/cache/logwatch/dmeventd/syslogpattern.txt + +# Install systemd unit +install -d %{buildroot}%{_prefix}/lib/systemd +install -d %{buildroot}%{_unitdir} +install -p -m 755 %{SOURCE1} %{buildroot}%{_prefix}/lib/systemd/anolis-dmraid-activation +install -p -m 444 %{SOURCE2} %{buildroot}%{_unitdir}/dmraid-activation.service + +rm -f %{buildroot}%{_libdir}/libdmraid.a +rm -f %{buildroot}%{_prefix}/lib/libdmraid.a + +%post +%systemd_post dmraid-activation.service + +%preun +%systemd_preun dmraid-activation.service + +%postun +%systemd_postun dmraid-activation.service + +%files +%license LICENSE LICENSE_GPL LICENSE_LGPL +%doc CREDITS README +%{_mandir}/man8/dmraid* +%{_sbindir}/dmraid +%{_prefix}/lib/systemd/anolis-dmraid-activation +%{_unitdir}/dmraid-activation.service + +%files -n dmraid-libs +%license LICENSE LICENSE_GPL LICENSE_LGPL +%{_libdir}/libdmraid.so.* +%{_libdir}/libdmraid-events-isw.so.* + +%files -n dmraid-devel +%doc KNOWN_BUGS TODO doc/dmraid_design.txt +%{_libdir}/libdmraid.so +%{_prefix}/lib/libdmraid.so +%{_libdir}/libdmraid-events-isw.so +%{_libdir}/device-mapper/libdmraid-events-isw.so +%{_includedir}/dmraid + +%files -n dmraid-events +%{_mandir}/man8/dmevent_tool* +%{_mandir}/man8/dm_dso_reg_tool* +%{_sbindir}/dmevent_tool +%{_sbindir}/dm_dso_reg_tool + +%files -n dmraid-events-logwatch +%config(noreplace) /etc/logwatch/* +%config(noreplace) /etc/cron.d/dmeventd-logwatch +%dir /var/cache/logwatch/dmeventd +%ghost /var/cache/logwatch/dmeventd/syslogpattern.txt + +%changelog +* Mon Apr 11 2022 Zhongling He 1.0.0.rc16-1 +- Init package from upstream v1.0.0.rc16