Removed 'missing files' features (kept on branch 'missing')

git-svn-id: https://svn.code.sf.net/p/porg/code/trunk@116 8854956c-c02d-4db9-8198-7e99b8e08f37
This commit is contained in:
davidrr 2015-04-12 19:03:52 +00:00
parent c4c445c723
commit a23f808f7c
21 changed files with 141 additions and 182 deletions

View File

@ -2,24 +2,15 @@ SVN
---
General changes:
+ Fixed "double DESTDIR" bug (thanks R.J.V. Bertin).
+ Fixed "double DESTDIR" bug (thanks Rene J.V. Bertin).
+ Added support for MacOS, and perhaps MacOS X (thanks Masahiro Kasahara
and Rene J.V. Bertin).
Changes in porg:
+ New options -m and -M, for listing and counting of missing files (see man
page).
+ Better option requirement checking.
+ When calculating total sizes of packages, sizes of hardlinks to installed
files are counted only once (thanks Kardakov Slava).
+ Sizes of files are not saved into the database anymore. Now they're
calculated at runtime. Backwards compatibility with databases created with
previous versions of porg (0.x) is guaranteed.
Changes in grop:
+ Added column for missing files count in the list of packages.
Changes in scripts:

View File

@ -32,7 +32,7 @@ logme:
for dir in $(SUBDIRS); do \
( cd $$dir && $(MAKE) $@ ) 2>/dev/null; \
done && \
echo && porg -vvxfmsty porg-$(PACKAGE_VERSION)
echo && porg -vvxfsty porg-$(PACKAGE_VERSION)
## Download SVN snapshot (Read Only)
svn-ro:

View File

