Commit ddc54358 authored by Lukas Fleischer's avatar Lukas Fleischer
Browse files

Add packages' provides and replaces to the blacklist in aurblup.



Signed-off-by: default avatarLukas Fleischer <archlinux@cryptocrack.de>
parent 48957ef5
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#define mysql_die(...) die(__VA_ARGS__, mysql_error(c)); #define mysql_die(...) die(__VA_ARGS__, mysql_error(c));
void die(const char *, ...); void die(const char *, ...);
void blacklist_add(const char *);
void blacklist_sync(alpm_list_t *); void blacklist_sync(alpm_list_t *);
alpm_list_t *get_package_list(alpm_list_t *); alpm_list_t *get_package_list(alpm_list_t *);
alpm_list_t *create_db_list(void); alpm_list_t *create_db_list(void);
...@@ -45,12 +46,26 @@ die(const char *format, ...) ...@@ -45,12 +46,26 @@ die(const char *format, ...)
} }
void void
blacklist_sync(alpm_list_t *pkgs) blacklist_add(const char *name)
{ {
alpm_list_t *r; char *esc = malloc(strlen(name) * 2 + 1);
char *se;
char query[1024]; 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;")) if (mysql_query(c, "LOCK TABLES PackageBlacklist WRITE;"))
mysql_die("failed to lock MySQL table: %s\n"); mysql_die("failed to lock MySQL table: %s\n");
...@@ -58,16 +73,17 @@ blacklist_sync(alpm_list_t *pkgs) ...@@ -58,16 +73,17 @@ blacklist_sync(alpm_list_t *pkgs)
mysql_die("failed to clear MySQL table: %s\n"); mysql_die("failed to clear MySQL table: %s\n");
for (r = pkgs; r; r = alpm_list_next(r)) { 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); blacklist_add(alpm_pkg_get_name(pkg));
mysql_real_escape_string(c, se, s, strlen(s));
snprintf(query, 1024, "INSERT INTO PackageBlacklist (Name) "
"VALUES ('%s');", se);
free(se);
if (mysql_query(c, query)) for (p = alpm_pkg_get_provides(pkg); p; p = alpm_list_next(p)) {
mysql_die("failed to query MySQL database (\"%s\"): %s\n", query); 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;")) if (mysql_query(c, "UNLOCK TABLES;"))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment