# HG changeset patch # User Kristian H?gsberg # Date 1213036738 14400 # Node ID fef9808171ff947f114623878dd64a5a1ed24302 # Parent c1e2aed8dd0700065067f8056ab5935cad9f7e75 Make yum url overridable by environment variable YUM_URL. diff -r c1e2aed8dd07 -r fef9808171ff main.c --- a/main.c Mon Jun 09 12:47:37 2008 -0400 +++ b/main.c Mon Jun 09 14:38:58 2008 -0400 @@ -39,6 +39,7 @@ static const char razor_root_path[] = "/var/lib/razor"; static const char root[] = "install"; static const char *repo_filename = system_repo_filename; +static const char *yum_url; static int command_list(int argc, const char *argv[]) @@ -321,19 +322,23 @@ return 0; } -#define REPO_URL "http://download.fedora.redhat.com" \ +#define YUM_URL "http://download.fedora.redhat.com" \ "/pub/fedora/linux/development/i386/os" static int command_import_yum(int argc, const char *argv[]) { struct razor_set *set; + char buffer[512]; - if (download_if_missing(REPO_URL "/repodata/primary.xml.gz", - "primary.xml.gz") < 0) + printf("downloading from %s.\n", yum_url); + snprintf(buffer, sizeof buffer, + "%s/repodata/primary.xml.gz", yum_url); + if (download_if_missing(buffer, "primary.xml.gz") < 0) return -1; - if (download_if_missing(REPO_URL "/repodata/filelists.xml.gz", - "filelists.xml.gz") < 0) + snprintf(buffer, sizeof buffer, + "%s/repodata/filelists.xml.gz", yum_url); + if (download_if_missing(buffer, "filelists.xml.gz") < 0) return -1; set = razor_set_create_from_yum(); @@ -580,7 +585,7 @@ v = new_version; snprintf(url, sizeof url, - REPO_URL "/Packages/%s-%s.%s.rpm", name, v, arch); + "%s/Packages/%s-%s.%s.rpm", yum_url, name, v, arch); snprintf(file, sizeof file, "rpms/%s-%s.%s.rpm", name, v, arch); if (download_if_missing(url, file) < 0) @@ -778,8 +783,8 @@ matches++; snprintf(url, sizeof url, - REPO_URL "/Packages/%s-%s.%s.rpm", - name, version, arch); + "%s/Packages/%s-%s.%s.rpm", + yum_url, name, version, arch); snprintf(file, sizeof file, "rpms/%s-%s.%s.rpm", name, version, arch); download_if_missing(url, file); @@ -846,6 +851,10 @@ if (repo != NULL) repo_filename = repo; + yum_url = getenv("YUM_URL"); + if (yum_url == NULL) + yum_url = YUM_URL; + if (argc < 2) return usage();