@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
#
AC_INIT([porg],[1.0-svn],[http://porg.sourceforge.net])
AC_INIT([porg],[svn],[http://porg.sourceforge.net])
#RELEASEDATE="16 June 2014"
RELEASEDATE="`date +'%d %B %Y'`"

View File

@ -77,30 +77,23 @@ Do not print the name of the package when listing. Useful for scripts.
.SH PACKAGE LIST OPTIONS
.TP
\fB-s, --size\fR
Print the currently installed size of the package. Sizes of hardlinks to installed
Print the installed size of the package. Sizes of hardlinks to installed
files are counted only once.
.TP
\fB-F, --nfiles\fR
Print the number of currently installed files.
.TP
\fB-M, --nfiles-miss\fR
Print the number of missing files, in parenthesis.
Print the number of installed files.
.TP
\fB-d, --date\fR
Print the installation date of the package. Double it ('\fB-dd\fR') to print
also the hour.
.TP
\fB-S, --sort\fR=\fIWORD\fR
Sort the list by WORD: 'name', 'size', 'files', 'files-miss' or 'date'.
Sort the list by WORD: 'name', 'size', 'files' or 'date'.
.SH FILE LIST OPTIONS
.TP
\fB-f, --files\fR
List the files currently installed by the package.
.TP
\fB-m, --files-miss\fR
List the missing files of the package (original - current). Use along with \fB-f\fR
to list all files (installed and missing).
List the files installed by the package.
.TP
\fB-s, --size\fR
Print the size of each file.

View File

@ -54,10 +54,6 @@ void MainTreeView::add_columns()
cell = get_column_cell_renderer(id);
cell->set_alignment(1, 0.5);
id = append_column("Files miss.", m_columns.m_nfiles_miss) - 1;
cell = get_column_cell_renderer(id);
cell->set_alignment(1, 0.5);
id = append_column("Date", m_columns.m_date) - 1;
cell = get_column_cell_renderer(id);
cell->set_alignment(1, 0.5);
@ -103,7 +99,6 @@ void MainTreeView::fill_model()
(*i)[m_columns.m_name] = (*p)->name();
(*i)[m_columns.m_size] = (*p)->size();
(*i)[m_columns.m_nfiles] = (*p)->nfiles();
(*i)[m_columns.m_nfiles_miss] = (*p)->nfiles_miss();
(*i)[m_columns.m_date] = (*p)->date();
(*i)[m_columns.m_summary] = (*p)->summary();
}

View File

@ -30,7 +30,6 @@ class MainTreeView : public Gtk::TreeView
add(m_name);
add(m_size);
add(m_nfiles);
add(m_nfiles_miss);
add(m_date);
add(m_summary);
add(m_pkg);
@ -41,7 +40,6 @@ class MainTreeView : public Gtk::TreeView
Gtk::TreeModelColumn<float> m_size;
Gtk::TreeModelColumn<int> m_date;
Gtk::TreeModelColumn<gulong> m_nfiles;
Gtk::TreeModelColumn<gulong> m_nfiles_miss;
Gtk::TreeModelColumn<Glib::ustring> m_summary;
}; // class MainTreeView::ModelColumns
@ -54,7 +52,6 @@ class MainTreeView : public Gtk::TreeView
COL_NAME,
COL_SIZE,
COL_NFILES,
COL_NFILES_MISS,
COL_DATE,
COL_SUMMARY,
NCOLS

View File

@ -36,7 +36,7 @@ Preferences::Preferences(Gtk::Window& parent)
Gtk::Grid* grid = Gtk::manage(new Gtk::Grid());
string col_names[] = { "_Name", "_Size", "_Files", "Files _miss.", "_Date", "S_ummary" };
string col_names[] = { "_Name", "_Size", "_Files", "_Date", "S_ummary" };
for (int i = 0; i < MainTreeView::NCOLS; ++i) {
m_buttons[i].set_label(col_names[i]);

View File

@ -14,6 +14,7 @@
#include <fstream>
#include <algorithm>
#include <sstream>
#include <iomanip>
using std::string;
using namespace Porg;
@ -32,7 +33,6 @@ BasePkg::BasePkg(string const& name_)
m_date(time(0)),
m_size(0),
m_nfiles(0),
m_nfiles_miss(0),
m_icon_path(),
m_url(),
m_license(),
@ -44,66 +44,66 @@ BasePkg::BasePkg(string const& name_)
{ }
//
// Read info line from log
// Each info line has the form '#<char>:<value>', where
// <char> is a single character defining the info field, and
// <value> is its value.
//
void BasePkg::read_info_line(string const& buf)
{
if (buf.size() < 3) {
assert(buf.size() > 2);
return;
}
string val(buf.substr(3));
switch (buf[1]) {
case CODE_DATE: m_date = str2num<int>(val); break;
case CODE_SIZE: m_size = str2num<float>(val); break;
case CODE_NFILES: m_nfiles = str2num<ulong>(val); break;
case CODE_CONF_OPTS: m_conf_opts = val; break;
case CODE_ICON_PATH: m_icon_path = val; break;
case CODE_SUMMARY: m_summary = val; break;
case CODE_URL: m_url = val; break;
case CODE_LICENSE: m_license = val; break;
case CODE_AUTHOR: m_author = val; break;
case CODE_DESCRIPTION:
if (!m_description.empty())
m_description += "\n";
m_description += val;
break;
default: assert(false);
}
}
void BasePkg::read_log()
{
// read '#!porg' header or die
FileStream<std::ifstream> f(m_log);
string buf;
if (!(getline(f, buf) && buf.find("#!porg") == 0))
throw Error(m_log + ": '#!porg' header missing");
int db_version = str2num<int>(buf.substr(7, 1));
Rexp re("^(/.+)\\|([0-9]+)\\|(.*)$");
//
// Read info header.
// Each line in the header has the form '#<char>:<value>', where <char> is
// a single character defining the info field, and <value> is its value.
//
while (getline(f, buf)) {
while (getline(f, buf) && buf[0] == '#') {
if (buf.size() < 3) {
assert(buf.size() > 2);
if (buf[0] == '#')
read_info_line(buf);
else if (re.exec(buf)) {
m_files.push_back(new File(re.match(1),
str2num<ulong>(re.match(2)), re.match(3)));
}
else {
assert(re.exec(buf));
continue;
}
string val(buf.substr(3));
switch (buf[1]) {
case CODE_DATE: m_date = str2num<int>(val); break;
case CODE_CONF_OPTS: m_conf_opts = val; break;
case CODE_ICON_PATH: m_icon_path = val; break;
case CODE_SUMMARY: m_summary = val; break;
case CODE_URL: m_url = val; break;
case CODE_LICENSE: m_license = val; break;
case CODE_AUTHOR: m_author = val; break;
case CODE_DESCRIPTION:
if (!m_description.empty())
m_description += "\n";
m_description += val;
break;
}
}
// Read list of logged files
if (f.eof() || buf[0] != '/')
return;
if (db_version == 0) { // old format
string::size_type p;
do {
if ((p = buf.find("|")) != string::npos)
buf.erase(p);
add_file(buf);
}
while (getline(f, buf) && buf[0] == '/');
}
else {
do { add_file(buf); }
while (getline(f, buf) && buf[0] == '/');
}
sort_files();
@ -167,6 +167,8 @@ void BasePkg::write_log() const
of << "#!porg-" PACKAGE_VERSION "\n"
<< '#' << CODE_DATE << ':' << m_date << '\n'
<< '#' << CODE_SIZE << ':' << std::setprecision(0) << std::fixed << m_size << '\n'
<< '#' << CODE_NFILES << ':' << m_nfiles << '\n'
<< '#' << CODE_AUTHOR << ':' << m_author << '\n'
<< '#' << CODE_SUMMARY << ':' << Porg::strip_trailing(m_summary, '.') << '\n'
<< '#' << CODE_URL << ':' << m_url << '\n'
@ -178,25 +180,22 @@ void BasePkg::write_log() const
// write installed files
for (const_iter f(m_files.begin()); f != m_files.end(); ++f)
of << (*f)->name() << '\n';
of << (*f)->name() << '|' << (*f)->size() << '|' << (*f)->ln_name() << '\n';
}
void BasePkg::add_file(string const& path)
void BasePkg::log_file(string const& path)
{
File* file = new File(path);
m_files.push_back(file);
if (file->is_installed()) {
m_nfiles++;
// detect hardlinks to installed files, to count their size only once
if (m_inodes.find(file->inode()) == m_inodes.end()) {
m_inodes.insert(file->inode());
m_size += file->size();
}
m_nfiles++;
// detect hardlinks to installed files, to count their size only once
if (m_inodes.find(file->inode()) == m_inodes.end()) {
m_inodes.insert(file->inode());
m_size += file->size();
}
else
m_nfiles_miss++;
}

View File

@ -29,6 +29,8 @@ class BasePkg
// codes used to identify fields in the header of log files
static char const CODE_DATE = 't';
static char const CODE_SIZE = 's';
static char const CODE_NFILES = 'f';
static char const CODE_CONF_OPTS = 'c';
static char const CODE_ICON_PATH = 'i';
static char const CODE_SUMMARY = 'S';
@ -44,7 +46,6 @@ class BasePkg
int date() const { return m_date; }
float size() const { return m_size; }
ulong nfiles() const { return m_nfiles; }
ulong nfiles_miss() const { return m_nfiles_miss; }
std::string const& name() const { return m_name; }
std::string const& log() const { return m_log; }
std::string const& base_name() const { return m_base_name; }
@ -78,9 +79,10 @@ class BasePkg
protected:
void read_info_line(std::string const&);
void sort_files(sort_t type = SORT_BY_NAME, bool reverse = false);
std::string format_description() const;
void add_file(std::string const& path);
void log_file(std::string const& path);
std::string description_str(bool debug = false) const;
std::vector<File*> m_files;
@ -92,7 +94,6 @@ class BasePkg
int m_date;
float m_size;
ulong m_nfiles;
ulong m_nfiles_miss;
std::string m_icon_path;
std::string m_url;
std::string m_license;

View File

@ -20,7 +20,6 @@ namespace Porg
SORT_BY_NAME,
SORT_BY_SIZE,
SORT_BY_NFILES,
SORT_BY_NFILES_MISS,
SORT_BY_DATE
} sort_t;

View File

@ -12,11 +12,13 @@
using std::string;
//
// Ctor. for newly logged files
//
Porg::File::File(string const& name_)
:
m_name(name_),
m_size(0),
m_installed(false),
m_inode(0),
m_ln_name()
{
@ -35,7 +37,18 @@ Porg::File::File(string const& name_)
}
m_inode = s.st_ino;
m_installed = true;
m_size = s.st_size;
}
//
// Ctor. for files read from database
//
Porg::File::File(string const& name_, ulong size_, string const& ln_name_ /* = "" */)
:
m_name(name_),
m_size(size_),
m_inode(0),
m_ln_name(ln_name_)
{ }

View File

@ -20,19 +20,18 @@ class File
public:
File(std::string const& name_);
File(std::string const& name_, ulong size_, std::string const& ln_name_ = "");
ulong size() const { return m_size; }
std::string const& name() const { return m_name; }
std::string const& ln_name() const { return m_ln_name; }
ino_t inode() const { return m_inode; }
bool is_symlink() const { return !m_ln_name.empty(); }
bool is_installed() const { return m_installed; }
private:
std::string const m_name;
ulong m_size;
bool m_installed;
// inode of file. Used to detect hardlinks.
ino_t m_inode;

View File

@ -33,8 +33,7 @@ DB::DB()
:
vector<Pkg*>(),
m_total_size(0),
m_total_files(0),
m_total_files_miss(0)
m_total_files(0)
{ }
@ -95,7 +94,6 @@ bool DB::add_pkg(string const& name)
push_back(pkg);
m_total_size += pkg->size();
m_total_files += pkg->nfiles();
m_total_files_miss += pkg->nfiles_miss();
return true;
}
catch (...)
@ -108,25 +106,21 @@ bool DB::add_pkg(string const& name)
//
// get widths for printing pkg sizes and number of files
//
void DB::get_pkg_list_widths(int& size_w, int& nfiles_w, int& nfiles_miss_w)
void DB::get_pkg_list_widths(int& size_w, int& nfiles_w)
{
size_w = Opt::print_totals() ? get_width(m_total_size) : 0;
ulong max_nfiles(Opt::print_totals() ? m_total_files : 0);
ulong max_nfiles_miss(Opt::print_totals() ? m_total_files_miss : 0);
for (iterator p(begin()); p != end(); ++p) {
size_w = max(size_w, get_width((*p)->size()));
if (!Opt::print_totals()) {
if (!Opt::print_totals())
max_nfiles = max(max_nfiles, (*p)->nfiles());
max_nfiles_miss = max(max_nfiles_miss, (*p)->nfiles_miss());
}
}
nfiles_w = get_digits(max_nfiles);
nfiles_miss_w = get_digits(max_nfiles_miss);
}
@ -238,11 +232,11 @@ void DB::del_pkg(string const& name)
void DB::list()
{
//XXX class members
int size_w = 0, nfiles_w = 0, nfiles_miss_w = 0;
int size_w = 0, nfiles_w = 0;
if (Opt::print_sizes() || Opt::print_nfiles() || Opt::print_nfiles_miss()) {
if (Opt::print_sizes() || Opt::print_nfiles()) {
// get widths for printing pkg sizes and number of files
get_pkg_list_widths(size_w, nfiles_w, nfiles_miss_w);
get_pkg_list_widths(size_w, nfiles_w);
}
// sort list of packages
@ -254,7 +248,7 @@ void DB::list()
// list packages
for (iterator p(begin()); p != end(); ++p)
(*p)->list(size_w, nfiles_w, nfiles_miss_w);
(*p)->list(size_w, nfiles_w);
// print totals, if needed
@ -266,9 +260,6 @@ void DB::list()
if (Opt::print_nfiles())
cout << setw(nfiles_w) << m_total_files << " ";
if (Opt::print_nfiles_miss())
cout << "(" << setw(nfiles_miss_w) << m_total_files_miss << ") ";
if (Opt::print_date())
cout << fmt_date(0, Opt::print_hour()) << " ";
@ -302,11 +293,10 @@ DB::Sorter::Sorter(sort_t const& t /* = SORT_BY_NAME */)
m_sort_func()
{
switch (t) {
case SORT_BY_SIZE: m_sort_func = &Sorter::sort_by_size; break;
case SORT_BY_NFILES: m_sort_func = &Sorter::sort_by_nfiles; break;
case SORT_BY_NFILES_MISS: m_sort_func = &Sorter::sort_by_nfiles_miss; break;
case SORT_BY_DATE: m_sort_func = &Sorter::sort_by_date; break;
default: m_sort_func = &Sorter::sort_by_name;
case SORT_BY_SIZE: m_sort_func = &Sorter::sort_by_size; break;
case SORT_BY_NFILES: m_sort_func = &Sorter::sort_by_nfiles; break;
case SORT_BY_DATE: m_sort_func = &Sorter::sort_by_date; break;
default: m_sort_func = &Sorter::sort_by_name;
}
}
@ -331,11 +321,6 @@ bool DB::Sorter::sort_by_nfiles(Pkg* left, Pkg* right) const
return left->nfiles() < right->nfiles();
}
bool DB::Sorter::sort_by_nfiles_miss(Pkg* left, Pkg* right) const
{
return left->nfiles_miss() < right->nfiles_miss();
}
bool DB::Sorter::sort_by_date(Pkg* left, Pkg* right) const
{
return left->date() > right->date();

View File

@ -37,7 +37,7 @@ class DB : public std::vector<Pkg*>
protected:
void get_pkg_list_widths(int&, int&, int&);
void get_pkg_list_widths(int&, int&);
int get_file_size_width();
bool add_pkg(std::string const& name);
void del_pkg(std::string const& name);
@ -55,14 +55,12 @@ class DB : public std::vector<Pkg*>
bool sort_by_name(Pkg* left, Pkg* right) const;
bool sort_by_size(Pkg* left, Pkg* right) const;
bool sort_by_nfiles(Pkg* left, Pkg* right) const;
bool sort_by_nfiles_miss(Pkg* left, Pkg* right) const;
bool sort_by_date(Pkg* left, Pkg* right) const;
}; // class DB::Sorter
float m_total_size;
ulong m_total_files;
ulong m_total_files_miss;
}; // class DB

View File

@ -29,7 +29,7 @@ NewPkg::NewPkg(string const& name_, set<string> const& files_)
BasePkg(name_)
{
for (set<string>::const_iterator f(files_.begin()); f != files_.end(); ++f)
add_file(*f);
log_file(*f);
if (m_files.empty())
throw Error(m_name + ": No files to log");;

View File

@ -30,9 +30,7 @@ namespace Porg
bool Opt::s_exact_version = false;
bool Opt::s_print_sizes = false;
bool Opt::s_print_nfiles = false;
bool Opt::s_print_nfiles_miss = false;
bool Opt::s_list_files = false;
bool Opt::s_list_files_miss = false;
bool Opt::s_print_totals = false;
bool Opt::s_print_symlinks = false;
bool Opt::s_print_no_pkg_name = false;
@ -87,8 +85,6 @@ Opt::Opt(int argc, char* argv[])
OPT_INFO = 'i',
OPT_LOGDIR = 'L',
OPT_LOG = 'l',
OPT_FILES_MISS = 'm',
OPT_NFILES_MISS = 'M',
OPT_CONF_OPTS = 'o',
OPT_PACKAGE = 'p',
OPT_LOG_MISSING = 'j',
@ -120,9 +116,7 @@ Opt::Opt(int argc, char* argv[])
{ "sort", 1, 0, OPT_SORT },
{ "size", 0, 0, OPT_SIZE },
{ "nfiles", 0, 0, OPT_NFILES },
{ "nfiles-miss", 0, 0, OPT_NFILES_MISS },
{ "files", 0, 0, OPT_FILES },
{ "files-miss", 0, 0, OPT_FILES_MISS },
{ "reverse", 0, 0, OPT_REVERSE },
{ "total", 0, 0, OPT_TOTAL },
{ "symlinks", 0, 0, OPT_SYMLINKS },
@ -184,7 +178,6 @@ Opt::Opt(int argc, char* argv[])
case OPT_INFO: set_mode(MODE_INFO, c); break;
case OPT_CONF_OPTS: set_mode(MODE_CONF_OPTS, c); break;
case OPT_QUERY: set_mode(MODE_QUERY, c); break;
case OPT_FILES_MISS:
case OPT_FILES: set_mode(MODE_LIST_FILES, c); break;
case OPT_LOG: set_mode(MODE_LOG, c); break;
case OPT_REMOVE: set_mode(MODE_REMOVE, c); break;
@ -243,10 +236,6 @@ Opt::Opt(int argc, char* argv[])
s_list_files = true;
break;
case OPT_FILES_MISS:
s_list_files_miss = true;
break;
case OPT_DATE:
check_mode(MODE_LIST_PKGS, c);
s_print_hour = s_print_date;
@ -258,11 +247,6 @@ Opt::Opt(int argc, char* argv[])
s_print_nfiles = true;
break;
case OPT_NFILES_MISS:
check_mode(MODE_LIST_PKGS, c);
s_print_nfiles_miss = true;
break;
case OPT_SYMLINKS:
check_mode(MODE_LIST_FILES, c);
s_print_symlinks = true;
@ -324,7 +308,7 @@ Opt::Opt(int argc, char* argv[])
switch (c) {
case OPT_SYMLINKS:
check_required(c, string(1, OPT_FILES) + OPT_FILES_MISS);
check_required(c, string(1, OPT_FILES));
break;
case OPT_SKIP:
@ -349,12 +333,12 @@ Opt::Opt(int argc, char* argv[])
case OPT_NO_PACKAGE_NAME:
if (s_mode == MODE_LIST_PKGS) {
check_required(c, string(1, OPT_SIZE) + OPT_NFILES
+ OPT_NFILES_MISS + OPT_DATE + OPT_FILES + OPT_FILES_MISS);
+ OPT_DATE + OPT_FILES);
}
break;
case OPT_TOTAL:
check_required(c, string(1, OPT_SIZE) + OPT_NFILES + OPT_NFILES_MISS);
check_required(c, string(1, OPT_SIZE) + OPT_NFILES);
break;
}
@ -452,8 +436,6 @@ void Opt::set_sort_type(string const& s)
s_sort_type = SORT_BY_DATE;
else if (!s.compare(0, s.size(), "files", s.size()))
s_sort_type = SORT_BY_NFILES;
else if (!s.compare(0, s.size(), "files-miss", s.size()))
s_sort_type = SORT_BY_NFILES_MISS;
else if (!s.compare(0, s.size(), "name", s.size()))
s_sort_type = SORT_BY_NAME;
else
@ -462,7 +444,6 @@ void Opt::set_sort_type(string const& s)
switch (s_sort_type) {
case SORT_BY_DATE:
case SORT_BY_NFILES:
case SORT_BY_NFILES_MISS:
if (s_mode != MODE_LIST_PKGS)
die_help("'" + s + "': Invalid argument for option '-S|--sort'");
default: break;
@ -491,12 +472,9 @@ cout <<
" -d, --date Print the installation day (-dd prints the hour too).\n"
" -s, --size Print the installed size of the package.\n"
" -F, --nfiles Print the number of installed files.\n"
" -M, --nfiles-miss Print the number of missing files.\n"
" -S, --sort=WORD Sort by WORD: 'name', 'date', 'size', 'files' or\n"
" 'files-miss'.\n\n"
" -S, --sort=WORD Sort by WORD: 'name', 'date', 'size' or 'files'.\n\n"
"File list options:\n"
" -f, --files List the files installed by the package.\n"
" -m, --files-miss List the missing files of the package.\n"
" -s, --size Print the size of each file.\n"
" -y, --symlinks Print the contents of symbolic links.\n"
" -S, --sort=WORD Sort by WORD: 'name' or 'size'.\n\n"

View File

@ -41,9 +41,7 @@ class Opt : public BaseOpt
static bool exact_version() { return s_exact_version; }
static bool print_sizes() { return s_print_sizes; }
static bool print_nfiles() { return s_print_nfiles; }
static bool print_nfiles_miss() { return s_print_nfiles_miss; }
static bool list_files() { return s_list_files; }
static bool list_files_miss() { return s_list_files_miss; }
static bool print_totals() { return s_print_totals; }
static bool print_symlinks() { return s_print_symlinks; }
static bool print_no_pkg_name() { return s_print_no_pkg_name; }
@ -72,9 +70,7 @@ class Opt : public BaseOpt
static bool s_exact_version;
static bool s_print_sizes;
static bool s_print_nfiles;
static bool s_print_nfiles_miss;
static bool s_list_files;
static bool s_list_files_miss;
static bool s_print_totals;
static bool s_print_symlinks;
static bool s_print_no_pkg_name;

View File

@ -56,7 +56,7 @@ void Pkg::append(set<string> const& files_)
for (set<string>::const_iterator f(files_.begin()); f != files_.end(); ++f) {
if (!find_file(*f)) {
add_file(*f);
log_file(*f);
appended = true;
}
}
@ -80,7 +80,7 @@ void Pkg::unlog() const
}
void Pkg::list(int size_w, int nfiles_w, int nfiles_miss_w) const
void Pkg::list(int size_w, int nfiles_w) const
{
if (Opt::print_sizes())
cout << setw(size_w) << fmt_size(m_size) << " ";
@ -88,9 +88,6 @@ void Pkg::list(int size_w, int nfiles_w, int nfiles_miss_w) const
if (Opt::print_nfiles())
cout << setw(nfiles_w) << m_nfiles << " ";
if (Opt::print_nfiles_miss())
cout << "(" << setw(nfiles_miss_w) << m_nfiles_miss << ") ";
if (Opt::print_date())
cout << fmt_date(m_date, Opt::print_hour()) << " ";
@ -110,11 +107,7 @@ void Pkg::list_files(int size_w)
for (const_iter f(m_files.begin()); f != m_files.end(); ++f) {
if (((*f)->is_installed() && !Opt::list_files())
|| (!(*f)->is_installed() && !Opt::list_files_miss()))
continue;
else if (Opt::print_sizes())
if (Opt::print_sizes())
cout << setw(size_w) << fmt_size((*f)->size()) << " ";
cout << (*f)->name();

View File

@ -30,7 +30,7 @@ class Pkg : public BasePkg
void remove(DB const&);
void print_conf_opts(bool print_pkg_name) const;
void print_info() const;
void list(int, int, int) const;
void list(int, int) const;
void list_files(int size_w);
void append(std::set<std::string> const& files);

View File

@ -10,7 +10,6 @@
me=$(basename $0)
sed_cmd=@SED@
porg_version=@PACKAGE_VERSION@
die() { echo "$me: $*"; exit 1; }
sayf() { [ "$opt_verb" ] && printf "$*"; }
@ -42,6 +41,10 @@ EOF
exit 0
}
# Get version of porg
porg_version=$(porg --version | grep --only-matching '^porg[^ ]*') || exit 1
# Default log directories
for p in paco porg; do
@ -61,7 +64,7 @@ while [ "$1" ]; do
case $1 in
-v|--verbose) opt_verb=-v;;
-f|--force) opt_force=-f;;
-V|--version) echo "$me-$porg_version"; exit 0;;
-V|--version) porg --version | sed "s/^porg/$me/"; exit 0;;
--paco-logdir=*)
paco_dir=${1#*=}
[ "$paco_dir" ] || die "Option '${1%=*}' requires an argument"
@ -118,6 +121,10 @@ for paco_log in $(find $paco_dir -maxdepth 1 -type f); do
$sed_cmd -n 's/^#d:/#t:/p' $paco_log >> $porg_log
line=$($sed_cmd -n '/^##:/ s///p' $paco_log)
echo "#s:$(($(echo $line | cut -s -f 1-2 -d '|' --output-delimiter=+)))" >> $porg_log
echo "#f:$(($(echo $line | cut -s -f 3-4 -d '|' --output-delimiter=+)))" >> $porg_log
echo "#a:$($sed_cmd -n '/^#:Author: */ s///p' $paco_log)" >> $porg_log
echo "#S:$($sed_cmd -n '/^#:Summary: */ s///p' $paco_log)" >> $porg_log
echo "#u:$($sed_cmd -n '/^#:URL: */ s///p' $paco_log)" >> $porg_log
@ -136,19 +143,35 @@ for paco_log in $(find $paco_dir -maxdepth 1 -type f); do
for buf in $($sed_cmd -n '/^-\?\// s//\//p' $paco_log); do
path=${buf%%|*}
size=0
symlink=
size_raw=$(echo $buf | cut -f2 -d '|')
size_gz=$(echo $buf | cut -f3 -d '|')
size_bz2=$(echo $buf | cut -f4 -d '|')
if [ "$size_raw" -ne 0 ]; then
echo $path >> $porg_log
elif [ "$size_gz" -ne 0 ]; then
echo ${path}.gz >> $porg_log
elif [ "$size_bz2" -ne 0 ]; then
echo ${path}.bz2 >> $porg_log
if [ "$size_raw" -ge 0 ]; then
size=$size_raw
elif [ "$size_raw" = -1 ]; then
symlink=$(readlink $path)
elif [ "$size_gz" -ge 0 ]; then
path=${path}.gz
size=$size_gz
elif [ "$size_gz" = -1 ]; then
path=${path}.gz
symlink=$(readlink $path)
elif [ "$size_bz2" -ge 0 ]; then
path=${path}.bz2
size=$size_bz2
elif [ "$size_bz2" = -1 ]; then
path=${path}.bz2
symlink=$(readlink $path)
fi
[ "$symlink" ] && size=${#symlink}
echo "$path|$size|$symlink" >> $porg_log
done
sayf "done\n"

View File

@ -14,7 +14,6 @@ sed_cmd=@SED@
warn() { echo "$me: $*" >&2; exit_status=1; }
die() { warn "$*"; exit 1; }
say() { [ "$opt_verb" ] && echo "$*"; }
do_version() { porg -V | $sed_cmd "s/^porg/$me/"; exit 0; }
do_help()
@ -176,7 +175,7 @@ while [ "$1" ]; do
case $1 in
-V|--version) do_version;;
-V|--version) porg --version | $sed_cmd "s/^porg/$me/"; exit 0;;
-h|--help) do_help;;
-t|--test) opt_test=-t;;
-v|--verbose) opt_verb=-v;;