xbps_removed_binary_pkg(): chdir after checking if pkg is installed not before.

--HG--
extra : convert_revision : c06555f92939f37740b1677d842619eeb1f5d5ac
This commit is contained in:
Juan RP 2009-04-05 14:48:24 +02:00
parent 4f8d329867
commit 986a54a56f
1 changed files with 6 additions and 4 deletions

View File

@ -221,16 +221,18 @@ xbps_remove_binary_pkg(const char *pkgname, bool update)
assert(pkgname != NULL); assert(pkgname != NULL);
/*
* Check if pkg is installed before anything else.
*/
if (xbps_check_is_installed_pkgname(pkgname) == false)
return ENOENT;
if (strcmp(rootdir, "") == 0) if (strcmp(rootdir, "") == 0)
rootdir = "/"; rootdir = "/";
if (chdir(rootdir) == -1) if (chdir(rootdir) == -1)
return errno; return errno;
/* Check if pkg is installed */
if (xbps_check_is_installed_pkgname(pkgname) == false)
return ENOENT;
buf = xbps_xasprintf("%s/%s/metadata/%s/REMOVE", rootdir, buf = xbps_xasprintf("%s/%s/metadata/%s/REMOVE", rootdir,
XBPS_META_PATH, pkgname); XBPS_META_PATH, pkgname);
if (buf == NULL) if (buf == NULL)