Hello community, here is the log from the commit of package libstorage-ng for openSUSE:Factory checked in at 2020-04-05 20:51:28 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libstorage-ng (Old) and /work/SRC/openSUSE:Factory/.libstorage-ng.new.3248 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libstorage-ng" Sun Apr 5 20:51:28 2020 rev:79 rq:790505 version:4.2.72 Changes: -------- --- /work/SRC/openSUSE:Factory/libstorage-ng/libstorage-ng.changes 2020-03-27 21:56:42.154771991 +0100 +++ /work/SRC/openSUSE:Factory/.libstorage-ng.new.3248/libstorage-ng.changes 2020-04-05 20:51:39.733074529 +0200 @@ -1,0 +2,11 @@ +Wed Apr 1 09:07:32 UTC 2020 - aschn...@suse.com + +- merge gh#openSUSE/libstorage-ng#718 +- allow control over environment variables +- query number of partition slots from parted +- respect number of partition slots reported by parted for GPT + (bsc#1161783) +- run travis with "--privileged" to avoid permissions error +- 4.2.72 + +-------------------------------------------------------------------- Old: ---- libstorage-ng-4.2.71.tar.xz New: ---- libstorage-ng-4.2.72.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libstorage-ng.spec ++++++ --- /var/tmp/diff_new_pack.t5geWU/_old 2020-04-05 20:51:40.785075536 +0200 +++ /var/tmp/diff_new_pack.t5geWU/_new 2020-04-05 20:51:40.785075536 +0200 @@ -18,7 +18,7 @@ %define libname %{name}1 Name: libstorage-ng -Version: 4.2.71 +Version: 4.2.72 Release: 0 Summary: Library for storage management License: GPL-2.0-only ++++++ libstorage-ng-4.2.71.tar.xz -> libstorage-ng-4.2.72.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.2.71/.travis.yml new/libstorage-ng-4.2.72/.travis.yml --- old/libstorage-ng-4.2.71/.travis.yml 2020-03-25 15:14:09.000000000 +0100 +++ new/libstorage-ng-4.2.72/.travis.yml 2020-04-01 11:07:32.000000000 +0200 @@ -14,4 +14,4 @@ script: # run the travis script # mount the ccache as a volume (bind-mount) so the changes are available later outside the container - - docker run -it -e TRAVIS=1 -e TRAVIS_JOB_ID="$TRAVIS_JOB_ID" -v $HOME/.ccache:/root/.ccache libstorage-ng-image ./.travis.sh + - docker run -it --privileged -e TRAVIS=1 -e TRAVIS_JOB_ID="$TRAVIS_JOB_ID" -v $HOME/.ccache:/root/.ccache libstorage-ng-image ./.travis.sh diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.2.71/LIBVERSION new/libstorage-ng-4.2.72/LIBVERSION --- old/libstorage-ng-4.2.71/LIBVERSION 2020-03-25 15:14:09.000000000 +0100 +++ new/libstorage-ng-4.2.72/LIBVERSION 2020-04-01 11:07:32.000000000 +0200 @@ -1 +1 @@ -1.30.0 +1.30.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.2.71/VERSION new/libstorage-ng-4.2.72/VERSION --- old/libstorage-ng-4.2.71/VERSION 2020-03-25 15:14:09.000000000 +0100 +++ new/libstorage-ng-4.2.72/VERSION 2020-04-01 11:07:32.000000000 +0200 @@ -1 +1 @@ -4.2.71 +4.2.72 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.2.71/storage/Devices/GptImpl.cc new/libstorage-ng-4.2.72/storage/Devices/GptImpl.cc --- old/libstorage-ng-4.2.71/storage/Devices/GptImpl.cc 2020-03-25 15:14:09.000000000 +0100 +++ new/libstorage-ng-4.2.72/storage/Devices/GptImpl.cc 2020-04-01 11:07:32.000000000 +0200 @@ -1,6 +1,6 @@ /* * Copyright (c) [2014-2015] Novell, Inc. - * Copyright (c) [2016-2018] SUSE LLC + * Copyright (c) [2016-2020] SUSE LLC * * All Rights Reserved. * @@ -43,10 +43,15 @@ const char* DeviceTraits<Gpt>::classname = "Gpt"; + const unsigned int Gpt::Impl::default_partition_slots; + Gpt::Impl::Impl(const xmlNode* node) - : PartitionTable::Impl(node), undersized(false), backup_broken(false), pmbr_boot(false) + : PartitionTable::Impl(node), partition_slots(default_partition_slots), undersized(false), + backup_broken(false), pmbr_boot(false) { + getChildValue(node, "partition-slots", partition_slots); + getChildValue(node, "undersized", undersized); getChildValue(node, "backup-broken", backup_broken); @@ -71,6 +76,9 @@ const Parted& parted = prober.get_system_info().getParted(partitionable->get_name()); + if (parted.get_primary_slots() >= 0) + partition_slots = parted.get_primary_slots(); + undersized = parted.is_gpt_undersized(); backup_broken = parted.is_gpt_backup_broken(); @@ -83,6 +91,8 @@ { PartitionTable::Impl::save(node); + setChildValueIf(node, "partition-slots", partition_slots, partition_slots != default_partition_slots); + setChildValueIf(node, "undersized", undersized, undersized); setChildValueIf(node, "backup-broken", backup_broken, backup_broken); @@ -95,12 +105,13 @@ { Region region = get_partitionable()->get_region(); - // 1 sector for protective MBR (only at beginning), 1 sector for - // primary or secondary header and 128 partition entries with 128 - // bytes per partition entry. In theory these values are - // variables. See https://en.wikipedia.org/wiki/GUID_Partition_Table. + // 1 sector for protective MBR (only at beginning), 1 sector + // for primary or secondary header and partition_slots, + // usually 128, partition entries with 128 bytes per partition + // entry. In theory these values are variables. See + // https://en.wikipedia.org/wiki/GUID_Partition_Table. - unsigned long long sectors = 1 + 128 * 128 * B / region.get_block_size(); + unsigned long long sectors = 1 + partition_slots * 128 * B / region.get_block_size(); return make_pair(1 + sectors, sectors); } @@ -149,8 +160,8 @@ if (!PartitionTable::Impl::equal(rhs)) return false; - return undersized == rhs.undersized && backup_broken == rhs.backup_broken && - pmbr_boot == rhs.pmbr_boot; + return partition_slots == rhs.partition_slots && undersized == rhs.undersized && + backup_broken == rhs.backup_broken && pmbr_boot == rhs.pmbr_boot; } @@ -161,6 +172,8 @@ PartitionTable::Impl::log_diff(log, rhs); + storage::log_diff(log, "partition-slots", partition_slots, rhs.partition_slots); + storage::log_diff(log, "undersized", undersized, rhs.undersized); storage::log_diff(log, "backup-broken", backup_broken, rhs.backup_broken); @@ -173,6 +186,9 @@ { PartitionTable::Impl::print(out); + if (partition_slots != default_partition_slots) + out << " partition-slots:" << partition_slots; + if (is_undersized()) out << " undersized"; @@ -206,7 +222,7 @@ unsigned int Gpt::Impl::max_primary() const { - return min(128U, get_partitionable()->get_range() - 1); + return min(partition_slots, get_partitionable()->get_range() - 1); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.2.71/storage/Devices/GptImpl.h new/libstorage-ng-4.2.72/storage/Devices/GptImpl.h --- old/libstorage-ng-4.2.71/storage/Devices/GptImpl.h 2020-03-25 15:14:09.000000000 +0100 +++ new/libstorage-ng-4.2.72/storage/Devices/GptImpl.h 2020-04-01 11:07:32.000000000 +0200 @@ -1,6 +1,6 @@ /* * Copyright (c) [2014-2015] Novell, Inc. - * Copyright (c) [2016-2018] SUSE LLC + * Copyright (c) [2016-2020] SUSE LLC * * All Rights Reserved. * @@ -43,8 +43,8 @@ public: Impl() - : PartitionTable::Impl(), undersized(false), backup_broken(false), - pmbr_boot(false) {} + : PartitionTable::Impl(), partition_slots(default_partition_slots), undersized(false), + backup_broken(false), pmbr_boot(false) {} Impl(const xmlNode* node); @@ -100,6 +100,17 @@ private: /** + * Number of partitions slots if parted does not report anything else and + * for new GPTs. + */ + static const unsigned int default_partition_slots = 128; + + /** + * Number of partitions slots. + */ + unsigned int partition_slots; + + /** * The GPT does not use the complete device. */ bool undersized; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.2.71/storage/SystemInfo/CmdParted.cc new/libstorage-ng-4.2.72/storage/SystemInfo/CmdParted.cc --- old/libstorage-ng-4.2.71/storage/SystemInfo/CmdParted.cc 2020-03-25 15:14:09.000000000 +0100 +++ new/libstorage-ng-4.2.72/storage/SystemInfo/CmdParted.cc 2020-04-01 11:07:32.000000000 +0200 @@ -1,6 +1,6 @@ /* * Copyright (c) [2004-2015] Novell, Inc. - * Copyright (c) [2016-2018] SUSE LLC + * Copyright (c) [2016-2020] SUSE LLC * * All Rights Reserved. * @@ -41,13 +41,14 @@ Parted::Parted(const string& device) - : device(device), label(PtType::UNKNOWN), region(), implicit(false), + : device(device), label(PtType::UNKNOWN), region(), primary_slots(-1), implicit(false), gpt_undersized(false), gpt_backup_broken(false), gpt_pmbr_boot(false), logical_sector_size(0), physical_sector_size(0) { SystemCmd::Options options(PARTED_BIN " --script --machine " + quote(device) + " unit s print", SystemCmd::DoThrow); options.verify = [](int) { return true; }; + options.env.push_back("PARTED_PRINT_NUMBER_OF_PARTITION_SLOTS=1"); SystemCmd cmd(options); @@ -83,6 +84,7 @@ void Parted::parse(const vector<string>& stdout, const vector<string>& stderr) { + primary_slots = -1; implicit = false; gpt_undersized = false; gpt_backup_broken = false; @@ -133,6 +135,9 @@ label = scan_partition_table_type(tmp[5]); scan_device_flags(tmp[7]); + + if (tmp.size() >= 9) + tmp[8] >> primary_slots; } @@ -366,6 +371,9 @@ s << "device:" << parted.device << " label:" << toString(parted.label) << " region:" << parted.region; + if (parted.primary_slots >= 0) + s << " primary-slots:" << parted.primary_slots; + if (parted.implicit) s << " implicit"; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.2.71/storage/SystemInfo/CmdParted.h new/libstorage-ng-4.2.72/storage/SystemInfo/CmdParted.h --- old/libstorage-ng-4.2.71/storage/SystemInfo/CmdParted.h 2020-03-25 15:14:09.000000000 +0100 +++ new/libstorage-ng-4.2.72/storage/SystemInfo/CmdParted.h 2020-04-01 11:07:32.000000000 +0200 @@ -1,6 +1,6 @@ /* * Copyright (c) [2004-2014] Novell, Inc. - * Copyright (c) [2016-2018] SUSE LLC + * Copyright (c) [2016-2020] SUSE LLC * * All Rights Reserved. * @@ -81,6 +81,12 @@ const Region& get_region() const { return region; } /** + * Get the number of primary partition slots. If parted did not report the + * value it is -1 (reporting the value is a SUSE specific patch). + */ + int get_primary_slots() const { return primary_slots; } + + /** * S/390 arch: zFCP DASDs create implicit partitions if there is none * on that disk yet. This function returns if this is the case for * this device. @@ -123,6 +129,7 @@ string device; PtType label; Region region; + int primary_slots; bool implicit; bool gpt_undersized; bool gpt_backup_broken; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.2.71/storage/Utils/SystemCmd.cc new/libstorage-ng-4.2.72/storage/Utils/SystemCmd.cc --- old/libstorage-ng-4.2.71/storage/Utils/SystemCmd.cc 2020-03-25 15:14:09.000000000 +0100 +++ new/libstorage-ng-4.2.72/storage/Utils/SystemCmd.cc 2020-04-01 11:07:32.000000000 +0200 @@ -693,17 +693,29 @@ vector<const char*> SystemCmd::make_env() const { + // Environment variables should be present only once in the environment. + // https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html + vector<const char*> env; for (char** v = environ; *v != NULL; ++v) + env.push_back(*v); + + for (const string& v : options.env) { - if (strncmp(*v, "LC_ALL=", strlen("LC_ALL=")) != 0 && - strncmp(*v, "LANGUAGE=", strlen("LANGUAGE=")) != 0) - env.push_back(*v); - } + string::size_type pos = v.find("="); + if (pos == string::npos) + continue; - env.push_back("LC_ALL=C"); - env.push_back("LANGUAGE=C"); + string key = v.substr(0, pos + 1); // key including '=' sign + + vector<const char*>::iterator it = find_if(env.begin(), env.end(), + [&key](const char* tmp) { return boost::starts_with(tmp, key); }); + if (it != env.end()) + *it = v.c_str(); + else + env.push_back(v.c_str()); + } env.push_back(nullptr); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.2.71/storage/Utils/SystemCmd.h new/libstorage-ng-4.2.72/storage/Utils/SystemCmd.h --- old/libstorage-ng-4.2.71/storage/Utils/SystemCmd.h 2020-03-25 15:14:09.000000000 +0100 +++ new/libstorage-ng-4.2.72/storage/Utils/SystemCmd.h 2020-04-01 11:07:32.000000000 +0200 @@ -60,7 +60,8 @@ Options(const string& command, ThrowBehaviour throw_behaviour = NoThrow) : command(command), throw_behaviour(throw_behaviour), stdin_text(), mockup_key(), log_line_limit(1000), - verify([](int exit_code){ return exit_code == 0; }) {} + verify([](int exit_code){ return exit_code == 0; }), + env({ "LC_ALL=C", "LANGUAGE=C" }) {} /** * The command to be executed. @@ -94,6 +95,12 @@ */ std::function<bool(int)> verify; + /** + * Environment variables to override existing environment variables. Per + * default this includes LC_ALL=C and LANGUAGE=C. + */ + vector<string> env; + }; /** diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.2.71/testsuite/SystemInfo/parted.cc new/libstorage-ng-4.2.72/testsuite/SystemInfo/parted.cc --- old/libstorage-ng-4.2.71/testsuite/SystemInfo/parted.cc 2020-03-25 15:14:09.000000000 +0100 +++ new/libstorage-ng-4.2.72/testsuite/SystemInfo/parted.cc 2020-04-01 11:07:32.000000000 +0200 @@ -292,6 +292,53 @@ } +BOOST_AUTO_TEST_CASE(parse_jetson_nano) +{ + // GPT of Jetson Nano image with only 15 partition slots. + + vector<string> input = { + "BYT;", + "/dev/mmcblk1:31116288s:sd/mmc:512:512:gpt:SD SL16G::15;", + "1:40s:29360167s:29360128s:ext4:APP:;", + "2:29360168s:29360423s:256s::TBC:msftdata;", + "3:29360424s:29361319s:896s::RP1:msftdata;", + "4:29361320s:29362471s:1152s::EBT:msftdata;", + "5:29362472s:29362599s:128s::WB0:msftdata;", + "6:29362600s:29362983s:384s::BPF:msftdata;", + "7:29362984s:29363751s:768s::BPF-DTB:msftdata;", + "8:29363752s:29363879s:128s::FX:msftdata;", + "9:29363880s:29364775s:896s::TOS:msftdata;", + "10:29364776s:29365671s:896s::DTB:msftdata;", + "11:29365672s:29367207s:1536s::LNX:msftdata;", + "12:29367208s:29367335s:128s::EKS:msftdata;", + "13:29367336s:29367495s:160s::BMP:msftdata;", + "14:29367496s:29367751s:256s::RP4:msftdata;", + "15:29367752s:29629895s:262144s:fat16:EFI:boot, esp;" + }; + + vector<string> output = { + "device:/dev/mmcblk1 label:GPT region:[0, 31116288, 512 B] primary-slots:15", + "number:1 region:[40, 29360128, 512 B] type:primary id:0x83", + "number:2 region:[29360168, 256, 512 B] type:primary id:0x102", + "number:3 region:[29360424, 896, 512 B] type:primary id:0x102", + "number:4 region:[29361320, 1152, 512 B] type:primary id:0x102", + "number:5 region:[29362472, 128, 512 B] type:primary id:0x102", + "number:6 region:[29362600, 384, 512 B] type:primary id:0x102", + "number:7 region:[29362984, 768, 512 B] type:primary id:0x102", + "number:8 region:[29363752, 128, 512 B] type:primary id:0x102", + "number:9 region:[29363880, 896, 512 B] type:primary id:0x102", + "number:10 region:[29364776, 896, 512 B] type:primary id:0x102", + "number:11 region:[29365672, 1536, 512 B] type:primary id:0x102", + "number:12 region:[29367208, 128, 512 B] type:primary id:0x102", + "number:13 region:[29367336, 160, 512 B] type:primary id:0x102", + "number:14 region:[29367496, 256, 512 B] type:primary id:0x102", + "number:15 region:[29367752, 262144, 512 B] type:primary id:0xEF" + }; + + check("/dev/mmcblk1", input, output); +} + + BOOST_AUTO_TEST_CASE(parse_gpt_backup_broken) { vector<string> stdout = { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.2.71/testsuite/Utils/systemcmd.cc new/libstorage-ng-4.2.72/testsuite/Utils/systemcmd.cc --- old/libstorage-ng-4.2.71/testsuite/Utils/systemcmd.cc 2020-03-25 15:14:09.000000000 +0100 +++ new/libstorage-ng-4.2.72/testsuite/Utils/systemcmd.cc 2020-04-01 11:07:32.000000000 +0200 @@ -165,13 +165,18 @@ BOOST_AUTO_TEST_CASE(env) { vector<string> stdout = { - "C ++" + "C ++ sure" }; - setenv("LC_ALL", "en_US", 1); // will be overridden + setenv("LC_ALL", "en_US", 1); // will be overridden (by default in options.env) setenv("FUNNY", "++", 1); // will not be overridden + setenv("AMUSING", "no", 1); // will be overridden (by addition to options.env) - SystemCmd cmd("echo $LC_ALL $FUNNY"); + SystemCmd::Options options("echo $LC_ALL $FUNNY $AMUSING"); + + options.env.push_back("AMUSING=sure"); + + SystemCmd cmd(options); BOOST_CHECK(cmd.retcode() == 0); BOOST_CHECK_EQUAL(join(cmd.stdout()), join(stdout));