Pkglist-query: Difference between revisions
(init off email) |
m (reduce code font size too) |
||
Line 14: | Line 14: | ||
The source for <tt>[http://git.altlinux.org/gears/a/apt-repo-tools.git?p=apt-repo-tools.git;a=blob;f=pkglist-query.cc;hb=HEAD pkglist-query]</tt> utility follows, it should build against any librpm version available (thanks at@, legion@, glebfm@): | The source for <tt>[http://git.altlinux.org/gears/a/apt-repo-tools.git?p=apt-repo-tools.git;a=blob;f=pkglist-query.cc;hb=HEAD pkglist-query]</tt> utility follows, it should build against any librpm version available (thanks at@, legion@, glebfm@): | ||
<small> | |||
<pre> | <pre> | ||
// g++ pkglist-query.cc -o pkglist-query -lrpm -lrpmio | // g++ pkglist-query.cc -o pkglist-query -lrpm -lrpmio | ||
Line 59: | Line 60: | ||
// ex:set ts=8 sts=4 sw=4 noet: | // ex:set ts=8 sts=4 sw=4 noet: | ||
</pre> | </pre> | ||
</small> | |||
[[Category:Branches]] | [[Category:Branches]] | ||
[[ru:pkglist-query]] | [[ru:pkglist-query]] |
Latest revision as of 14:59, 17 August 2019
ALT repository metadata can be accessed directly, like:
wget -qO- http://ftp.altlinux.org/pub/distributions/ALTLinux/p9/branch/x86_64/base/pkglist.classic.xz | unxz > pkglist.classic wget -qO- http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/aarch64/base/srclist.classic.xz | unxz > srclist.classic pkglist-query '%{name}-%{version}-%{release}.%{arch}.rpm\n' pkglist.classic pkglist-query '%{name}-%{version}-%{release}.src.rpm\n' srclist.classic
The source for pkglist-query utility follows, it should build against any librpm version available (thanks at@, legion@, glebfm@):
// g++ pkglist-query.cc -o pkglist-query -lrpm -lrpmio #include <stdio.h> #include <rpm/header.h> int main(int argc, char *argv[]) { const char *progname = argv[0]; if (argc < 3) { fprintf(stderr, "Usage: %s <format> <pkglist>...\n", progname); return 2; } const char *format = argv[1]; int rc = 0; const char *pkglist; int ix = 2; while ((pkglist = argv[ix++]) != NULL) { FD_t Fd = Fopen(pkglist, "r.ufdio"); if (Ferror(Fd)) { fprintf(stderr, "%s: %s: %s\n", progname, pkglist, Fstrerror(Fd)); rc = 1; continue; } Header h; while ((h = headerRead(Fd, HEADER_MAGIC_YES)) != NULL) { const char *err = "unknown error"; char *str = headerFormat(h, format, &err); if (str == NULL) { rc = 1; fprintf(stderr, "%s: %s: %s\n", progname, pkglist, err); } else { fputs(str, stdout); free(str); } headerFree(h); } Fclose(Fd); } return rc; } // ex:set ts=8 sts=4 sw=4 noet: