Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Marcus Andersson
aurweb
Commits
ddc54358
Commit
ddc54358
authored
Feb 08, 2011
by
Lukas Fleischer
Browse files
Add packages' provides and replaces to the blacklist in aurblup.
Signed-off-by:
Lukas Fleischer
<
archlinux@cryptocrack.de
>
parent
48957ef5
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/aurblup/aurblup.c
View file @
ddc54358
...
...
@@ -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
=
al
pm
_
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;"
))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment