diff options
author | Lukas Fleischer <archlinux@cryptocrack.de> | 2011-02-08 10:13:12 +0100 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2011-02-11 14:43:23 +0100 |
commit | ddc54358d0f382cbd801d3f4339f05d680ad94e3 (patch) | |
tree | b4ceaba7b5a2b61bd7810ce2c6995227ef4bcb5d /scripts/aurblup/aurblup.c | |
parent | 48957ef5d5f38613957cc0fc29c402023cb4276c (diff) | |
download | aur-ddc54358d0f382cbd801d3f4339f05d680ad94e3.tar.gz aur-ddc54358d0f382cbd801d3f4339f05d680ad94e3.tar.xz |
Add packages' provides and replaces to the blacklist in aurblup.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'scripts/aurblup/aurblup.c')
-rw-r--r-- | scripts/aurblup/aurblup.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/scripts/aurblup/aurblup.c b/scripts/aurblup/aurblup.c index 8cf49e07..1d73fe39 100644 --- a/scripts/aurblup/aurblup.c +++ b/scripts/aurblup/aurblup.c @@ -15,6 +15,7 @@ #define mysql_die(...) die(__VA_ARGS__, mysql_error(c)); void die(const char *, ...); +void blacklist_add(const char *); void blacklist_sync(alpm_list_t *); alpm_list_t *get_package_list(alpm_list_t *); alpm_list_t *create_db_list(void); @@ -45,12 +46,26 @@ die(const char *format, ...) } void -blacklist_sync(alpm_list_t *pkgs) +blacklist_add(const char *name) { - alpm_list_t *r; - char *se; + char *esc = malloc(strlen(name) * 2 + 1); char query[1024]; + mysql_real_escape_string(c, esc, name, strlen(name)); + *(esc + strcspn(esc, "<=>")) = 0; + snprintf(query, 1024, "INSERT IGNORE INTO PackageBlacklist (Name) " + "VALUES ('%s');", esc); + free(esc); + + if (mysql_query(c, query)) + mysql_die("failed to query MySQL database (\"%s\"): %s\n", query); +} + +void +blacklist_sync(alpm_list_t *pkgs) +{ + alpm_list_t *r, *p; + if (mysql_query(c, "LOCK TABLES PackageBlacklist WRITE;")) mysql_die("failed to lock MySQL table: %s\n"); @@ -58,16 +73,17 @@ blacklist_sync(alpm_list_t *pkgs) mysql_die("failed to clear MySQL table: %s\n"); for (r = pkgs; r; r = alpm_list_next(r)) { - const char *s = alpm_pkg_get_name(alpm_list_getdata(r)); + pmpkg_t *pkg = alpm_list_getdata(r); - se = malloc(strlen(s) * 2 + 1); - mysql_real_escape_string(c, se, s, strlen(s)); - snprintf(query, 1024, "INSERT INTO PackageBlacklist (Name) " - "VALUES ('%s');", se); - free(se); + blacklist_add(alpm_pkg_get_name(pkg)); - if (mysql_query(c, query)) - mysql_die("failed to query MySQL database (\"%s\"): %s\n", query); + for (p = alpm_pkg_get_provides(pkg); p; p = alpm_list_next(p)) { + blacklist_add(alpm_list_getdata(p)); + } + + for (p = alpm_pkg_get_replaces(pkg); p; p = alpm_list_next(p)) { + blacklist_add(alpm_list_getdata(p)); + } } if (mysql_query(c, "UNLOCK TABLES;")) |