Skip to content

Commit

Permalink
Implement installed size representation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kharacternyk committed Dec 29, 2020
1 parent 5bfad3e commit b9b6cc1
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 6 deletions.
32 changes: 27 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ Usage

Run ``pacwall``.

The blue dots are manually (explicitly) installed packages, the red ones are
automatically (implicitly) installed packages. The green dots are packages not found
in the official non-testing repositories (e.g. from the AUR). The outlined teal dots
are orphans, the outlined yellow dots are outdated packages. The outlined magenta
dots are packages with unresolved `.pacnew files`_ (it's time to run ``pacdiff``).
The circles represent packages, where the area of a circle is proportional to the
size of the package.
The blue circles are manually (explicitly) installed packages, the red ones are
automatically (implicitly) installed packages. The green circles are packages not found
in the official non-testing repositories (e.g. from the AUR). The outlined teal circles
are orphans, the outlined yellow circles are outdated packages. The outlined magenta
circles are packages with unresolved `.pacnew files`_ (it's time to run ``pacdiff``).
The dashed edges represent optional dependencies, the normal edges represent strict
(hard, direct) dependencies. The appearance is customizable, see Customization_.

Expand Down Expand Up @@ -253,6 +255,26 @@ List of settings

The attributes that are applied to optional dependencies (separated by commas).

* ``features`` (group)

The group that contains settings that control optional features.

* ``installed-size`` (group) (default::

enabled: true
delta: 2e-5
)

The group that contains settings that control the installed size representation
feature. If ``enabled`` is true, the ``height`` and ``width`` attributes of nodes
are overwritten so that the area covered by a node is proportional to the size of
the installed package. The formula is::

width in inches = height in inches = (installed size in bytes)^(1/2) * delta

Note that the values of these settings are not strings and omit the quotes enclosing
them.

---------------
Tips and tricks
---------------
Expand Down
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ DEPS = libalpm libconfig

CFLAGS ?= -g -Wall
CFLAGS += $(shell pkg-config --cflags $(DEPS))
LDLIBS += $(shell pkg-config --libs-only-l $(DEPS))
LDLIBS += $(shell pkg-config --libs-only-l $(DEPS)) -lm
LDFLAGS += $(shell pkg-config --libs-only-other $(DEPS))

pacwall: pacwall.o generate.o opts.o
Expand Down
8 changes: 8 additions & 0 deletions src/generate.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "generate.h"
#include "util.h"
#include <alpm.h>
#include <math.h>
#include <unistd.h>

static void write_updates(FILE *file, const struct opts *opts) {
Expand Down Expand Up @@ -127,6 +128,13 @@ void generate_graph(pid_t fetch_pid, const struct opts *opts) {
opts->attributes.dependency.optional);
}

/* Installed size representation */
if (opts->features.installed_size.enabled) {
double size =
sqrt(alpm_pkg_get_isize(pkg)) * opts->features.installed_size.delta;
fprintf(file, "\"%s\" [width=%lf, height=%lf];\n", name, size, size);
}

FREELIST(requiredby);
FREELIST(optionalfor);
}
Expand Down
12 changes: 12 additions & 0 deletions src/opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ struct opts parse_opts(int argc, char **argv) {
.optional = "arrowhead=empty, style=dashed",
}
},
.features = {
.installed_size = {
.enabled = 1,
.delta = 2e-5
}
},
._skip_fetch = 0,
._skip_generate = 0,
._skip_hook = 0
Expand Down Expand Up @@ -154,6 +160,12 @@ struct opts parse_opts(int argc, char **argv) {
"color=\"#859900aa\"";
}

/* Parsing the features group */
config_lookup_bool(&cfg, "features.installed-size.enabled",
&opts.features.installed_size.enabled);
config_lookup_float(&cfg, "features.installed-size.delta",
&opts.features.installed_size.delta);

config_destroy(&cfg);

parse_cli_opts(&opts, argc, argv);
Expand Down
6 changes: 6 additions & 0 deletions src/opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ struct opts {
const char *optional;
} dependency;
} attributes;
struct {
struct {
int enabled;
double delta;
} installed_size;
} features;
int _skip_fetch;
int _skip_generate;
int _skip_hook;
Expand Down

0 comments on commit b9b6cc1

Please sign in to comment.