bin: use EXIT_SUCCESS and EXIT_FAILURE.
--HG-- extra : convert_revision : 730a4f09ae67423e4a34b1c7e9d020998cc2288c
This commit is contained in:
parent
c0549cd845
commit
15e15465c8
|
@ -73,7 +73,7 @@ usage(void)
|
|||
" $ xbps-bin repo-rm /path/to/directory\n"
|
||||
" $ xbps-bin search klibc\n"
|
||||
" $ xbps-bin show klibc\n");
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -113,14 +113,14 @@ getrepolist_dict(const char *root)
|
|||
|
||||
plist = xbps_append_full_path(true, NULL, XBPS_REPOLIST);
|
||||
if (plist == NULL)
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
dict = prop_dictionary_internalize_from_file(plist);
|
||||
if (dict == NULL) {
|
||||
printf("ERROR: cannot find repository plist file (%s).\n",
|
||||
strerror(errno));
|
||||
free(plist);
|
||||
exit(EINVAL);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return dict;
|
||||
|
@ -200,26 +200,26 @@ main(int argc, char **argv)
|
|||
usage();
|
||||
|
||||
if (!sanitize_localpath(dpkgidx, argv[1]))
|
||||
exit(EINVAL);
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
/* Temp buffer to verify pkgindex file. */
|
||||
plist = xbps_append_full_path(false, dpkgidx, XBPS_PKGINDEX);
|
||||
if (plist == NULL)
|
||||
exit(EINVAL);
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
dict = prop_dictionary_internalize_from_file(plist);
|
||||
if (dict == NULL) {
|
||||
printf("Directory %s does not contain any "
|
||||
"xbps pkgindex file.\n", dpkgidx);
|
||||
free(plist);
|
||||
exit(EINVAL);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
rinfo = malloc(sizeof(*rinfo));
|
||||
if (rinfo == NULL) {
|
||||
prop_object_release(dict);
|
||||
free(plist);
|
||||
exit(ENOMEM);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!pkgindex_getinfo(dict, rinfo)) {
|
||||
|
@ -227,7 +227,7 @@ main(int argc, char **argv)
|
|||
prop_object_release(dict);
|
||||
free(rinfo);
|
||||
free(plist);
|
||||
exit(EINVAL);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!xbps_register_repository(dpkgidx)) {
|
||||
|
@ -236,7 +236,7 @@ main(int argc, char **argv)
|
|||
prop_object_release(dict);
|
||||
free(rinfo);
|
||||
free(plist);
|
||||
exit(EINVAL);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("Added repository at %s (%s) with %ju packages.\n",
|
||||
|
@ -264,7 +264,7 @@ main(int argc, char **argv)
|
|||
usage();
|
||||
|
||||
if (!sanitize_localpath(dpkgidx, argv[1]))
|
||||
exit(EINVAL);
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
if (!xbps_unregister_repository(dpkgidx)) {
|
||||
if (errno == ENODEV)
|
||||
|
@ -273,7 +273,7 @@ main(int argc, char **argv)
|
|||
else
|
||||
printf("ERROR: couldn't unregister "
|
||||
"repository (%s)\n", strerror(errno));
|
||||
exit(EINVAL);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
} else if (strcasecmp(argv[0], "search") == 0) {
|
||||
|
@ -299,7 +299,7 @@ main(int argc, char **argv)
|
|||
free(plist);
|
||||
printf("ERROR: unable to locate package '%s'.\n",
|
||||
argv[1]);
|
||||
exit(EINVAL);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
prop_object_release(dict);
|
||||
free(plist);
|
||||
|
@ -311,20 +311,20 @@ main(int argc, char **argv)
|
|||
|
||||
plist = xbps_append_full_path(true, NULL, XBPS_REGPKGDB);
|
||||
if (plist == NULL)
|
||||
exit(EINVAL);
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
dict = prop_dictionary_internalize_from_file(plist);
|
||||
if (dict == NULL) {
|
||||
printf("No packages currently registered.\n");
|
||||
free(plist);
|
||||
exit(0);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (!xbps_callback_array_iter_in_dict(dict, "packages",
|
||||
xbps_list_pkgs_in_dict, NULL)) {
|
||||
prop_object_release(dict);
|
||||
free(plist);
|
||||
exit(EINVAL);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
prop_object_release(dict);
|
||||
free(plist);
|
||||
|
@ -334,6 +334,12 @@ main(int argc, char **argv)
|
|||
if (argc != 2)
|
||||
usage();
|
||||
|
||||
if (geteuid() != 0) {
|
||||
printf("ERROR: root permissions are needed to install "
|
||||
"binary packages.");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Install into root directory by default. */
|
||||
rv = xbps_install_binary_pkg(argv[1], root);
|
||||
if (rv) {
|
||||
|
@ -344,5 +350,5 @@ main(int argc, char **argv)
|
|||
usage();
|
||||
}
|
||||
|
||||
exit(0);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ static void
|
|||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: xbps-digest <file> <file1+N> ...\n");
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -59,14 +59,14 @@ main(int argc, char **argv)
|
|||
if ((fd = open(argv[i], O_RDONLY)) == -1) {
|
||||
printf("xbps-digest: cannot open %s (%s)\n", argv[i],
|
||||
strerror(errno));
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
digest = malloc(SHA256_DIGEST_LENGTH * 2 + 1);
|
||||
if (digest == NULL) {
|
||||
printf("xbps-digest: malloc failed (%s)\n",
|
||||
strerror(errno));
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
SHA256_Init(&ctx);
|
||||
|
@ -78,5 +78,5 @@ main(int argc, char **argv)
|
|||
close(fd);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ write_plist_file(prop_dictionary_t dict, const char *file)
|
|||
prop_object_release(dict);
|
||||
printf("=> ERROR: couldn't write to %s (%s)",
|
||||
file, strerror(errno));
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ main(int argc, char **argv)
|
|||
/* To specify the root directory */
|
||||
root = strdup(optarg);
|
||||
if (root == NULL)
|
||||
exit(ENOMEM);
|
||||
exit(EXIT_FAILURE);
|
||||
xbps_set_rootdir(root);
|
||||
break;
|
||||
case '?':
|
||||
|
@ -101,7 +101,7 @@ main(int argc, char **argv)
|
|||
if (dbfile == NULL) {
|
||||
printf("=> ERROR: couldn't find regpkdb file (%s)\n",
|
||||
strerror(errno));
|
||||
exit(EINVAL);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
in_chroot_env = getenv("in_chroot");
|
||||
|
@ -139,7 +139,7 @@ main(int argc, char **argv)
|
|||
printf("=> ERROR: couldn't unregister %s "
|
||||
"from database (%s)\n", argv[1],
|
||||
strerror(errno));
|
||||
exit(EINVAL);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("%s=> %s-%s unregistered successfully.\n",
|
||||
|
@ -152,15 +152,15 @@ main(int argc, char **argv)
|
|||
|
||||
dbdict = prop_dictionary_internalize_from_file(dbfile);
|
||||
if (dbdict == NULL)
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
pkgdict = xbps_find_pkg_in_dict(dbdict, argv[1]);
|
||||
if (pkgdict == NULL)
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
if (!prop_dictionary_get_cstring_nocopy(pkgdict, "version",
|
||||
&version))
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
printf("%s\n", version);
|
||||
|
||||
|
@ -173,7 +173,7 @@ main(int argc, char **argv)
|
|||
if (dbdict == NULL) {
|
||||
printf("=> ERROR: couldn't sanitize %s plist file "
|
||||
"(%s)\n", argv[1], strerror(errno));
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
write_plist_file(dbdict, argv[1]);
|
||||
|
||||
|
@ -181,5 +181,5 @@ main(int argc, char **argv)
|
|||
usage();
|
||||
}
|
||||
|
||||
exit(0);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue