update ffmpeg.git files for newer versions
[goodguy/cinelerra.git] / cinelerra-5.1 / tools / makeappimagetool / copyright_dpkgquery.cpp
1 // local includes
2 #include "includes/copyright_dpkgquery.h"
3 #include "includes/log.h"
4 #include "includes/util.h"
5 #include "includes/subprocess.h"
6
7 namespace linuxdeploy {
8     namespace core {
9         namespace copyright {
10             using namespace log;
11
12             std::vector<bf::path> DpkgQueryCopyrightFilesManager::getCopyrightFilesForPath(const bf::path& path) {
13                 subprocess::subprocess proc{{"dpkg-query", "-S", path.c_str()}};
14
15                 auto result = proc.run();
16
17                 if (result.exit_code() != 0 || result.stdout_contents().empty()) {
18                     ldLog() << LD_WARNING << "Could not find copyright files for file" << path << "using dpkg-query" << std::endl;
19                     return {};
20                 }
21
22                 auto packageName = util::split(util::splitLines(result.stdout_string())[0], ':')[0];
23
24                 if (!packageName.empty()) {
25                     auto copyrightFilePath = bf::path("/usr/share/doc") / packageName / "copyright";
26
27                     if (bf::is_regular_file(copyrightFilePath)) {
28                         return {copyrightFilePath};
29                     }
30                 } else {
31                     ldLog() << LD_WARNING << "Could not find copyright files for file" << path << "using dpkg-query" << std::endl;
32                 }
33
34                 return {};
35             }
36         }
37     }
38 }