Hello community, here is the log from the commit of package brp-check-suse for openSUSE:Factory checked in at 2020-09-18 14:25:11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/brp-check-suse (Old) and /work/SRC/openSUSE:Factory/.brp-check-suse.new.4249 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "brp-check-suse" Fri Sep 18 14:25:11 2020 rev:66 rq:833502 version:84.87+git20200910.754804a Changes: -------- --- /work/SRC/openSUSE:Factory/brp-check-suse/brp-check-suse.changes 2020-08-25 09:31:52.375969759 +0200 +++ /work/SRC/openSUSE:Factory/.brp-check-suse.new.4249/brp-check-suse.changes 2020-09-18 14:27:44.683250743 +0200 @@ -1,0 +2,6 @@ +Thu Sep 10 14:50:43 UTC 2020 - [email protected] + +- Update to version 84.87+git20200910.754804a: + * Make prg-brp-symlink compile on SLE15 (#34 and #35) + +------------------------------------------------------------------- Old: ---- brp-check-suse-84.87+git20200817.346e853.tar.xz New: ---- brp-check-suse-84.87+git20200910.754804a.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ brp-check-suse.spec ++++++ --- /var/tmp/diff_new_pack.sJqT42/_old 2020-09-18 14:27:46.155252226 +0200 +++ /var/tmp/diff_new_pack.sJqT42/_new 2020-09-18 14:27:46.159252230 +0200 @@ -23,7 +23,7 @@ License: GPL-2.0-or-later Group: Development/Tools/Building Requires: perl -Version: 84.87+git20200817.346e853 +Version: 84.87+git20200910.754804a Release: 0 URL: https://github.com/openSUSE/brp-check-suse BuildRequires: gcc-c++ ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.sJqT42/_old 2020-09-18 14:27:46.199252270 +0200 +++ /var/tmp/diff_new_pack.sJqT42/_new 2020-09-18 14:27:46.199252270 +0200 @@ -1,5 +1,5 @@ <servicedata> <service name="tar_scm"> <param name="url">git://github.com/openSUSE/brp-check-suse.git</param> - <param name="changesrevision">346e8534a3952e177d3ceac6abdf44f637b7a85c</param></service> + <param name="changesrevision">c49ee24629b5649854d3e5d42d7c826d7bf72299</param></service> </servicedata> \ No newline at end of file ++++++ brp-check-suse-84.87+git20200817.346e853.tar.xz -> brp-check-suse-84.87+git20200910.754804a.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/brp-check-suse-84.87+git20200817.346e853/prg-brp-symlink/Makefile new/brp-check-suse-84.87+git20200910.754804a/prg-brp-symlink/Makefile --- old/brp-check-suse-84.87+git20200817.346e853/prg-brp-symlink/Makefile 2020-08-17 16:54:49.000000000 +0200 +++ new/brp-check-suse-84.87+git20200910.754804a/prg-brp-symlink/Makefile 2020-09-10 16:50:23.000000000 +0200 @@ -1,7 +1,7 @@ all: brp-symlink brp-symlink: main.cpp - g++ -std=c++17 main.cpp -o brp-symlink + g++ -I. -std=c++17 main.cpp -o brp-symlink check: brp-symlink ./brp-symlink < tests.in > tests.new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/brp-check-suse-84.87+git20200817.346e853/prg-brp-symlink/main.cpp new/brp-check-suse-84.87+git20200910.754804a/prg-brp-symlink/main.cpp --- old/brp-check-suse-84.87+git20200817.346e853/prg-brp-symlink/main.cpp 2020-08-17 16:54:49.000000000 +0200 +++ new/brp-check-suse-84.87+git20200910.754804a/prg-brp-symlink/main.cpp 2020-09-10 16:50:23.000000000 +0200 @@ -1,8 +1,8 @@ #include <iostream> +#include <iterator> +#include <sstream> #include <string> -#include <filesystem> - -using namespace std; +#include <vector> // synopsis: read from stdin lines per link // IFS=| link link_dest @@ -13,25 +13,106 @@ // NOTE: // the actual file system content is of no concern here -void check_link(const string &link, const string &link_dest) { - std::filesystem::path link_path(link); - std::filesystem::path link_dest_path = link_path.parent_path().append(link_dest); - std::filesystem::path link_dest_abs(link_dest_path.lexically_normal().string()); - cout << link << "|" - << link_dest << "|" - << link_dest_abs.lexically_relative(link_path.parent_path()).string() << "|" - << link_dest_abs.string() << endl; +using namespace std; + +string append(const string& p1, const string& p2) +{ + char sep = '/'; + if (p2[0] == sep) + return p2; + + string tmp = p1; + + size_t len = p1.length(); + while (len && p1[len] != sep) + len--; + tmp.resize(len + 1); + + return (tmp + p2); +} + +vector<string> split_paths(string path) +{ + size_t pos = 0; + string token; + vector<string> paths; + while ((pos = path.find("/")) != string::npos) { + token = path.substr(0, pos); + if (token == "..") { + paths.pop_back(); + } else { + paths.push_back(token); + } + path.erase(0, pos + 1); + } + paths.push_back(path); + return paths; +} + +string merge_paths(vector<string> paths) +{ + string path; + for (const auto& s : paths) { + if (s.empty()) + continue; + if (!path.empty()) + path += "/"; + path += s; + } + + return path; +} + +string normalize(string path) +{ + vector<string> paths = split_paths(path); + return "/" + merge_paths(paths); +} + +string relative(const string& p1, const string& p2) +{ + vector<string> paths1 = split_paths(p1); + paths1.pop_back(); + vector<string> paths2 = split_paths(p2); + vector<string> paths; + vector<string>::const_iterator it1 = paths1.begin(); + vector<string>::const_iterator it2 = paths2.begin(); + // first remove the common parts + while (it1 != paths1.end() && *it1 == *it2) { + it1++; + it2++; + } + for (; it1 != paths1.end(); ++it1) { + paths.push_back(".."); + } + for (; it2 != paths2.end(); ++it2) { + paths.push_back(*it2); + } + + return merge_paths(paths); +} + +void check_link(const string& link, const string& link_dest) +{ + string link_dest_path = append(link, link_dest); + string link_dest_abs = normalize(link_dest_path); + cout << link << "|" + << link_dest << "|" + << relative(normalize(link), link_dest_abs) << "|" + << link_dest_abs << endl; } -void work_line(const string &line) { +void work_line(const string& line) +{ size_t delim = line.find('|'); - check_link("/" + line.substr(0, delim), line.substr(delim+1)); + check_link("/" + line.substr(0, delim), line.substr(delim + 1)); } -int main(int argc, char **argv) { - for (string line; std::getline(cin, line);) { - work_line(line); +int main(int argc, char** argv) +{ + for (string line; getline(cin, line);) { + work_line(line); } - return 0; + return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/brp-check-suse-84.87+git20200817.346e853/prg-brp-symlink/tests.in new/brp-check-suse-84.87+git20200910.754804a/prg-brp-symlink/tests.in --- old/brp-check-suse-84.87+git20200817.346e853/prg-brp-symlink/tests.in 2020-08-17 16:54:49.000000000 +0200 +++ new/brp-check-suse-84.87+git20200910.754804a/prg-brp-symlink/tests.in 2020-09-10 16:50:23.000000000 +0200 @@ -1372,3 +1372,4 @@ bin/vi|/usr/bin/vim bin/vim|/usr/bin/vim bin/ex|/usr/bin/vim +bin/keyctl|//usr/bin/keyctl diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/brp-check-suse-84.87+git20200817.346e853/prg-brp-symlink/tests.out new/brp-check-suse-84.87+git20200910.754804a/prg-brp-symlink/tests.out --- old/brp-check-suse-84.87+git20200817.346e853/prg-brp-symlink/tests.out 2020-08-17 16:54:49.000000000 +0200 +++ new/brp-check-suse-84.87+git20200910.754804a/prg-brp-symlink/tests.out 2020-09-10 16:50:23.000000000 +0200 @@ -1372,3 +1372,4 @@ /bin/vi|/usr/bin/vim|../usr/bin/vim|/usr/bin/vim /bin/vim|/usr/bin/vim|../usr/bin/vim|/usr/bin/vim /bin/ex|/usr/bin/vim|../usr/bin/vim|/usr/bin/vim +/bin/keyctl|//usr/bin/keyctl|../usr/bin/keyctl|/usr/bin/keyctl
