int LocalPackage::create_md5() { string sys="md5sum "+filename; string md5str=psystem(sys); if (md5str.empty()) { mError("Unable to get MD5 from " + filename); return 1; } md5str = md5str.substr(0,32); data.set_md5(md5str); xmlNewChild(_packageXMLNode, NULL, (const xmlChar *)"md5", (const xmlChar *)md5str.c_str()); return 0; }
void PlayMovie(void){ char command_line[1024], moviefile_path[1024]; if(play_movie_now==0)return; if(file_exists(get_moviefile_path(moviefile_path)) == 1){ strcpy(command_line, "ffplay "); strcat(command_line,moviefile_path); psystem(command_line); } else{ PRINTF("*** Error: the movie file, %s, does not exist\n", moviefile_path); } }
PkgScanResults checkRevDeps(const PACKAGE &pkg, bool fast, bool skip_symbols) { //printf("Running check for %s\n", pkg.get_name().c_str()); PkgScanResults ret; // Check if package has files filled in, if no - report error and return empty results. This check includes that package is installed and checkable. if (pkg.get_files().empty()) { //mError("FATAL: package " + pkg.get_name() + " has no files filled in, check impossible\n"); return ret; } // Now go scanning string fname; vector<string> data; string ld_preload; string ldd_options; if (!skip_symbols) ldd_options = " -r "; // Create LD_LIBRARY_PATH variable. For this, we need a full list of .so paths of package vector<string> ld_paths; bool ld_found; for (size_t i=0; i<pkg.get_files().size(); ++i) { if (pkg.get_files().at(i).find(".so")==pkg.get_files().at(i).size()-3) { ld_found = false; for (size_t t=0; !ld_found && t<ld_paths.size(); ++t) { if (ld_paths[t]==getDirectory(pkg.get_files().at(i))) ld_found = true; } if (!ld_found) ld_paths.push_back(getDirectory(pkg.get_files().at(i))); } } string ld_library_path, orig_library_path; if (getenv("LD_LIBRARY_PATH")) orig_library_path = getenv("LD_LIBRARY_PATH"); ld_library_path = orig_library_path; for (size_t i=0; i<ld_paths.size(); ++i) { if (ld_library_path.size()>0) ld_library_path += ":"; ld_library_path += "/" + ld_paths[i]; } string cmdstring; setenv("LD_LIBRARY_PATH", ld_library_path.c_str(), 1); for (size_t i=0; i<pkg.get_files().size(); ++i) { fname = pkg.get_files().at(i); //printf("Scanning file %s\n", fname.c_str()); if (fast) { if (fname.find("usr/lib")!=0 && fname.find("usr/bin/")!=0 && fname.find("bin/")!=0 && fname.find("sbin/")!=0 && fname.find("usr/sbin/")!=0) continue; } // Skip directories and special dirs with huge amount of files if (fname.empty() || fname[fname.size()-1]=='/' || fname.find("etc/")==0 || fname.find("dev/")==0 || fname.find("lib/modules/")==0 || fname.find("usr/share/")==0 || fname.find("usr/man/")==0 || fname.find("usr/include/")==0 || fname.find("usr/doc/")==0 || fname.find("usr/lib/locale/")==0 || fname.find("usr/lib64/locale/")==0 || fname.find("opt/")==0) continue; // Skip non-executable ones if (fast && access(string("/" + fname).c_str(), X_OK)) continue; // Too slow, disabled //msay("[" + pkg.get_name() + ": errs: " + IntToStr(ret.symbolErrors.size() + ret.notFoundErrors.size()) + "] [" + IntToStr(i+1) + "/" + IntToStr(pkg.get_files().size()) + "]: /" + fname); if (fname.find("usr/lib/")==0 && fname.find("python")!=std::string::npos) ld_preload = "LD_PRELOAD=/usr/lib/libpython2.6.so "; else if (fname.find("usr/lib64/")==0 && fname.find("python")!=std::string::npos) ld_preload = "LD_PRELOAD=/usr/lib64/libpython2.6.so "; else ld_preload = ""; cmdstring = "LD_PRELOAD=" + ld_preload + " LD_LIBRARY_PATH=" + ld_library_path + " ldd " + ldd_options + " '" + SYS_ROOT + fname + "' 2>&1 | grep -P 'undefined symbol|not found'"; data = MakeStrings(psystem(cmdstring)); if (data.empty()) { //printf("CMDLINE WAS: %s\n", cmdstring.c_str()); //printf("Nothing for %s, continue\n", fname.c_str()); continue; } //printf("Parsing data for file %s, found %d records\n", fname.c_str(), data.size()); ret.parseData(fname, data); } if (orig_library_path.empty()) unsetenv("LD_LIBRARY_PATH"); else setenv("LD_LIBRARY_PATH", orig_library_path.c_str(), 1); return ret; }
string getLZExtractedSize(const string& filename) { string cmd = "lzcat " + filename + " | wc -c"; string size = psystem(cmd); return size; }
string getGZExtractedSize(const string& filename) { string cmd = "gzip -l " + filename + " | tail -n 1 | sed 's/^\\s*[0-9]*\\s*//' | sed 's/\\s.*//g'"; string size = psystem(cmd); return size; }
string getXZExtractedSize(const string& filename) { string cmd = "xz --robot -l " + filename + " | grep totals | sed 's/\\s/\\n/g' | head -n 5 | tail -n 1"; string size = psystem(cmd); return size; }