Make yum url overridable by environment variable YUM_URL.
1.1 --- a/main.c Mon Jun 09 12:47:37 2008 -0400
1.2 +++ b/main.c Mon Jun 09 14:38:58 2008 -0400
1.3 @@ -39,6 +39,7 @@
1.4 static const char razor_root_path[] = "/var/lib/razor";
1.5 static const char root[] = "install";
1.6 static const char *repo_filename = system_repo_filename;
1.7 +static const char *yum_url;
1.8
1.9 static int
1.10 command_list(int argc, const char *argv[])
1.11 @@ -321,19 +322,23 @@
1.12 return 0;
1.13 }
1.14
1.15 -#define REPO_URL "http://download.fedora.redhat.com" \
1.16 +#define YUM_URL "http://download.fedora.redhat.com" \
1.17 "/pub/fedora/linux/development/i386/os"
1.18
1.19 static int
1.20 command_import_yum(int argc, const char *argv[])
1.21 {
1.22 struct razor_set *set;
1.23 + char buffer[512];
1.24
1.25 - if (download_if_missing(REPO_URL "/repodata/primary.xml.gz",
1.26 - "primary.xml.gz") < 0)
1.27 + printf("downloading from %s.\n", yum_url);
1.28 + snprintf(buffer, sizeof buffer,
1.29 + "%s/repodata/primary.xml.gz", yum_url);
1.30 + if (download_if_missing(buffer, "primary.xml.gz") < 0)
1.31 return -1;
1.32 - if (download_if_missing(REPO_URL "/repodata/filelists.xml.gz",
1.33 - "filelists.xml.gz") < 0)
1.34 + snprintf(buffer, sizeof buffer,
1.35 + "%s/repodata/filelists.xml.gz", yum_url);
1.36 + if (download_if_missing(buffer, "filelists.xml.gz") < 0)
1.37 return -1;
1.38
1.39 set = razor_set_create_from_yum();
1.40 @@ -580,7 +585,7 @@
1.41 v = new_version;
1.42
1.43 snprintf(url, sizeof url,
1.44 - REPO_URL "/Packages/%s-%s.%s.rpm", name, v, arch);
1.45 + "%s/Packages/%s-%s.%s.rpm", yum_url, name, v, arch);
1.46 snprintf(file, sizeof file,
1.47 "rpms/%s-%s.%s.rpm", name, v, arch);
1.48 if (download_if_missing(url, file) < 0)
1.49 @@ -778,8 +783,8 @@
1.50
1.51 matches++;
1.52 snprintf(url, sizeof url,
1.53 - REPO_URL "/Packages/%s-%s.%s.rpm",
1.54 - name, version, arch);
1.55 + "%s/Packages/%s-%s.%s.rpm",
1.56 + yum_url, name, version, arch);
1.57 snprintf(file, sizeof file,
1.58 "rpms/%s-%s.%s.rpm", name, version, arch);
1.59 download_if_missing(url, file);
1.60 @@ -846,6 +851,10 @@
1.61 if (repo != NULL)
1.62 repo_filename = repo;
1.63
1.64 + yum_url = getenv("YUM_URL");
1.65 + if (yum_url == NULL)
1.66 + yum_url = YUM_URL;
1.67 +
1.68 if (argc < 2)
1.69 return usage();
1.70