#!/usr/bin/php = $level) { if (!$l) { echo "+ "; } echo "$m\n"; } if ($l >= 3) { exit(1); } } function usage() { printf("\nMkView version %s - (c) Remi Collet\n", MKVIEW_VERSION); printf("\nusage: %s [ options ]\n\n", $_SERVER['argv'][0]); printf("\t--template directory\n"); printf("\t--url repository public URL\n"); printf("\t--quiet less message\n"); printf("\t--verbose more message\n"); printf("\t--title repository title\n\n"); } function parse_repomd() { if (!is_dir("repodata")) { msg(3, "repodata directory missing"); } if (!is_file("repodata/repomd.xml")) { msg(3, "repomd.xml is missing"); } $md = simplexml_load_file("repodata/repomd.xml"); if (!$md) { msg(3, "Can't read repomd.xml or empty"); } msg(0, "Read repomd.xml"); foreach($md->data as $n) { $a = (string)$n->attributes()->type[0]; if ($a === 'primary') { $path = (string)$n->location->attributes()->href[0]; } } if ($path) { msg(0, "Primary stored in $path"); } else { msg(3, "Primary not found"); } return $path; } for($i=1 ; $i<$_SERVER['argc'] ; $i++) { $arg = $_SERVER['argv'][$i]; switch ($arg) { case '-h': case '--help': usage(); exit(0); case '-t': case '--title': $title = $_SERVER['argv'][++$i]; break; case '-T': case '--template': $template = realpath($_SERVER['argv'][++$i]); break; case '-u': case '--url': $url = $_SERVER['argv'][++$i]; break; case '-v': case '--verbose': $level--; break; case '-q': case '--quiet': $level++; break; default: if (!is_dir($arg)) { msg(3, "Unkownn option $arg"); } else if (!chdir($arg)) { msg(3, "Bad directory $arg"); exit(1); } } } msg(1, sprintf("MkView version %s - (c) Remi Collet", MKVIEW_VERSION)); msg(0, "Work in " . getcwd()); $prim = parse_repomd(); msg(0, "Done");