Skip to content

Commit

Permalink
etcat, FORMAT_{VERSION,}ETCAT, {*var=(color)}, <overlay{,ver}name>
Browse files Browse the repository at this point in the history
  • Loading branch information
vaeth committed Aug 5, 2016
1 parent a1485c0 commit e992457
Show file tree
Hide file tree
Showing 14 changed files with 159 additions and 11 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
to eliminate hidden bugs, although in the moment it can cause pain.
- Thanks already for some such reports to:
Michał Bartoszkiewicz <mbartoszkiewicz at gmail.com>
- Add etcat script to resemble somewhat etcat -v behaviour
- New FORMAT_ETCAT and FORMAT_VERSION_ETCAT default variables
for etcat type output
- Support colors in unquoted runtime variables
- New attributes overlay{,ver}name
- Honour ebuild md5 whenever provided (e.g. by >=portage-2.3.1)
- Make timestamp optional for assign method (e.g. for >=portage-2.3.1)
- Honour TMPDIR as requested by POSIX
Expand Down
19 changes: 16 additions & 3 deletions manpage/de-eix.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

.B eix-installed

.B eix-etcat

.B eix-functions.sh

.B eix-header
Expand Down Expand Up @@ -106,6 +108,16 @@ ausgibt, und das prüfen kann, welche Pakete mit/ohne Repository- oder Buildtime
(vgl. die Beschreibung zu B<CHECK_INSTALLED_OVERLAYS> und B<USE_BUILD_TIME>).
Mehr zu B<eix-installed> erfahren Sie durch den Aufruf B<eix-installed -h>.

B<eix-etcat> ist ein Wrapper, der eix mit einer Konfiguaration aufruft,
so dass das Verhalten ähnlich dem von B<etcat -v> aus alten
app-portage/gentoolkit Versionen oder dessen aktuelle Version von
https://github.com/proteusx/etcat/ (z.B. app-portage/etcat aus dem mv overlay)
ist.
Die Ausgabe ist analog (durch Aufruf von B<eix --print FORMAT_ETCAT> bzw.
B<eix --print FORMAT_VERSION_ETCAT> kann man die benutzten Format-Strings
anschauen), und die voreingestellte Eingabe akzeptiert eine Folge von
Paketnamen (die Angabe der Kategorie ist optional).

B<masked-packages> ist ein Hilfsprogramm für Skripte, das die Argumente gegen
eine Maskenliste testet.
Details stehen nahe am Ende dieser Manpage.
Expand Down Expand Up @@ -1265,13 +1277,14 @@ B<slotfirst>/B<slotlast> äquivalent zu B<first>/B<last>, und B<oneslot> ist 1.
Dies darf nur in I<VARIABLE> im Zusammenhang von Versionsausgaben benutzt werden.
Sie gibt die B<EAPI> einer verfügbaren oder installierten Version aus.
.TP
.BR slot ", " isslot ", " fullslot ", " isfullslot ", " subslot ", " issubslot ", "overlayver ", " overlaynum ", " virtual
.BR slot ", " isslot ", " fullslot ", " isfullslot ", " subslot ", " issubslot ", "overlayver ", " overlaynum ", " overlayvername ", " virtual
Dies darf nur in I<VARIABLE> im Zusammenhang von Versionsausgaben benutzt werden.
Es wird der aktuelle Slot bzw. der Overlay der aktuellen Version ausgegeben.
B<overlayver> ist leer, falls das gesamte Paket aus nur einem Overlay stammt;
für diesen Fall sollte B<overlaykey> zur Ausgabe des Overlays benutzt werden.
Im Gegensatz dazu enthält B<overlaynum> stets die Nummer des Overlays
(als Text ohne Farben) oder ist leer, falls die Version keinem Overlay entstammt.
B<overlayvername> ist das Label (Name) (oder Pfad für unbekanntes oder leeres Label) des Overlays.
B<virtual> ist genau dann nichtleer, wenn die Version aus einem virtuellen Overlay kommt.
B<isslot>, B<isfullslot> und B<issubslot> testen nur of Slot, voller Slot bzw. Subslot
trivial sind und geben in diesem Fall 1 aus (sonst nichts).
Expand Down Expand Up @@ -1399,8 +1412,8 @@ Vgl. die Bemerkungen zu B<--binary>.
.B mainrepo
Ist 1 oder leer, je nachdem, ob mindestens eine verfügbare Version zum Hauptrepository 0 (typischerweise: gentoo) gehört.
.TP
.B overlaykey
Falls alle Versionen zum selben Overlay gehören, wird "[overlaykey]" mit entsprechcenden Farben ausgegeben.
.BR overlaykey ", " overlayname
Falls alle Versionen zum selben Overlay gehören, wird "[overlaykey]" (in entsprechenden Farben) bzw. "overlaylabel" ausgegeben.
.TP
.BR havevirtual ", " havenonvirtual
Ist 1 or leer, je nachdem ob mindestens eine verfügbare Version aus einem (nicht)virtuellen Overlay stammt.
Expand Down
18 changes: 15 additions & 3 deletions manpage/en-eix.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

