From: Kristian Høgsberg Date: Tue, 6 Nov 2007 00:06:52 +0000 (-0500) Subject: Link to curl and download yum files automatically. X-Git-Tag: 0.1~289 X-Git-Url: http://project.juiblex.co.uk/git/?a=commitdiff_plain;h=218e6b7f398545b941908928bcad665acfa1e1fb;p=razor.git Link to curl and download yum files automatically. --- diff --git a/Makefile b/Makefile index 34cb2f6..76d2e5a 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,7 @@ CFLAGS = -Wall -g -O2 -LDLIBS = -lexpat -lz -g -lrpm +LDLIBS = -lexpat -lz -g -lrpm -lcurl razor : razor.o import.o sha1.o main.o -import : razor primary.xml.gz - zcat primary.xml.gz | ./razor import-yum - -primary.xml.gz : - wget http://download.fedora.redhat.com/pub/fedora/linux/development/i386/os/repodata/primary.xml.gz - clean : rm -f *.o razor diff --git a/TODO b/TODO index 2c9f89b..58f17d2 100644 --- a/TODO +++ b/TODO @@ -12,8 +12,6 @@ Towards replacing rpm + yum (0.1): - merge file lists when merging package sets -- import filelist.xml.gz too in yum importer - - download (libcurl?) - figure out how to canonically represent empty string... ~0? @@ -88,3 +86,6 @@ Misc ideas: maybe the effective set is the on-disk representation and the overlay can be computed when needed, we just keep a link back to the base. + +- incremental rawhide repo updates? instead of downloading 10MB zipped + repo every time, download a diff repo? diff --git a/import-rpm.sh b/import-rpm.sh deleted file mode 100755 index 37eb537..0000000 --- a/import-rpm.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -import_rpm() { - echo "" - echo " " - - rpm -q --provides $p | sort -u | while read name ignore version; do - if test -z $version; then - echo " " - else - echo " " - fi - done - - rpm -q --requires $p | sort -u | while read name ignore version; do - if test -z $version; then - echo " " - else - echo " " - fi - done - - echo " " - echo "" -} - -mkdir -p pkgs -rpm -qa | while read p; do - name=${p%-*-*} - vr=${p#$name-} - version=${vr%-*} - release=${vr#*-} - - echo $name - $version - $release - import_rpm $name $version $release > pkgs/$name.rzr -done diff --git a/main.c b/main.c index b2f21ee..267753c 100644 --- a/main.c +++ b/main.c @@ -4,6 +4,7 @@ #include #include +#include #include "razor.h" static const char *repo_filename = "system.repo"; @@ -138,10 +139,35 @@ command_what_provides(int argc, const char *argv[]) return 0; } +#define REPO_URL "http://download.fedora.redhat.com" \ + "/pub/fedora/linux/development/i386/os/repodata" + static int command_import_yum(int argc, const char *argv[]) { struct razor_set *set; + CURL *curl; + CURLcode res; + FILE *fp; + + curl = curl_easy_init(); + if (curl == NULL) + return 1; + + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); + fp = fopen("primary.xml.gz", "w"); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + curl_easy_setopt(curl, CURLOPT_URL, REPO_URL "/primary.xml.gz"); + res = curl_easy_perform(curl); + fclose(fp); + + fp = fopen("filelists.xml.gz", "w"); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + curl_easy_setopt(curl, CURLOPT_URL, REPO_URL "/filelists.xml.gz"); + res = curl_easy_perform(curl); + fclose(fp); + + curl_easy_cleanup(curl); set = razor_set_create_from_yum(); if (set == NULL)