7 #if defined(WITH_SQLITE)
11 extern const char *sqlite3_errmsg(sqlite3 *db)
13 extern int sqlite3_open(
18 extern int sqlite3_exec(
21 int (*callback)(
void*,
int,
char**,
char**),
26 extern int sqlite3_prepare(
30 sqlite3_stmt **ppStmt,
34 extern int sqlite3_reset(sqlite3_stmt *pStmt)
36 extern int sqlite3_step(sqlite3_stmt *pStmt)
38 extern int sqlite3_finalize( sqlite3_stmt *pStmt)
40 extern int sqlite3_close(sqlite3 * db)
88 const char ** sql_fini;
110 #if defined(WITH_SQLITE)
143 const char * groupfile;
146 #if defined(WITH_SQLITE)
198 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
199 "<metadata xmlns=\"http://linux.duke.edu/metadata/common\" xmlns:rpm=\"http://linux.duke.edu/metadata/rpm\" packages=\"0\">\n";
205 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
206 "<filelists xmlns=\"http://linux.duke.edu/metadata/filelists\" packages=\"0\">\n";
212 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
213 "<otherdata xmlns=\"http://linux.duke.edu/metadata/other\" packages=\"0\">\n";
219 <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
220 <repomd xmlns=\"http://linux.duke.edu/metadata/repo\">\n";
227 #include "yum_primary_xml"
232 #include "yum_filelists_xml"
237 #include "yum_other_xml"
242 #include "wnh_primary_yaml"
247 #include "wnh_filelists_yaml"
252 #include "wnh_other_yaml"
257 #include "deb_Packages"
262 #include "deb_Sources"
268 "PRAGMA synchronous = \"OFF\";",
269 "pragma locking_mode = \"EXCLUSIVE\";",
270 "CREATE TABLE conflicts ( pkgKey INTEGER, name TEXT, flags TEXT, epoch TEXT, version TEXT, release TEXT );",
271 "CREATE TABLE db_info (dbversion INTEGER, checksum TEXT);",
272 "CREATE TABLE files ( pkgKey INTEGER, name TEXT, type TEXT );",
273 "CREATE TABLE obsoletes ( pkgKey INTEGER, name TEXT, flags TEXT, epoch TEXT, version TEXT, release TEXT );",
274 "CREATE TABLE packages ( pkgKey INTEGER PRIMARY KEY, pkgId TEXT, name TEXT, arch TEXT, version TEXT, epoch TEXT, release TEXT, summary TEXT, description TEXT, url TEXT, time_file INTEGER, time_build INTEGER, rpm_license TEXT, rpm_vendor TEXT, rpm_group TEXT, rpm_buildhost TEXT, rpm_sourcerpm TEXT, rpm_header_start INTEGER, rpm_header_end INTEGER, rpm_packager TEXT, size_package INTEGER, size_installed INTEGER, size_archive INTEGER, location_href TEXT, location_base TEXT, checksum_type TEXT);",
275 "CREATE TABLE provides ( pkgKey INTEGER, name TEXT, flags TEXT, epoch TEXT, version TEXT, release TEXT );",
276 "CREATE TABLE requires ( pkgKey INTEGER, name TEXT, flags TEXT, epoch TEXT, version TEXT, release TEXT );",
277 "CREATE INDEX filenames ON files (name);",
278 "CREATE INDEX packageId ON packages (pkgId);",
279 "CREATE INDEX packagename ON packages (name);",
280 "CREATE INDEX pkgconflicts on conflicts (pkgKey);",
281 "CREATE INDEX pkgobsoletes on obsoletes (pkgKey);",
282 "CREATE INDEX pkgprovides on provides (pkgKey);",
283 "CREATE INDEX pkgrequires on requires (pkgKey);",
284 "CREATE INDEX providesname ON provides (name);",
285 "CREATE INDEX requiresname ON requires (name);",
286 "CREATE TRIGGER removals AFTER DELETE ON packages\
288 \n DELETE FROM files WHERE pkgKey = old.pkgKey;\
289 \n DELETE FROM requires WHERE pkgKey = old.pkgKey;\
290 \n DELETE FROM provides WHERE pkgKey = old.pkgKey;\
291 \n DELETE FROM conflicts WHERE pkgKey = old.pkgKey;\
292 \n DELETE FROM obsoletes WHERE pkgKey = old.pkgKey;\
294 "INSERT into db_info values (9, 'direct_create');",
301 "PRAGMA synchronous = \"OFF\";",
302 "pragma locking_mode = \"EXCLUSIVE\";",
303 "CREATE TABLE db_info (dbversion INTEGER, checksum TEXT);",
304 "CREATE TABLE filelist ( pkgKey INTEGER, name TEXT, type TEXT );",
305 "CREATE TABLE packages ( pkgKey INTEGER PRIMARY KEY, pkgId TEXT);",
306 "CREATE INDEX filelistnames ON filelist (name);",
307 "CREATE INDEX keyfile ON filelist (pkgKey);",
308 "CREATE INDEX pkgId ON packages (pkgId);",
309 "CREATE TRIGGER remove_filelist AFTER DELETE ON packages\
311 \n DELETE FROM filelist WHERE pkgKey = old.pkgKey;\
313 "INSERT into db_info values (9, 'direct_create');",
320 "PRAGMA synchronous = \"OFF\";",
321 "pragma locking_mode = \"EXCLUSIVE\";",
322 "CREATE TABLE changelog ( pkgKey INTEGER, author TEXT, date INTEGER, changelog TEXT);",
323 "CREATE TABLE db_info (dbversion INTEGER, checksum TEXT);",
324 "CREATE TABLE packages ( pkgKey INTEGER PRIMARY KEY, pkgId TEXT);",
325 "CREATE INDEX keychange ON changelog (pkgKey);",
326 "CREATE INDEX pkgId ON packages (pkgId);",
327 "CREATE TRIGGER remove_changelogs AFTER DELETE ON packages\
329 \n DELETE FROM changelog WHERE pkgKey = old.pkgKey;\
331 "INSERT into db_info values (9, 'direct_create');",
393 #include "yum_primary_sqlite"
404 #include "yum_filelists_sqlite"
416 #include "yum_other_sqlite"
423 #if defined(WITH_SQLITE)
426 .tempdir =
".repodata",
427 .finaldir =
"repodata",
428 .olddir =
".olddata",
445 .Packages_init= NULL,
446 .Packages_qfmt= NULL,
447 .Packages_fini= NULL,
465 .Packages_init= NULL,
466 .Packages_qfmt= NULL,
467 .Packages_fini= NULL,
485 .Packages_init= NULL,
486 .Packages_qfmt= NULL,
487 .Packages_fini= NULL,
505 .Packages_init= NULL,
507 .Packages_fini= NULL,
535 (void) vfprintf(stderr, fmt, ap);
537 (void) fprintf(stderr,
"\n");
550 const char * item,
int current,
int total)
554 static size_t ncols = 80 - 1;
555 const char * bn = (item != NULL ? strrchr(item,
'/') : NULL);
562 nb = fprintf(stdout,
"\r%s: %d/%d",
__progname, current, total);
564 nb += fprintf(stdout,
" - %s", bn);
567 fprintf(stdout,
"%*s", (
int)(ncols - nb),
"");
569 (void) fflush(stdout);
581 return (
Stat(fn, st) == 0);
597 stctime = sb.st_ctime;
612 const char *rpath =
Realpath(lpath, NULL);
643 rc = (
Mkdir(dnurl, 0755) == 0 ||
errno == EEXIST ? 0 : -1);
646 dnurl =
_free(dnurl);
658 const char * type,
int compress)
664 (repo->
suffix != NULL && compress ? repo->
suffix :
""), NULL);
677 struct stat sb, *st = &sb;
684 if (directories != NULL)
685 while ((dn = *directories++) != NULL) {
686 if (!
rpmioExists(dn, st) || !S_ISDIR(st->st_mode)) {
708 repo_error(0,
_(
"Old data directory exists, please remove: %s"), dn);
714 static const char * dirs[] = {
".repodata",
"repodata", NULL };
716 static const char * types[] =
717 {
"primary",
"filelists",
"other",
"repomd", NULL };
718 const char ** dirp, ** typep;
719 for (dirp = dirs; *dirp != NULL; dirp++) {
720 for (typep = types; *typep != NULL; typep++) {
721 fn =
repoGetPath(repo, *dirp, *typep, strcmp(*typep,
"repomd"));
736 if (repo->groupfile != NULL) {
737 if (repo->
split || repo->groupfile[0] !=
'/') {
738 fn =
rpmGetPath(repo->package_dir,
"/", repo->groupfile, NULL);
739 repo->groupfile =
_free(repo->groupfile);
740 repo->groupfile = fn;
744 repo_error(0,
_(
"groupfile %s cannot be found."), repo->groupfile);
758 static int chkSuffix(
const char * fn,
const char * suffix)
761 size_t flen = strlen(fn);
762 size_t slen = strlen(suffix);
763 return (flen > slen && !strcmp(fn + flen - slen, suffix));
779 const char ** pkglist = NULL;
789 const char * fts_name = p->
fts_name;
793 if (p->
fts_level == 0 && fts_namelen == 0) {
795 fts_namelen =
sizeof(
".") - 1;
850 for (pkg = repo->
pkglist; *pkg != NULL ; pkg++) {
851 struct stat sb, *st = &sb;
874 size_t nspew = (spew != NULL ? strlen(spew) : 0);
876 size_t nb = (nspew > 0 ?
Fwrite(spew, 1, nspew, rfile->
fd) : 0);
880 repo_error(0,
_(
"Fwrite failed: expected write %u != %u bytes: %s\n"),
881 (
unsigned)nspew, (
unsigned)nb,
Fstrerror(rfile->
fd));
900 if (repo->
ts != NULL) {
921 const char * spew = rfile->
xml_init;
922 size_t nspew = strlen(spew);
929 assert(rfile->
fd != NULL);
934 if ((tail = strstr(spew,
" packages=\"0\">\n")) != NULL)
935 nspew -= strlen(tail);
937 nb =
Fwrite(spew, 1, nspew, rfile->
fd);
941 size_t tnb =
snprintf(buf,
sizeof(buf),
" packages=\"%d\">\n",
944 nb +=
Fwrite(buf, 1, tnb, rfile->
fd);
947 repo_error(0,
_(
"Fwrite failed: expected write %u != %u bytes: %s\n"),
948 (
unsigned)nspew, (
unsigned)nb,
Fstrerror(rfile->
fd));
954 #if defined(WITH_SQLITE)
955 if (repo->database) {
959 rfile->
type,
".sqlite", NULL);
960 if ((xx = sqlite3_open(fn, &rfile->sqldb)) != SQLITE_OK)
961 repo_error(1,
"sqlite3_open(%s): %s", fn, sqlite3_errmsg(rfile->sqldb));
962 for (stmt = rfile->
sql_init; *stmt != NULL; stmt++) {
964 xx = sqlite3_exec(rfile->sqldb, *stmt, NULL, NULL, &msg);
966 repo_error(1,
"sqlite3_exec(%s, \"%s\"): %s\n", fn, *stmt,
967 (msg != NULL ? msg :
"failed"));
1000 char buffer[32 * BUFSIZ];
1001 size_t nb =
sizeof(buffer);
1003 while ((nr =
Fread(buffer,
sizeof(buffer[0]), nb, fd)) == nb)
1006 fprintf(stderr,
_(
"%s: Fread(%s) failed: %s\n"),
1010 static int asAscii = 1;
1011 const char *digest = NULL;
1014 digest =
_free(digest);
1048 const char * msg = NULL;
1051 repo_error(1,
_(
"headerSprintf(%s): %s"), qfmt, msg);
1056 #if defined(WITH_SQLITE)
1062 static int rfileSQL(rpmrfile rfile,
const char * msg,
int rc)
1066 if (rc != SQLITE_OK || _repo_debug)
1068 sqlite3_errmsg(rfile->sqldb));
1077 static int rfileSQLStep(rpmrfile rfile, sqlite3_stmt * stmt)
1087 rc = sqlite3_step(stmt);
1090 rc = rfileSQL(rfile,
"step", rc);
1099 xx = rfileSQL(rfile,
"reset",
1100 sqlite3_reset(stmt));
1111 static const char * rfileHeaderSprintfHack(
Header h,
const char * qfmt)
1115 static const char mark[] =
"'XXX'";
1116 static size_t nmark =
sizeof(
"'XXX'") - 1;
1117 const char * msg = NULL;
1118 char * s = (
char *)
headerSprintf(h, qfmt, NULL, NULL, &msg);
1123 repo_error(1,
_(
"headerSprintf(%s): %s"), qfmt, msg);
1128 for (f = s; *f !=
'\0' && (fe = strstr(f,
"'XXX'")) != NULL; fe += nmark, f = fe)
1134 int xx =
snprintf(instance,
sizeof(instance),
"'%u'",
1136 size_t tlen = strlen(s) + nsubs * ((int)strlen(instance) - (int)nmark);
1142 for (f = s; *f !=
'\0' && (fe = strstr(f, mark)) != NULL; fe += nmark, f = fe) {
1162 static int rfileSQLWrite(rpmrfile rfile,
const char * cmd)
1166 sqlite3_stmt * stmt;
1170 xx = rfileSQL(rfile,
"prepare",
1171 sqlite3_prepare(rfile->sqldb, cmd, (
int)strlen(cmd), &stmt, &tail));
1173 xx = rfileSQL(rfile,
"reset",
1174 sqlite3_reset(stmt));
1176 xx = rfileSQLStep(rfile, stmt);
1178 xx = rfileSQL(rfile,
"finalize",
1179 sqlite3_finalize(stmt));
1205 #if defined(WITH_SQLITE)
1206 if (repo->database) {
1207 if (rfileSQLWrite(rfile, rfileHeaderSprintfHack(h, rfile->
sql_qfmt)))
1228 while ((pkg = *pkglist++) != NULL) {
1246 self.primaryfile.write(po.do_primary_xml_dump(reldir, baseurl=repo->
baseurl))
1247 self.flfile.write(po.do_filelists_xml_dump())
1248 self.otherfile.write(po.do_other_xml_dump())
1274 const char ** digestp)
1277 static int asAscii = 1;
1278 struct stat sb, *st = &sb;
1280 const char * path = NULL;
1286 memset(st, 0,
sizeof(*st));
1289 fd =
Fopen(fn,
"r.ufdio");
1290 if (fd == NULL ||
Ferror(fd))
1296 #if defined(HAVE_MMAP)
1297 {
void * mapped = (
void *)-1;
1299 if (st->st_size > 0)
1300 mapped = mmap(NULL, st->st_size, PROT_READ, MAP_SHARED,
Fileno(fd), 0);
1301 if (mapped != (
void *)-1) {
1308 xx = munmap(mapped, st->st_size);
1314 {
char buf[64 * BUFSIZ];
1319 while ((nb =
Fread(buf,
sizeof(buf[0]),
sizeof(buf), fd)) > 0)
1346 static int asAscii = 1;
1351 repo_error(0,
_(
"Saving %s metadata"), basename(xmlfn));
1368 #if defined(WITH_SQLITE)
1369 if (repo->database && rfile->sqldb != NULL) {
1371 rfile->
type,
".sqlite", NULL);
1373 if ((xx = sqlite3_close(rfile->sqldb)) != SQLITE_OK)
1374 repo_error(1,
"sqlite3_close(%s): %s", dbfn, sqlite3_errmsg(rfile->sqldb));
1375 rfile->sqldb = NULL;
1381 xmlfn =
_free(xmlfn);
1400 def _getFragmentUrl(
self, url, fragment):
1402 urlparse.uses_fragment.append(
'media')
1405 (scheme, netloc, path, query, fragid) = urlparse.urlsplit(url)
1406 return urlparse.urlunsplit((scheme, netloc, path, query, str(fragment)))
1408 def doPkgMetadata(
self):
1409 """all the heavy lifting for the package metadata"""
1411 MetaDataGenerator.doPkgMetadata(
self)
1418 if (mydir[0] ==
'/')
1420 else if (mydir[0] ==
'.' && mydir[1] ==
'.' && mydir[2] ==
'/')
1425 xx =
argvAdd(&roots, thisdir);
1426 thisdir =
_free(thisdir);
1429 self.trimRpms(filematrix[mydir])
1459 fprintf(stderr,
"\n");
1474 const char * tagname = NULL;
1499 default: tagname = NULL;
break;
1516 (void)
snprintf(spewtime,
sizeof(spewtime),
"%u", (unsigned)rfile->
ctime);
1518 <data type=\"", rfile->
type,
"\">\n\
1519 <checksum type=\"", spewalgo,
"\">", rfile->
Zdigest,
"</checksum>\n\
1520 <timestamp>", spewtime,
"</timestamp>\n\
1521 <open-checksum type=\"",spewalgo,
"\">", rfile->
digest,
"</open-checksum>\n\
1535 rpmrfile rfile = &repo->
repomd;
1539 if ((rfile->
fd =
Fopen(fn,
"w.ufdio")) != NULL) {
1554 def doRepoMetadata(
self):
1555 """wrapper to generate the repomd.xml file that stores the info on the other files"""
1556 const char * repopath =
1558 repodoc = libxml2.newDoc(
"1.0")
1559 reporoot = repodoc.newChild(None,
"repomd", None)
1560 repons = reporoot.newNs(
"http://linux.duke.edu/metadata/repo", None)
1561 reporoot.setNs(repons)
1565 repoid =
"garbageid";
1567 if (repo->database) {
1570 dbversion = str(sqlitecachec.DBVERSION)
1571 except AttributeError:
1573 rp = sqlitecachec.RepodataParserSqlite(repopath, repoid, None)
1576 {
static const char * types[] =
1577 {
"primary",
"filelists",
"other", NULL };
1578 const char ** typep;
1579 for (typep = types; *typep != NULL; typep++) {
1582 zfo = _gzipOpen(complete_path)
1587 timestamp = os.stat(complete_path)[8]
1590 db_compressed_sums = {}
1592 if (repo->database) {
1594 time_t now = time(NULL);
1596 *typep, ctime(&now));
1599 if (!strcmp(*typep,
"primary"))
1600 rp.getPrimary(complete_path, csum)
1601 else if (!strcmp(*typep,
"filelists"));
1602 rp.getFilelists(complete_path, csum)
1603 else if (!strcmp(*typep,
"other"))
1604 rp.getOtherdata(complete_path, csum)
1606 {
const char * tmp_result_path =
1608 *typep,
".xml.gz.sqlite", NULL);
1609 const char * resultpath =
1611 *typep,
".sqlite", NULL);
1614 xx =
Rename(tmp_result_path, resultpath);
1615 tmp_result_path =
_free(tmp_result_path);
1618 *typep,
".sqlite.bz2", NULL);
1622 bzipFile(resultpath, result_compressed)
1624 db_compressed_sums[*typep] = misc.checksum(
algo2tagname(repo->
algo), result_compressed)
1627 resultpath =
_free(resultpath);
1631 const char * csum_result_compressed =
1633 db_compressed_sums[*typep],
"-", *typep,
".sqlite.bz2", NULL);
1634 xx =
Rename(result_compressed, csum_result_compressed);
1635 result_compressed =
_free(result_compressed);
1636 result_compressed = csum_result_compressed;
1641 db_timestamp = os.stat(result_compressed)[8]
1644 db_data_type =
rpmExpand(*typep,
"_db", NULL);
1645 data = reporoot.newChild(None,
'data', None)
1646 data.newProp(
'type', db_data_type)
1647 location = data.newChild(None,
'location', None)
1649 location.newProp(
'xml:base', repo->
baseurl)
1652 location.newProp(
'href',
rpmGetPath(repo->
finaldir,
"/", *typep,
".sqlite.bz2", NULL));
1653 checksum = data.newChild(None,
'checksum', db_compressed_sums[*typep])
1655 db_tstamp = data.newChild(None,
'timestamp', str(db_timestamp))
1656 unchecksum = data.newChild(None,
'open-checksum', db_csums[*typep])
1658 database_version = data.newChild(None,
'database_version', dbversion)
1660 time_t now = time(NULL);
1662 *typep, ctime(&now));
1666 data = reporoot.newChild(None,
'data', None)
1667 data.newProp(
'type', *typep)
1669 checksum = data.newChild(None,
'checksum', csum)
1671 timestamp = data.newChild(None,
'timestamp', str(timestamp))
1672 unchecksum = data.newChild(None,
'open-checksum', uncsum)
1674 location = data.newChild(None,
'location', None)
1676 location.newProp(
'xml:base', repo->
baseurl)
1681 (repo->
suffix && strcmp(*typep,
"repomd") ? repo->
suffix :
""), NULL);
1683 xx =
Rename(orig_file, dest_file);
1688 (repo->
suffix && strcmp(*typep,
"repomd") ? repo->
suffix :
""), NULL);
1694 if (!repo->
quiet && repo->database)
1697 if (repo->groupfile != NULL) {
1698 self.addArbitraryMetadata(repo->groupfile,
'group_gz', reporoot)
1699 self.addArbitraryMetadata(repo->groupfile,
'group', reporoot, compress=False)
1704 repodoc.saveFormatFileEnc(fn,
'UTF-8', 1)
1706 repo_error(0,
_(
"Error saving temp file for %s%s%s: %s"),
1709 (repo->
suffix && strcmp(*typep,
"repomd") ? repo->
suffix :
""),
1711 repo_error(1,
_(
"Could not save temp file: %s"), fn);
1728 const char * output_final_dir =
1730 const char * output_old_dir =
1732 const char * oldfile;
1733 struct stat sb, *st = &sb;
1737 if ((xx =
Rename(output_final_dir, output_old_dir)) != 0)
1738 repo_error(1,
_(
"Error moving final %s to old dir %s"),
1739 output_final_dir, output_old_dir);
1742 {
const char * output_temp_dir =
1744 if ((xx =
Rename(output_temp_dir, output_final_dir)) != 0) {
1745 xx =
Rename(output_old_dir, output_final_dir);
1746 repo_error(1,
_(
"Error moving final metadata into place"));
1748 output_temp_dir =
_free(output_temp_dir);
1752 static const char * types[] =
1753 {
"primary",
"filelists",
"other",
"repomd",
"group", NULL };
1754 const char ** typep;
1756 for (typep = types; *typep != NULL; typep++) {
1757 oldfile =
rpmGetPath(output_old_dir,
"/", *typep,
1759 (repo->
suffix != NULL && strcmp(*typep,
"repomd")
1760 ? repo->
suffix :
""), NULL);
1763 repo_error(1,
_(
"Could not remove old metadata file: %s: %s"),
1764 oldfile, strerror(
errno));
1766 oldfile =
_free(oldfile);
1770 { DIR * dir =
Opendir(output_old_dir);
1774 while ((dp =
Readdir(dir)) != NULL) {
1775 const char * finalfile;
1777 if (!strcmp(dp->d_name,
".") || !strcmp(dp->d_name,
".."))
1780 finalfile =
rpmGetPath(output_final_dir,
"/", dp->d_name, NULL);
1781 oldfile =
rpmGetPath(output_old_dir,
"/", dp->d_name, NULL);
1783 if (!strcmp(dp->d_name,
"filelists.sqlite.bz2")
1784 || !strcmp(dp->d_name,
"other.sqlite.bz2")
1785 || !strcmp(dp->d_name,
"primary.sqlite.bz2"))
1788 oldfile =
_free(oldfile);
1793 if (!S_ISDIR(st->st_mode)) {
1794 if ((xx =
Unlink(oldfile)) != 0)
1795 repo_error(1,
_(
"Could not remove old metadata file: %s: %s"),
1796 oldfile, strerror(
errno));
1800 shutil.rmtree(oldfile)
1804 if ((xx =
Rename(oldfile, finalfile)) != 0) {
1805 repo_error(1,
_(
"Could not restore old non-metadata file: %s -> %s: %s"),
1806 oldfile, finalfile, strerror(
errno));
1809 oldfile =
_free(oldfile);
1810 finalfile =
_free(finalfile);
1816 if ((xx =
Rmdir(output_old_dir)) != 0) {
1817 repo_error(1,
_(
"Could not remove old metadata dir: %s: %s"),
1820 output_old_dir =
_free(output_old_dir);
1821 output_final_dir =
_free(output_final_dir);
1831 enum poptCallbackReason reason,
1832 const struct poptOption * opt,
const char * arg,
1840 if (opt->arg == NULL)
1848 fprintf(stderr,
_(
"%s: Unknown option -%c\n"),
__progname, opt->val);
1849 poptPrintUsage(con, stderr, 0);
1860 {
"uncompressed",
'\0', POPT_ARG_VAL, &
compression, 0,
1861 N_(
"don't compress"), NULL },
1863 N_(
"use gzip compression"), NULL },
1865 N_(
"use bzip2 compression"), NULL },
1867 N_(
"use lzma compression"), NULL },
1869 N_(
"use xz compression"), NULL },
1876 { NULL,
'\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA | POPT_CBFLAG_CONTINUE,
1880 {
"repodebug",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &
_repo_debug, -1,
1881 N_(
"debug repo handling"), NULL },
1883 {
"quiet",
'q', POPT_ARG_VAL, &__rpmrepo.
quiet, 0,
1884 N_(
"output nothing except for serious errors"), NULL },
1885 {
"verbose",
'v', 0, NULL, (int)
'v',
1886 N_(
"output more debugging info."), NULL },
1887 {
"dryrun",
'\0', POPT_ARG_VAL, &__rpmrepo.
dryrun, 1,
1888 N_(
"sanity check arguments, don't create metadata"), NULL },
1890 N_(
"glob PATTERN(s) to exclude"),
N_(
"PATTERN") },
1892 N_(
"glob PATTERN(s) to include"),
N_(
"PATTERN") },
1893 {
"basedir",
'\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, &__rpmrepo.
basedir, 0,
1894 N_(
"top level directory"),
N_(
"DIR") },
1895 {
"baseurl",
'u', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, &__rpmrepo.
baseurl, 0,
1896 N_(
"baseurl to append on all files"),
N_(
"BASEURL") },
1898 {
"groupfile",
'g', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, &__rpmrepo.groupfile, 0,
1899 N_(
"path to groupfile to include in metadata"),
N_(
"FILE") },
1901 {
"pretty",
'p', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &__rpmrepo.
pretty, 1,
1902 N_(
"make sure all xml generated is formatted"), NULL },
1903 {
"checkts",
'C', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &__rpmrepo.
checkts, 1,
1904 N_(
"check timestamps on files vs the metadata to see if we need to update"), NULL },
1905 #if defined(WITH_SQLITE)
1906 {
"database",
'd', POPT_ARG_VAL, &__rpmrepo.database, 1,
1907 N_(
"create sqlite3 database files"), NULL },
1909 {
"split",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &__rpmrepo.
split, 1,
1910 N_(
"generate split media"), NULL },
1911 {
"pkglist",
'l', POPT_ARG_ARGV|POPT_ARGFLAG_DOC_HIDDEN, &__rpmrepo.
manifests, 0,
1912 N_(
"use only the files listed in this file from the directory specified"),
N_(
"FILE") },
1913 {
"outputdir",
'o', POPT_ARG_STRING, &__rpmrepo.
outputdir, 0,
1914 N_(
"<dir> = optional directory to output to"),
N_(
"DIR") },
1915 {
"skip-symlinks",
'S', POPT_ARG_VAL, &__rpmrepo.
nofollow, 1,
1916 N_(
"ignore symlinks of packages"), NULL },
1917 {
"unique-md-filenames",
'\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &__rpmrepo.
uniquemdfilenames, 1,
1918 N_(
"include the file's checksum in the filename, helps with proxies"), NULL },
1921 N_(
"Fts(3) traversal options:"), NULL },
1925 N_(
"print the version"), NULL },
1929 N_(
"Available compressions:"), NULL },
1932 N_(
"Available digests:"), NULL },
1935 N_(
"Common options for all rpmio executables:"),
1953 const char ** av = NULL;
1960 #if !defined(__LCLINT__)
1965 optCon =
rpmioInit(argc, argv, optionsTable);
1970 repo_error(1,
"FTS_LOGICAL and FTS_PYSICAL are mutually exclusive");
1979 repo->
compression = (compression >= 0 ? compression : 1);
1983 repo->
wmode =
"w.ufdio";
1989 repo->
wmode =
"w9.gzdio";
1993 repo->
wmode =
"w9.bzdio";
1997 repo->
wmode =
"w.lzdio";
2001 repo->
wmode =
"w.xzdio";
2005 av = poptGetArgs(optCon);
2006 if (av == NULL || av[0] == NULL) {
2007 repo_error(0,
_(
"Must specify path(s) to index."));
2008 poptPrintUsage(optCon, stderr, 0);
2013 for (i = 0; av[i] != NULL; i++) {
2017 const char * lpath = NULL;
2018 int ut =
urlPath(av[i], &lpath);
2019 size_t nb = (size_t)(lpath - av[i]);
2020 int isdir = (lpath[strlen(lpath)-1] ==
'/');
2023 if (lpath[0] !=
'/') {
2027 rpath =
_free(rpath);
2040 assert(nb <
sizeof(fullpath));
2041 strncpy(fullpath, av[i], nb);
2042 fullpath[nb] =
'\0';
2044 lpath =
_free(lpath);
2049 lpath = (isdir || (!
Stat(rpath, &sb) && S_ISDIR(sb.st_mode))
2051 if (lpath != NULL) {
2054 lpath =
_free(lpath);
2060 rpath =
_free(rpath);
2063 if (_repo_debug || repo->
dryrun)
2082 repo_error(1,
_(
"--split and --checkts options are mutually exclusive"));
2090 while ((fn = *av++) != NULL) {
2102 repo_error(1,
_(
"Error loading exclude glob patterns."));
2105 repo_error(1,
_(
"Error loading include glob patterns."));
2117 if (_repo_debug || repo->
dryrun)
2137 fprintf(stdout,
_(
"repo is up to date\n"));