.B eix-installed

.B eix-etcat

.B eix-functions.sh

.B eix-header
Expand Down Expand Up @@ -106,6 +108,15 @@ repository or buildtime information
(cf. the description of B<CHECK_INSTALLED_OVERLAYS> and B<USE_BUILD_TIME>).
To get more help on B<eix-installed> call B<eix-installed -h>.

B<eix-etcat> is a wrapper which calls eix with a configuration such
that it resembles the behaviour of B<etcat -v> from old app-portage/gentoolkit
versions or its updated version from https://github.com/proteusx/etcat/ (e.g.
app-portage/etcat from the mv overlay).
The output is analogous (call B<eix --print FORMAT_ETCAT> and
B<eix --print FORMAT_VERSION_ETCAT> to see the relevant format strings),
and the default input accepts a sequence of (exact) package names
(the specification of the category is optional).

B<masked-packages> is a helper tool which matches the arguments against a list of masks.
Details can be found near the end of the manpage.

Expand Down Expand Up @@ -1238,13 +1249,14 @@ B<slotfirst>/B<slotlast> is equivalent to B<first>/B<last> and B<oneslot> is 1.
This must occur only in I<VARIABLE> in the context of version printing.
It outputs the B<EAPI> of an available or installed version.
.TP
.BR slot ", " isslot ", " fullslot ", " isfullslot ", " subslot ", " issubslot ", "overlayver ", " overlaynum ", " virtual
.BR slot ", " isslot ", " fullslot ", " isfullslot ", " subslot ", " issubslot ", "overlayver ", " overlaynum ", " overlayvername ", " virtual
This must occur only in I<VARIABLE> in the context of version printing.
It outputs the current slot or the overlay of the current version.
B<overlayver> is empty if the whole package is from only one overlay;
you should use B<overlaykey> to print the overlay in such a case.
B<overlaynum>, in contrast, contains the number of the overlay
without colors unconditionally (or is empty if the version is not from an overlay).
B<overlayvername> is the label (name) (or path if the label is unknown or empty) of the overlay.
B<virtual> is nonempty if and only if the version is from a virtual overlay.
B<isslot>, B<isfullslot>, B<issubslot> just test whether the slot, fullslot, or subslot are trivial and outputs 1 in this case,
otherwise nothing.
Expand Down Expand Up @@ -1375,8 +1387,8 @@ See the remarks for B<--binary>.
.B mainrepo
Is 1 or empty, depending on whether at least one available version belongs to the main repository 0 (typically: gentoo).
.TP
.B overlaykey
If all versions are in the same overlay, "[overlaykey]" is output with corresponding colors.
.BR overlaykey ", " overlayname
If all versions are in the same overlay, "[overlaykey]" (in corresponding colors) or "overlaylabel" is output.
.TP
.BR havevirtual ", " havenonvirtual
Is 1 or empty, depending on whether at least one available version is from a (non)virtual overlay.
Expand Down
3 changes: 2 additions & 1 deletion po/POTFILES.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# List of source files which contain translatable strings.
# List of source files which (possibly) contain translatable strings.
# Shell type source files
src/eix-etcat.sh
src/eix-functions.sh.in
src/eix-installed.sh
src/eix-installed-after.sh
Expand Down
3 changes: 3 additions & 0 deletions po/Rules-local
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ $(MYSRC)/eix-installed.sh:
$(MYSRC)/eix-installed-after.sh:
( cd $(MYBUILD) && $(MAKE) eix-installed-after.sh )

