diff --git a/.gitignore b/.gitignore index 18aaa44..1844bef 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,31 @@ /v0.8.0.tar.gz /v0.8.1.tar.gz /v0.8.5.tar.gz +/v0.9.0-rc2.tar.gz +/device-mapper-persistent-data-0.9.0-rc2-vendor.tar.gz +/v0.9.0.tar.gz +/dmpd090-vendor.tar.gz +/dmpd090-vendor2.tar.gz +/dmpd090-vendor3.tar.gz +/v1.0.2.tar.gz +/dmpd102-vendor.tar.gz +/v1.0.4.tar.gz +/dmpd104-vendor.tar.gz +/v1.0.5.tar.gz +/dmpd105-vendor.tar.gz +/v1.0.6.tar.gz +/dmpd106-vendor.tar.gz +/v1.0.9.tar.gz +/dmpd109-vendor.tar.gz +/v1.0.11.tar.gz +/dmpd1011-vendor.tar.gz +/v1.0.12.tar.gz +/dmpd1012-vendor.tar.gz +/v1.1.0.tar.gz +/dmpd110-vendor.tar.gz +/v1.2.1.tar.gz +/dmpd121-vendor.tar.gz +/v1.3.0.tar.gz +/dmpd130-vendor.tar.gz +/v1.3.1.tar.gz +/dmpd131-vendor.tar.gz diff --git a/README.md b/README.md new file mode 100644 index 0000000..a81396d --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +# Packaging device-mapper-persitent-data (AKA dmpd) + +This is rust package using *vendor* file for dependencies. (Vendor file is an archive of dependencies' sources.) + +For most of simple fixes, there is nothing special, +to add a patches simply add them to dist-git, +add a corresponding `PatchN: 000N-...` lines, +increase `Release:` or `release_suffix` for Z-stream (or for test build use suffix like `.bzNNNNNN`), +add to `%changelog`, +commit, +push, +and build the package using `fedpkg build`. + +Alternatively before committing anything use `fedpkg srpm` and `fedpkg scratch-build --srpm $SRPM [--arches x86_64]` to create a scratch build. + +However when building a new version of dmpd or when updating a dependency is +needed (e.g. because of CVE in the dependency) vendor file +has to be regenerated. + +## Updating vendor file + +To build a new version of the package following tooling is needed: + +- `rust >= 1.35` +- `cargo` providing vendor subcommand (now upstream, included in latest Fedora and RHEL8+) + +To create the vendor file: + +In the upstream directory: + +1. Run `cargo vendor` in the directory with upstream sources to create *vendor* + directory with sources. + - TODO: There is a *cargo-vendor-filterer* project used by *stratisd* to + filter out unnecessary dependencies for other operating systems. +2. Run `tar czf device-mapper-persistent-data-vendor-$VERSION.tar.gz ./vendor` to create a tarball. +3. Copy the vendor file to dist git directory. + +In the dist-git directory: + +1. Get the upstream tarball `wget https://github.com/jthornber/thin-provisioning-tools/archive/v$VERSION.tar.gz` + - NOTE: Migration to `https://github.com/device-mapper-utils/thin-provisioning-tools` is coming. +2. Update *Source0* and *Source1* to correct values. +3. Add the tarballs to koji/brew lookaside: + - `fedpkg new-sources v$VERSION.tar.gz device-mapper-persistent-data-vendor-$VERSION.tar.gz` + +## TODO/NOTES + +Some of the dependencies are already packaged by Fedora. Can we instruct *cargo vendor* to include only those which are not provided by Fedora? +It would be possible to include these as submodules, and the rest could be used from Fedora. +For RHEL and CentOS Stream using vendor file is the recommended way. + +*%cargo_install* installs by default in */usr/bin* but the package expects */usr/sbin*. For now I run *make install-rust-tools*. +Now Fedora unified the */usr/sbin* and */usr/bin* directories, to this can be "fixed" in Fedora and later in CentOS Stream. + diff --git a/device-mapper-persistent-data.spec b/device-mapper-persistent-data.spec index b30c346..213bfff 100644 --- a/device-mapper-persistent-data.spec +++ b/device-mapper-persistent-data.spec @@ -1,19 +1,38 @@ # # Copyright (C) 2011-2017 Red Hat, Inc # +%bcond_without check +#%%global debug_package %%{nil} + +#%%global version_suffix -rc2 +#%%global release_suffix .test3 Summary: Device-mapper Persistent Data Tools Name: device-mapper-persistent-data -Version: 0.8.5 -Release: 3%{?dist} -License: GPLv3+ -URL: https://github.com/jthornber/thin-provisioning-tools -#Source0: https://github.com/jthornber/thin-provisioning-tools/archive/thin-provisioning-tools-% {version}.tar.gz -Source0: https://github.com/jthornber/thin-provisioning-tools/archive/v%{version}.tar.gz -Patch0: device-mapper-persistent-data-avoid-strip.patch +Version: 1.3.1 +Release: 1%{?dist}%{?release_suffix} +License: GPL-3.0-only AND (0BSD OR MIT OR Apache-2.0) AND Apache-2.0 AND (Apache-2.0 OR MIT) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND BSD-3-Clause AND MIT AND (MIT OR Apache-2.0) AND (MIT OR Zlib OR Apache-2.0) AND (Unlicense OR MIT) AND (Zlib OR Apache-2.0 OR MIT) -BuildRequires: autoconf, expat-devel, libaio-devel, libstdc++-devel, boost-devel, gcc-c++ -Requires: expat +#ExcludeArch: %%{ix86} +URL: https://github.com/jthornber/thin-provisioning-tools +#Source0: https://github.com/jthornber/thin-provisioning-tools/archive/thin-provisioning-tools-%%{version}.tar.gz +Source0: https://github.com/jthornber/thin-provisioning-tools/archive/v%{version}%{?version_suffix}.tar.gz +Source1: dmpd131-vendor.tar.gz + +%if %{defined rhel} +BuildRequires: rust-toolset +%else +BuildRequires: rust-packaging +BuildRequires: rust >= 1.35 +BuildRequires: cargo +%endif +BuildRequires: make +BuildRequires: systemd-devel +BuildRequires: clang-libs +BuildRequires: glibc-static +BuildRequires: device-mapper-devel +BuildRequires: clang +#BuildRequires: gcc %description thin-provisioning-tools contains check,dump,restore,repair,rmap @@ -24,20 +43,46 @@ are included and era check, dump, restore and invalidate to manage snapshot eras %prep -%setup -q -n thin-provisioning-tools-%{version} -%patch0 -p1 -b .avoid_strip +%autosetup -p1 -n thin-provisioning-tools-%{version}%{?version_suffix} -a1 +%cargo_prep -v vendor + +# NOTE: Following could replace Cargo.toml patching, but some macros are not working well with it +# Notably at least one of cargo_license_summary, cargo_license_summary, or cargo_vendor_manifest +#cat >> .cargo/config.toml << EOF +# +#[source."git+https://github.com/jthornber/rio?branch=master"] +#git = "https://github.com/jthornber/rio" +#branch = "master" +#replace-with = "vendored-sources" +# +#EOF + echo %{version}-%{release} > VERSION +%generate_buildrequires + %build -autoconf -%configure --with-optimisation= -make %{?_smp_mflags} V= +#make %{?_smp_mflags} V= +%cargo_build +%cargo_license_summary +%{cargo_license} > LICENSE.dependencies +%cargo_vendor_manifest %install -make DESTDIR=%{buildroot} MANDIR=%{_mandir} install +# TODO: Check that MANDIR is unused and remove +%make_install STRIP=true MANDIR=%{_mandir} BINDIR=%{buildroot}%{_sbindir} + +%if %{with check} +%check +%cargo_test +#cargo test --test thin_shrink -- --nocapture --test-threads=1 +%endif %files -%doc COPYING README.md +%doc README.md +%license COPYING +%license LICENSE.dependencies +%license cargo-vendor.txt %{_mandir}/man8/cache_check.8.gz %{_mandir}/man8/cache_dump.8.gz %{_mandir}/man8/cache_metadata_size.8.gz @@ -53,10 +98,13 @@ make DESTDIR=%{buildroot} MANDIR=%{_mandir} install %{_mandir}/man8/thin_dump.8.gz %{_mandir}/man8/thin_ls.8.gz %{_mandir}/man8/thin_metadata_size.8.gz +%{_mandir}/man8/thin_migrate.8.gz %{_mandir}/man8/thin_repair.8.gz %{_mandir}/man8/thin_restore.8.gz %{_mandir}/man8/thin_rmap.8.gz %{_mandir}/man8/thin_trim.8.gz +%{_mandir}/man8/thin_metadata_pack.8.gz +%{_mandir}/man8/thin_metadata_unpack.8.gz %{_sbindir}/pdata_tools %{_sbindir}/cache_check %{_sbindir}/cache_dump @@ -73,13 +121,123 @@ make DESTDIR=%{buildroot} MANDIR=%{_mandir} install %{_sbindir}/thin_dump %{_sbindir}/thin_ls %{_sbindir}/thin_metadata_size +%{_sbindir}/thin_migrate %{_sbindir}/thin_repair %{_sbindir}/thin_restore %{_sbindir}/thin_rmap %{_sbindir}/thin_trim +%{_sbindir}/thin_metadata_pack +%{_sbindir}/thin_metadata_unpack #% {_sbindir}/thin_show_duplicates %changelog +* Tue Dec 02 2025 Marian Csontos - 1.3.1-1 +- Update to latest upstream release 1.3.1. + +* Wed Oct 22 2025 Marian Csontos - 1.3.0-1 +- Update to latest upstream release 1.3.0. + +* Thu Sep 04 2025 Marian Csontos - 1.2.1-1 +- Update to latest upstream release 1.2.1. + +* Wed Jul 23 2025 Fedora Release Engineering - 1.1.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + +* Thu Jan 16 2025 Fedora Release Engineering - 1.1.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + +* Sun Jan 12 2025 Zbigniew Jędrzejewski-Szmek - 1.1.0-2 +- Rebuilt for the bin-sbin merge (2nd attempt) + +* Mon Sep 02 2024 Marian Csontos - 1.1.0-1 +- Update to latest upstream release 1.1.0. + +* Wed Jul 17 2024 Fedora Release Engineering - 1.0.12-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Tue Jul 09 2024 Zbigniew Jędrzejewski-Szmek - 1.0.12-2 +- Rebuilt for the bin-sbin merge + +* Tue Feb 27 2024 Marian Csontos - 1.0.12-1 +- Update to latest upstream release 1.0.12. + +* Tue Feb 13 2024 Marian Csontos - 1.0.11-4 +- Add licenses for statically linked libraries. + +* Tue Feb 13 2024 Marian Csontos - 1.0.11-3 +- SPDX migration + +* Thu Feb 08 2024 Yaakov Selkowitz - 1.0.11-2 +- Update Rust macro usage + +* Thu Feb 08 2024 Marian Csontos - 1.0.11-1 +- Update to latest upstream release 1.0.11. + +* Wed Jan 24 2024 Fedora Release Engineering - 1.0.9-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Fri Jan 19 2024 Fedora Release Engineering - 1.0.9-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Mon Dec 11 2023 Marian Csontos - 1.0.9-1 +- Update to latest upstream release 1.0.9. + +* Thu Aug 31 2023 Marian Csontos - 1.0.6-2 +- Fix broken installation on ppc64le caused by incorrect ioctl call. + +* Wed Aug 09 2023 Marian Csontos - 1.0.6-1 +- Update to latest upstream release 1.0.6. + +* Thu Jul 27 2023 Marian Csontos - 1.0.5-1 +- Update to latest upstream release 1.0.5. + +* Wed Jul 19 2023 Fedora Release Engineering - 1.0.4-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Tue May 30 2023 Yaakov Selkowitz - 1.0.4-2 +- Use rust-toolset in RHEL builds + +* Fri Apr 28 2023 Marian Csontos - 1.0.4-1 +- Update to latest upstream release 1.0.4. + +* Wed Mar 22 2023 Marian Csontos - 1.0.3-1 +- Update to latest upstream release 1.0.3. + +* Sun Feb 05 2023 Fabio Valentini - 0.9.0-10 +- Rebuild for fixed frame pointer compiler flags in Rust RPM macros. + +* Thu Jan 19 2023 Fedora Release Engineering - 0.9.0-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Thu Jul 21 2022 Fedora Release Engineering - 0.9.0-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Thu Jan 20 2022 Fedora Release Engineering - 0.9.0-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Thu Jul 22 2021 Marian Csontos - 0.9.0-6 +- Fix rust-1.53 compilation issues. + +* Wed Jul 21 2021 Fedora Release Engineering - 0.9.0-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Thu Jun 10 2021 Marian Csontos - 0.9.0-4 +- Fix gating test syntax. +- Fix important issues found by static analysis. + +* Tue Jan 26 2021 Fedora Release Engineering - 0.9.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Mon Sep 21 2020 Marian Csontos - 0.9.0-2 +- Update crc32c to version 0.5 supporting non x86 architectures + +* Thu Sep 17 2020 Marian Csontos - 0.9.0-1 +- Update to latest upstream version +- New tools thin_metadata_pack and thin_metadata_unpack + +* Mon Jul 27 2020 Fedora Release Engineering - 0.8.5-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + * Tue Jan 28 2020 Fedora Release Engineering - 0.8.5-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild diff --git a/sources b/sources index db03cfa..4ddfdfb 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ -SHA512 (v0.8.5.tar.gz) = 11e8f6bccaa1d5ccc622a356995f60afa45bba5f4dd80e2fbd7e980963d856a15a32d7b3305e445291936d5207af72fac85d9956680ed7c651383cc57a945451 +SHA512 (v1.3.1.tar.gz) = ff0758b21b50702568cad88522ee4c2b6b4433cec0a5f5074c9d1791c13e630e5c516601d7a68c51ac34e036091fc82fe831dbe51e6776737571d90ed266878e +SHA512 (dmpd131-vendor.tar.gz) = 0e1b8e501e330b64415c9097c94dfc1f1b43d2900a66258e40b6c8f28c51fd61247d60495f594f14550fb349ed4ad435f8959a8808fea1d363a206c5ead7db1e diff --git a/tests/functions_test/Makefile b/tests/functions_test/Makefile index 85cc8dd..6b14a2f 100644 --- a/tests/functions_test/Makefile +++ b/tests/functions_test/Makefile @@ -40,7 +40,7 @@ export TEST=/$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH) BUILT_FILES= # data files, .c files, scripts anything needed to either compile the test and/or run it. -FILES=$(METADATA) runtest.sh PURPOSE +FILES=$(METADATA) runtest.sh PURPOSE testinfo.desc dmpd_functions.py dmpd_library.py Makefile run: $(FILES) build ./runtest.sh @@ -62,7 +62,7 @@ include /usr/share/rhts/lib/rhts-make.include $(METADATA): Makefile @touch $(METADATA) # Change to the test owner's name - @echo "Owner: Jakub Krysl " > $(METADATA) + @echo "Owner: Filip Suba " > $(METADATA) @echo "Name: $(TEST)" >> $(METADATA) @echo "Path: $(TEST_DIR)" >> $(METADATA) @echo "License: GPL" >> $(METADATA) @@ -71,6 +71,5 @@ $(METADATA): Makefile @echo "TestTime: 1h" >> $(METADATA) @echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA) @echo "Requires: $(PACKAGE_NAME)" >> $(METADATA) - @echo "RhtsRequires: kernel-kernel-storage-misc-env_setup" >> $(METADATA) rhts-lint $(METADATA) diff --git a/tests/functions_test/dmpd_functions.py b/tests/functions_test/dmpd_functions.py index a908bcf..4d23f70 100755 --- a/tests/functions_test/dmpd_functions.py +++ b/tests/functions_test/dmpd_functions.py @@ -39,7 +39,7 @@ def thin_init(args): atomic_run("Creating thin pool", vg_name=args["group"], lv_name=args["pool"], - options=["-T", "-L 500"], + options=["-T", "-L 1500"], command=lvm.lv_create, errors=errors) @@ -48,7 +48,7 @@ def thin_init(args): atomic_run("Creating thin LV No. %s" % i, vg_name=args["group"] + "/" + args["pool"], lv_name=args["vol"] + str(i), - options=["-T", "-V 100"], + options=["-T", "-V 300"], command=lvm.lv_create, errors=errors) @@ -58,28 +58,16 @@ def thin_init(args): command=create_filesystem, errors=errors) - atomic_run("Deactivating thin LV No. %s" % i, - lv_name=args["vol"] + str(i), - vg_name=args["group"], - command=lvm.lv_deactivate, - errors=errors) - atomic_run("Creating metadata snapshot", lv_name=args["pool"], vg_name=args["group"], command=metadata_snapshot, errors=errors) - atomic_run("Deactivating pool", - lv_name=args["pool"], - vg_name=args["group"], - command=lvm.lv_deactivate, - errors=errors) - atomic_run("Creating swap LV", vg_name=args["group"], lv_name=args["swap"], - options=["-L 100"], + options=["-L 300"], command=lvm.lv_create, errors=errors) @@ -89,6 +77,19 @@ def thin_init(args): command=lvm.lv_deactivate, errors=errors) + atomic_run("Deactivating pool", + lv_name=args["pool"], + vg_name=args["group"], + command=lvm.lv_deactivate, + errors=errors) + + for i in range(args["number of vols"]): + atomic_run("Deactivating thin LV No. %s" % i, + lv_name=args["vol"] + str(i), + vg_name=args["group"], + command=lvm.lv_deactivate, + errors=errors) + atomic_run("Swapping metadata", vg_name=args["group"], lv_name=args["swap"], @@ -195,7 +196,7 @@ def thin_clean(args): def thin_test(args): print("\n#######################################\n") - print ( + print( "INFO: Testing thin tools runtime provided by device_mapper_persistent_data") errors = [] @@ -281,7 +282,8 @@ def thin_test(args): command=run, errors=errors) - atomic_run("Outputting reverse map of metadata device", + atomic_run("Outputting reverse map of metadata device with negative number in region", + False, source_vg=args["group"], source_lv=args["swap"], region="0..-1", @@ -415,7 +417,7 @@ def thin_test(args): def thin_errors_test(args): print("\n#######################################\n") - print ( + print( "INFO: Testing thin tools errors provided by device_mapper_persistent_data") errors = [] @@ -845,7 +847,7 @@ def cache_clean(args): def cache_test(args): print("\n#######################################\n") - print ("INFO: Testing cache tools runtime provided by device_mapper_persistent_data") + print("INFO: Testing cache tools runtime provided by device_mapper_persistent_data") errors = [] @@ -965,7 +967,7 @@ def cache_test(args): def cache_errors_test(args): print("\n#######################################\n") - print ("INFO: Testing cache tools errors provided by device_mapper_persistent_data") + print("INFO: Testing cache tools errors provided by device_mapper_persistent_data") errors = [] @@ -1111,6 +1113,7 @@ def cache_errors_test(args): # errors=errors) #FIXME: Find other way to corrupt metadata, this exploits a bug + """ atomic_run("Corrupting mappings on metadata device", False, source_file="Makefile", @@ -1139,7 +1142,7 @@ def cache_errors_test(args): source_lv=args['swap'], target_file="/tmp/metadata_repair", command=dmpd.cache_repair, - errors=errors) + errors=errors)""" atomic_run("Corrupting metadata on device", cmd="echo 'nothing' >> /dev/mapper/%s-%s" % (args['group'], args['swap']), @@ -1208,6 +1211,7 @@ def main(): "swap": "swapvol"} # Initialization + install_package("lvm2") install_package("device-mapper-persistent-data") # Tests for thin tools provided by device-mapper-persistent-data @@ -1223,10 +1227,10 @@ def main(): cache_clean(args) if not TC.tend(): - print "FAIL: test failed" + print("FAIL: test failed") sys.exit(1) - print "PASS: Test pass" + print("PASS: Test pass") sys.exit(0) diff --git a/tests/functions_test/dmpd_library.py b/tests/functions_test/dmpd_library.py index e8f1ed9..1cf44df 100755 --- a/tests/functions_test/dmpd_library.py +++ b/tests/functions_test/dmpd_library.py @@ -16,6 +16,8 @@ """dmpd_library.py: Complete library providing functionality for device-mapper-persistent-data upstream test.""" +from __future__ import print_function + import platform from os.path import expanduser import re #regex @@ -23,6 +25,8 @@ import sys, os import subprocess import time import fileinput +# TODO: Is this really necessary? Unlikely we will run into python2 in rawhide +# again... def _print(string): @@ -52,7 +56,7 @@ def run(cmd, return_output=False, verbose=True, force_flush=False): date = "date \"+%Y-%m-%d %H:%M:%S\"" p = subprocess.Popen(date, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) stdout, stderr = p.communicate() - stdout = stdout.rstrip("\n") + stdout = stdout.decode('ascii', 'ignore').rstrip("\n") _print("INFO: [%s] Running: '%s'..." % (stdout, cmd)) #enabling shell=True, because was the only way I found to run command with '|' @@ -74,7 +78,7 @@ def run(cmd, return_output=False, verbose=True, force_flush=False): retcode = p.returncode - output = stdout + stderr + output = stdout.decode('ascii', 'ignore') + stderr.decode('ascii', 'ignore') #remove new line from last line output = output.rstrip() @@ -152,11 +156,11 @@ def dist_release(): """ Find out the release number of Linux distribution. """ - dist = platform.linux_distribution() - if not dist or dist[1] == "": + dist = platform.release() + if not dist: _print("WARN: dist_release() - Could not determine dist release") return None - return dist[1] + return dist def dist_ver(): @@ -191,7 +195,8 @@ def show_sys_info(): if run("rpm -q device-mapper-multipath") == 0: #Abort test execution if multipath is not working well if run("multipath -l 2>/dev/null") != 0: - sys.exit(1) + print("WARN: Multipath is not configured correctly") + return #Flush all unused multipath devices before starting the test run("multipath -F") run("multipath -r") @@ -602,7 +607,7 @@ class LogChecker: _print("WARN: Could not open %s" % log_msg_file) return True - log_file = open(log_msg_file) + log_file = open(log_msg_file, encoding="utf-8", errors="ignore") log = log_file.read() begin_tag = "\\[ cut here \\]" @@ -1042,7 +1047,7 @@ class LoopDev: _print("WARN: Could not create loop device image file") return ret_fail except OSError as e: - print >> sys.err, "command failed: ", e + print("command failed: ", e, file=sys.err) return ret_fail loop_path = self._get_loop_path(name) @@ -1125,7 +1130,7 @@ class LoopDev: name = self._standardize_name(name) # Just try to detach if device is connected, otherwise ignore - # print "INFO: Checking if ", loop_path, " exists, to be detached" + # print("INFO: Checking if ", loop_path, " exists, to be detached") dev_path = self._get_loop_path(name) if dev_path in devs: cmd = "losetup -d %s" % dev_path @@ -1199,7 +1204,7 @@ class LVM: cmd = "vgcreate %s %s %s" % (options, vg_name, pv_name) retcode = run(cmd, verbose=verbose) if (retcode != 0): - # _print ("WARN: Could not create %s" % vg_name) + # _print("WARN: Could not create %s" % vg_name) return False return True @@ -1277,7 +1282,7 @@ class LVM: _print("WARN: (%s) does not match lvs output format" % lv) continue lv_info_dict = {} - for index in xrange(len(param_names)): + for index in range(len(param_names)): lv_info_dict[param_names[index]] = m.group(index + 1) lv_list.append(lv_info_dict) @@ -1321,7 +1326,7 @@ class LVM: cmd = "lvcreate %s %s -n %s" % (" ".join(str(i) for i in options), vg_name, lv_name) retcode = run(cmd, verbose=verbose) if (retcode != 0): - # _print ("WARN: Could not create %s" % lv_name) + # _print("WARN: Could not create %s" % lv_name) return False return True @@ -1514,7 +1519,7 @@ class DMPD: _print("WARN: Could not create file to %s metadata to." % command_message) return False except OSError as e: - print >> sys.err, "command failed: ", e + print("command failed: ", e, file=sys.err) return False return True diff --git a/tests/tools_not_linked_usr/tools_not_linked_usr.py b/tests/tools_not_linked_usr/tools_not_linked_usr.py index 7acb804..7be6393 100755 --- a/tests/tools_not_linked_usr/tools_not_linked_usr.py +++ b/tests/tools_not_linked_usr/tools_not_linked_usr.py @@ -14,25 +14,27 @@ # # Author: Bruno Goncalves -from os import walk import subprocess import sys import re def run(cmd): - print "INFO: Running '%s'..." % cmd + print("INFO: Running '%s'..." % cmd) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) stdout, stderr = p.communicate() retcode = p.returncode - output = stdout + stderr - print output + output = stdout.decode('ascii', 'ignore') + stderr.decode('ascii', 'ignore') + + # remove new line from last line + output = output.rstrip() + print(output) return retcode, output def start_test(): #if uses any library linked to /usr this my affect the tools during boot - print ("INFO: Making sure tools provided by device-mapper-persistent-data " + print("INFO: Making sure tools provided by device-mapper-persistent-data " "are not linked to /usr") #Paths where we should have no libraries linked from @@ -54,7 +56,7 @@ def start_test(): continue tool_error = 0 for lib_path in lib_paths: - print "INFO: Checking if %s is not linked to libraries at %s" % (tool, lib_path) + print("INFO: Checking if %s is not linked to libraries at %s" % (tool, lib_path)) ret, linked_lib = run("ldd %s" % tool) if ret != 0: print("FAIL: Could not list dynamically libraries for %s" % (tool)) @@ -83,10 +85,10 @@ def start_test(): def main(): if not start_test(): - print "FAIL: test failed" + print("FAIL: test failed") sys.exit(1) - print "PASS: Test pass" + print("PASS: Test pass") sys.exit(0) main()