summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2013-12-03 13:17:39 +0100
committerMichael Schroeder <mls@suse.de>2013-12-03 13:17:39 +0100
commit3c1f4d97d1d5d469e1bee747776ae547b98ec468 (patch)
tree3ecbce30628eda7a5b8bbd8dcb4b121fcf7fb533
parent09e3108d36e065e553fc6ac486a2c8fa7601718c (diff)
downloadlibsolv-3c1f4d97d1d5d469e1bee747776ae547b98ec468.tar.gz
libsolv-3c1f4d97d1d5d469e1bee747776ae547b98ec468.tar.bz2
libsolv-3c1f4d97d1d5d469e1bee747776ae547b98ec468.zip
support appdata parsing in tools, support SUSE auto-pattern generation
-rw-r--r--tools/CMakeLists.txt7
-rw-r--r--tools/mergesolv.c18
-rwxr-xr-xtools/repo2solv.sh40
-rw-r--r--tools/rpmdb2solv.c37
-rw-r--r--tools/rpms2solv.c17
-rw-r--r--tools/susetags2solv.c22
6 files changed, 132 insertions, 9 deletions
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 9a614df..16fa097 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -93,6 +93,13 @@ ADD_EXECUTABLE (patchcheck patchcheck.c)
TARGET_LINK_LIBRARIES (patchcheck libsolvext libsolv ${SYSTEM_LIBRARIES})
ENDIF (SUSE)
+IF (ENABLE_APPDATA)
+ADD_EXECUTABLE (appdata2solv appdata2solv.c)
+TARGET_LINK_LIBRARIES (appdata2solv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})
+
+SET (tools_list ${tools_list} appdata2solv)
+ENDIF (ENABLE_APPDATA)
+
ADD_EXECUTABLE (dumpsolv dumpsolv.c )
TARGET_LINK_LIBRARIES (dumpsolv libsolv)
diff --git a/tools/mergesolv.c b/tools/mergesolv.c
index 8ff4857..6719c8c 100644
--- a/tools/mergesolv.c
+++ b/tools/mergesolv.c
@@ -21,6 +21,9 @@
#include "pool.h"
#include "repo_solv.h"
+#ifdef SUSE
+#include "repo_autopattern.h"
+#endif
#include "common_write.h"
static void
@@ -61,12 +64,15 @@ main(int argc, char **argv)
Repo *repo;
const char *basefile = 0;
int with_attr = 0;
+#ifdef SUSE
+ int add_auto = 0;
+#endif
int c;
pool = pool_create();
repo = repo_create(pool, "<mergesolv>");
- while ((c = getopt(argc, argv, "ahb:")) >= 0)
+ while ((c = getopt(argc, argv, "ahb:X")) >= 0)
{
switch (c)
{
@@ -79,7 +85,13 @@ main(int argc, char **argv)
case 'b':
basefile = optarg;
break;
+ case 'X':
+#ifdef SUSE
+ add_auto = 1;
+#endif
+ break;
default:
+ usage();
exit(1);
}
}
@@ -101,6 +113,10 @@ main(int argc, char **argv)
}
fclose(fp);
}
+#ifdef SUSE
+ if (add_auto)
+ repo_add_autopattern(repo, 0);
+#endif
tool_write(repo, basefile, 0);
pool_free(pool);
return 0;
diff --git a/tools/repo2solv.sh b/tools/repo2solv.sh
index 3f24e17..c3f968a 100755
--- a/tools/repo2solv.sh
+++ b/tools/repo2solv.sh
@@ -54,6 +54,18 @@ repomd_decompress() {
esac
}
+susetags_findfile() {
+ if test -s "$1.xz" ; then
+ echo "$1.xz"
+ elif test -s "$1.lzma" ; then
+ echo "$1.lzma"
+ elif test -s "$1.bz2" ; then
+ echo "$1.bz2"
+ elif test -s "$1.gz" ; then
+ echo "$1.gz"
+ fi
+}
+
susetags_findfile_cat() {
if test -s "$1.xz" ; then
xz -dc "$1.xz"
@@ -77,6 +89,7 @@ parser_options=${PARSER_OPTIONS:-}
findopt="-prune"
repotype=
+addautooption=
while true ; do
if test "$1" = "-o" ; then
@@ -88,6 +101,9 @@ while true ; do
findopt=
repotype=plaindir
shift
+ elif test "$1" = "-X" ; then
+ addautooption=-X
+ shift
else
break
fi
@@ -187,14 +203,29 @@ if test "$repotype" = rpmmd ; then
repomd_decompress "$deltainfoxml" | deltainfoxml2solv $parser_options > $deltainfofile || exit 4
fi
+ # This contains appdata
+ appdatafile=
+ appdataxml=`repomd_findfile appdata appdata.xml`
+ if test -n "$appdataxml" -a -s "$appdataxml" ; then
+ appdatafile=`mktemp` || exit 3
+ repomd_decompress "$appdataxml" | appdata2solv $parser_options > $appdatafile || exit 4
+ fi
+
# Now merge primary, patches, updateinfo, and deltainfo
- mergesolv $repomdfile $suseinfofile $primfile $prodfile $patternfile $updateinfofile $deltainfofile
- rm -f $repomdfile $suseinfofile $primfile $patternfile $prodfile $updateinfofile $deltainfofile
+ mergesolv $addautooption $repomdfile $suseinfofile $primfile $prodfile $patternfile $updateinfofile $deltainfofile $appdatafile
+ rm -f $repomdfile $suseinfofile $primfile $patternfile $prodfile $updateinfofile $deltainfofile $appdatafile
elif test "$repotype" = susetags ; then
olddir=`pwd`
DESCR=$(get_DESCRDIR)
cd ${DESCR} || exit 2
+ appdatafile=
+ appdataxml=`susetags_findfile appdata.xml`
+ if test -n "$appdataxml" ; then
+ appdatafile=`mktemp` || exit 3
+ repomd_decompress "$appdataxml" | appdata2solv $parser_options > $appdatafile || exit 4
+ parser_options="-M $appdatafile $parser_options"
+ fi
(
# First packages
susetags_findfile_cat packages
@@ -232,10 +263,11 @@ elif test "$repotype" = susetags ; then
esac
done
- ) | susetags2solv -c "${olddir}/content" $parser_options || exit 4
+ ) | susetags2solv $addautooption -c "${olddir}/content" $parser_options || exit 4
+ test -n "$appdatafile" && rm -f "$appdatafile"
cd "$olddir"
elif test "$repotype" = plaindir ; then
- find * -name .\* -prune -o $findopt -name \*.delta.rpm -o -name \*.patch.rpm -o -name \*.rpm -a -type f -print0 | rpms2solv -0 -m -
+ find * -name .\* -prune -o $findopt -name \*.delta.rpm -o -name \*.patch.rpm -o -name \*.rpm -a -type f -print0 | rpms2solv $addautooption -0 -m -
else
echo "unknown repository type '$repotype'" >&2
exit 1
diff --git a/tools/rpmdb2solv.c b/tools/rpmdb2solv.c
index ba6fef3..ef934ac 100644
--- a/tools/rpmdb2solv.c
+++ b/tools/rpmdb2solv.c
@@ -31,6 +31,13 @@
#include "repo_products.h"
#include "repo_solv.h"
#include "common_write.h"
+#ifdef ENABLE_APPDATA
+#include "repo_appdata.h"
+#endif
+#ifdef SUSE
+#include "repo_autopattern.h"
+#endif
+
static void
usage(int status)
@@ -66,12 +73,18 @@ main(int argc, char **argv)
#ifdef ENABLE_PUBKEY
int pubkeys = 0;
#endif
+#ifdef ENABLE_APPDATA
+ int add_appdata = 0;
+#endif
+#ifdef SUSE
+ int add_auto = 0;
+#endif
/*
* parse arguments
*/
- while ((c = getopt(argc, argv, "Phnkxb:r:p:o:")) >= 0)
+ while ((c = getopt(argc, argv, "APhnkxXb:r:p:o:")) >= 0)
switch (c)
{
case 'h':
@@ -95,7 +108,17 @@ main(int argc, char **argv)
#endif
break;
case 'x':
- break;
+ break; /* extrapool no longer supported */
+ case 'X':
+#ifdef SUSE
+ add_auto = 1;
+#endif
+ break;
+ case 'A':
+#ifdef ENABLE_APPDATA
+ add_appdata = 1;
+#endif
+ break;
case 'o':
outfile = optarg;
break;
@@ -181,11 +204,21 @@ main(int argc, char **argv)
}
}
#endif
+
+#ifdef ENABLE_APPDATA
+ if (add_appdata)
+ repo_add_appdata_dir(repo, "/usr/share/appdata", REPO_USE_ROOTDIR | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE);
+#endif
repodata_internalize(data);
if (reffp)
fclose(reffp);
+#ifdef SUSE
+ if (add_auto)
+ repo_add_autopattern(repo, 0);
+#endif
+
tool_write(repo, basefile, 0);
pool_free(pool);
exit(0);
diff --git a/tools/rpms2solv.c b/tools/rpms2solv.c
index b388f97..13b77b1 100644
--- a/tools/rpms2solv.c
+++ b/tools/rpms2solv.c
@@ -25,6 +25,9 @@
#include "solv_xfopen.h"
#endif
#include "repo_solv.h"
+#ifdef SUSE
+#include "repo_autopattern.h"
+#endif
#include "common_write.h"
static char *
@@ -65,8 +68,11 @@ main(int argc, char **argv)
#ifdef ENABLE_PUBKEY
int pubkeys = 0;
#endif
+#ifdef SUSE
+ int add_auto = 0;
+#endif
- while ((c = getopt(argc, argv, "0kKb:m:")) >= 0)
+ while ((c = getopt(argc, argv, "0XkKb:m:")) >= 0)
{
switch(c)
{
@@ -87,6 +93,11 @@ main(int argc, char **argv)
pubkeys = 2;
break;
#endif
+ case 'X':
+#ifdef SUSE
+ add_auto = 1;
+#endif
+ break;
default:
exit(1);
}
@@ -165,6 +176,10 @@ main(int argc, char **argv)
}
}
repo_internalize(repo);
+#ifdef SUSE
+ if (add_auto)
+ repo_add_autopattern(repo, 0);
+#endif
tool_write(repo, basefile, 0);
pool_free(pool);
for (c = 0; c < nrpms; c++)
diff --git a/tools/susetags2solv.c b/tools/susetags2solv.c
index f94e517..524253b 100644
--- a/tools/susetags2solv.c
+++ b/tools/susetags2solv.c
@@ -19,6 +19,7 @@
#include "pool.h"
#include "repo.h"
+#include "repo_solv.h"
#include "repo_susetags.h"
#include "repo_content.h"
#include "common_write.h"
@@ -64,13 +65,14 @@ main(int argc, char **argv)
const char *descrdir = 0;
const char *basefile = 0;
const char *query = 0;
+ const char *mergefile = 0;
Id defvendor = 0;
int flags = 0;
int c;
Pool *pool;
Repo *repo;
- while ((c = getopt(argc, argv, "hn:c:d:b:q:")) >= 0)
+ while ((c = getopt(argc, argv, "hn:c:d:b:q:M:")) >= 0)
{
switch (c)
{
@@ -92,6 +94,9 @@ main(int argc, char **argv)
case 'q':
query = optarg;
break;
+ case 'M':
+ mergefile = optarg;
+ break;
default:
usage(1);
break;
@@ -275,6 +280,21 @@ main(int argc, char **argv)
}
}
repo_internalize(repo);
+ if (mergefile)
+ {
+ FILE *fp = fopen(mergefile, "r");
+ if (!fp)
+ {
+ perror(mergefile);
+ exit(1);
+ }
+ if (repo_add_solv(repo, fp, 0))
+ {
+ fprintf(stderr, "susetags2solv: %s\n", pool_errstr(pool));
+ exit(1);
+ }
+ fclose(fp);
+ }
if (query)
doquery(pool, repo, query);