$(MYSRC)/eix-etcat.sh:
( cd $(MYBUILD) && $(MAKE) eix-etcat.sh )

12 changes: 11 additions & 1 deletion po/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: eix\n"
"Report-Msgid-Bugs-To: https://github.com/vaeth/eix/issues/\n"
"POT-Creation-Date: 2016-02-06 12:56+0100\n"
"POT-Creation-Date: 2016-08-05 12:34+0200\n"
"PO-Revision-Date: 2014-10-29 21:03+0100\n"
"Last-Translator: Andre Jaenisch <ryunoki@openmailbox.org>\n"
"Language-Team: German\n"
Expand Down Expand Up @@ -7185,6 +7185,16 @@ msgstr ""
"Diese Variable wird nur zur verzögerten Ersetzung benutzt.\n"
"Sie definiert das ausführliche Ausgabeformat von eix (Option -v)."

#: src/eixrc/defaults.cc
msgctxt "VERSION_ETCAT"
msgid "This format outputs a version in the style of the etcat script."
msgstr "Dieses Format gibt eine Version im Stile des etcat Skripts aus."

#: src/eixrc/defaults.cc
msgctxt "FORMAT_ETCAT"
msgid "This format outputs a package in the style of the etcat script."
msgstr "Dieses Format gibt ein Paket im Stile des etcat Skripts aus."

#: src/eixrc/defaults.cc
msgctxt "FORMAT"
msgid ""
Expand Down
12 changes: 11 additions & 1 deletion po/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ msgid ""
msgstr ""
"Project-Id-Version: eix\n"
"Report-Msgid-Bugs-To: https://github.com/vaeth/eix/issues/\n"
"POT-Creation-Date: 2016-02-06 12:56+0100\n"
"POT-Creation-Date: 2016-08-05 12:34+0200\n"
"PO-Revision-Date: 2013-05-20 00:30+0200\n"
"Last-Translator: Artem Vorotnikov <skybon@gmail.com>\n"
"Language-Team: русский <>\n"
Expand Down Expand Up @@ -6223,6 +6223,16 @@ msgid ""
"It defines the format of the verbose output of eix (option -v)."
msgstr ""

#: src/eixrc/defaults.cc
msgctxt "VERSION_ETCAT"
msgid "This format outputs a version in the style of the etcat script."
msgstr ""

#: src/eixrc/defaults.cc
msgctxt "FORMAT_ETCAT"
msgid "This format outputs a package in the style of the etcat script."
msgstr ""

#: src/eixrc/defaults.cc
msgctxt "FORMAT"
msgid ""
Expand Down
10 changes: 9 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ extra_update_only_src =
nodist_extra_update_only_src =

# Additional binaries (scripts) we will install
nodist_bin_SCRIPTS = \
nodist_bin_SCRIPTS = \
eix-functions.sh \
eix-installed \
eix-installed-after \
Expand All @@ -315,6 +315,9 @@ eix-remote \
eix-sync \
eix-test-obsolete

bin_SCRIPTS = \
eix-etcat

# Remove files we don't want ..
CLEANFILES = \
cppcomplete.tags \
Expand Down Expand Up @@ -343,6 +346,7 @@ $(srcdir)/eix-installed-after.sh \
$(srcdir)/eix-layman.sh \
$(srcdir)/eix-remote.sh \
$(srcdir)/eix-sync.sh \
$(srcdir)/eix-etcat.sh \
$(srcdir)/eix-test-obsolete.sh

# Files we need for generation in the tarball which are not canonical
Expand All @@ -353,6 +357,7 @@ eix-installed-after.in \
eix-layman.in \
eix-remote.in \
eix-sync.in \
eix-etcat \
eix-test-obsolete.in \
eixrc/00-eixrc.in \
cache/generate_cachemap.sh
Expand Down Expand Up @@ -632,6 +637,9 @@ eix-installed-after.sh:
eix-remote.sh:
$(AM_V_GEN)$(LN_S) eix-remote.in "$(srcdir)/$@"

eix-etcat.sh:
$(AM_V_GEN)$(LN_S) eix-etcat "$(srcdir)/$@"

SUFFIXES = .in
.in:
$(AM_V_GEN)$(SED) \
Expand Down
26 changes: 26 additions & 0 deletions src/eixrc/defaults.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3244,6 +3244,32 @@ AddOption(STRING, "FORMAT_ALL_VERBOSE",
"This format is only used for delayed substitution in FORMAT_VERBOSE.\n"
"It defines the format of the verbose output of eix (option -v)."));

AddOption(STRING, "FORMAT_VERSION_ETCAT",
"\\C<8>["
"{!*mask}{*color=(green,1)}"
"{ismasked}"
"{*mask}"
"{else}"
"{!isstable}{!isunstable}{*mask}{}{}"
"{}"
"{$mask}{*color=(red,1)}<$color>M(){else} {}"
"{isunstable}"
"{!$mask}{*color=(yellow,1)}{}"
"(yellow,1)~()"
"{else}"
" "
"{}"
"{installedversion}{*color=(cyan,1)}<$color>I(){else} {}"
"] <$color><version>()"
" \\(<$color><fullslot>()\\)"
"{overlayver} [<$color><overlayvername>()]{}\\n", P_("VERSION_ETCAT",
"This format outputs a version in the style of the etcat script."));

AddOption(STRING, "FORMAT_ETCAT",
"(green,1)*() (white,1)<category>/<name>() :\n"
"<availableversions:FORMAT_VERSION_ETCAT>\n", P_("FORMAT_ETCAT",
"This format outputs a package in the style of the etcat script."));

AddOption(STRING, "FORMAT",
"%{FORMAT_ALL}", P_("FORMAT",
"The format of the normal output of eix.\n"
Expand Down
27 changes: 26 additions & 1 deletion src/output/formatstring-print.cc
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ class Scanner {
prop_pkg("licenses", &PrintFormat::PKG_LICENSES);
prop_pkg("mainrepo", &PrintFormat::PKG_MAINREPO);
prop_pkg("overlaykey", &PrintFormat::PKG_OVERLAYKEY);
prop_pkg("overlayname", &PrintFormat::PKG_OVERLAYNAME);
prop_pkg("binary", &PrintFormat::PKG_BINARY);
prop_pkg("system", &PrintFormat::PKG_SYSTEM);
prop_pkg("profile", &PrintFormat::PKG_PROFILE);
Expand Down Expand Up @@ -446,6 +447,7 @@ class Scanner {
prop_ver("revision", &PrintFormat::VER_REVISION);
prop_ver("overlaynum", &PrintFormat::VER_OVERLAYNUM);
prop_ver("overlayver", &PrintFormat::VER_OVERLAYVER);
prop_ver("overlayvername", &PrintFormat::VER_OVERLAYVERNAME);
prop_ver("versionkeywords*", &PrintFormat::VER_VERSIONKEYWORDSS);
prop_ver("versionkeywords", &PrintFormat::VER_VERSIONKEYWORDS);
prop_ver("versionekeywords", &PrintFormat::VER_VERSIONEKEYWORDS);
Expand Down Expand Up @@ -815,6 +817,13 @@ void PrintFormat::PKG_OVERLAYKEY(OutputString *s, Package *package) const {
}
}

void PrintFormat::PKG_OVERLAYNAME(OutputString *s, Package *package) const {
ExtendedVersion::Overlay ov_key(package->largest_overlay);
if(ov_key && package->have_same_overlay_key()) {
s->assign_smart(header->getOverlay(ov_key).name());
}
}

void PrintFormat::PKG_MAINREPO(OutputString *s, Package *package) const {
if(package->have_main_repo_key()) {
s->set_one();
Expand Down Expand Up @@ -1119,7 +1128,7 @@ void PrintFormat::ver_overlay(OutputString *s, Package *package, bool getnum) co
}
}
} else if(getnum || (!package->have_same_overlay_key())) {
if(version_variables->version()->overlay_key) {
if(version_variables->version()->overlay_key > 0) {
overlay_keytext(s, version_variables->version()->overlay_key, getnum);
}
}
Expand All @@ -1133,6 +1142,22 @@ void PrintFormat::VER_OVERLAYVER(OutputString *s, Package *package) const {
ver_overlay(s, package, false);
}

void PrintFormat::VER_OVERLAYVERNAME(OutputString *s, Package *package) const {
ExtendedVersion::Overlay key;
eix_assert_paranoic(header != NULLPTR);
if(version_variables->isinst) {
InstVersion *i(version_variables->instver());
if(unlikely(!(vardb->readOverlay(*package, i, *header)))) {
s->assign_fast("?");
return;
}
key = i->overlay_key;
} else {
key = version_variables->version()->overlay_key;
}
s->assign_smart(header->getOverlay(key).name());
}

void PrintFormat::VER_VERSIONKEYWORDSS(OutputString *s, Package *package) const {
if(unlikely(version_variables->isinst)) {
return;
Expand Down
23 changes: 23 additions & 0 deletions src/output/formatstring.cc
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,29 @@ FormatParser::ParserState FormatParser::state_IF() {
if(!*band_position) {
break;
}
} else if((c == '(') && (parse_modus != single_quote) && (parse_modus != double_quote)) {
const char *q(++band_position);
while(isalnum(*q) || (strchr("|,;:", *q) != NULLPTR)) {
++q;
}
bool is_color(false);
if(likely(*q == ')')) {
AnsiColor ac;
GCC_DIAG_OFF(sign-conversion)
if(likely(ac.initcolor(string(band_position, q - band_position), NULLPTR))) {
GCC_DIAG_ON(sign-conversion)
is_color = true;
if(enable_colors) {
textbuffer.append(ac.asString(), 0);
}
}
}
if(likely(is_color)) {
band_position = q;
} else {
--band_position;
textbuffer.append_fast('(');
}
} else {
textbuffer.append_smart(c);
}
Expand Down
3 changes: 3 additions & 0 deletions src/output/formatstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <string>
#include <vector>

#include "database/header.h"
#include "eixTk/assert.h"
#include "eixTk/null.h"
#include "eixTk/outputstring.h"
Expand Down Expand Up @@ -270,6 +271,7 @@ class PrintFormat {
void PKG_BINARY(OutputString *s, Package *package) const ATTRIBUTE_NONNULL_;
void PKG_MAINREPO(OutputString *s, Package *package) const ATTRIBUTE_NONNULL_;
void PKG_OVERLAYKEY(OutputString *s, Package *package) const ATTRIBUTE_NONNULL_;
void PKG_OVERLAYNAME(OutputString *s, Package *package) const ATTRIBUTE_NONNULL_;
void PKG_SYSTEM(OutputString *s, Package *package) const ATTRIBUTE_NONNULL_;
void PKG_PROFILE(OutputString *s, Package *package) const ATTRIBUTE_NONNULL_;
void PKG_WORLD(OutputString *s, Package *package) const ATTRIBUTE_NONNULL_;
Expand Down Expand Up @@ -319,6 +321,7 @@ class PrintFormat {
void ver_overlay(OutputString *s, Package *package, bool getnum) const ATTRIBUTE_NONNULL_;
void VER_OVERLAYNUM(OutputString *s, Package *package) const ATTRIBUTE_NONNULL_;
void VER_OVERLAYVER(OutputString *s, Package *package) const ATTRIBUTE_NONNULL_;
void VER_OVERLAYVERNAME(OutputString *s, Package *package) const ATTRIBUTE_NONNULL_;
void VER_VERSIONKEYWORDSS(OutputString *s, Package *package) const ATTRIBUTE_NONNULL_;
void VER_VERSIONKEYWORDS(OutputString *s, Package *package) const ATTRIBUTE_NONNULL_;
void VER_VERSIONEKEYWORDS(OutputString *s, Package *package) const ATTRIBUTE_NONNULL_;
Expand Down
2 changes: 2 additions & 0 deletions src/portage/overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class OverlayIdent {

std::string human_readable() const;

std::string name() const;

static void init_static();
};

Expand Down

0 comments on commit e992457

Please sign in to comment.