aboutsummaryrefslogtreecommitdiff
path: root/src/internal_cmd.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2020-02-18 09:12:13 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2020-02-18 09:13:49 -0500
commit6292c699248d3dfa6271ae0961e63436615653f2 (patch)
treec456bacd51414480179c60e520867c8ff9cc1836 /src/internal_cmd.c
parent1c2cdc4d8e28ce1b4c0d1ba75686f05fd5dd772d (diff)
downloadspmc-6292c699248d3dfa6271ae0961e63436615653f2.tar.gz
Rework dependency scanning:
* Stop resolving dependencies during manifest creation * Resolve dependencies by path * Die on failure to resolve * Fixed an off-by-one error in manifest_read * Add CLI argument -M|--override-manifest to disable default manifest(s) * Clean up expandpath() a bit
Diffstat (limited to 'src/internal_cmd.c')
-rw-r--r--src/internal_cmd.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/internal_cmd.c b/src/internal_cmd.c
index e1344ed..8d91029 100644
--- a/src/internal_cmd.c
+++ b/src/internal_cmd.c
@@ -100,31 +100,39 @@ void mkmanifest_interface_usage(void) {
* @return value of `manifest_write`
*/
int mkmanifest_interface(int argc, char **argv) {
+ Manifest *manifest = NULL;
+ int result = 0;
+ char *pkgdir = NULL;
+
if (argc < 2) {
mkmanifest_interface_usage();
return -1;
}
- Manifest *manifest = NULL;
- int result = 0;
- char *pkgdir = NULL;
- pkgdir = argv[1];
+ if ((pkgdir = expandpath(argv[1])) == NULL) {
+ fprintf(stderr, "bad path\n");
+ return -2;
+ }
if (exists(pkgdir) != 0) {
- return -1;
+ fprintf(stderr, "'%s': does not exist\n", pkgdir);
+ return -3;
}
manifest = manifest_from(pkgdir);
if (manifest == NULL) {
- return -2;
+ fprintf(stderr, "no packages\n");
+ return -4;
}
result = manifest_write(manifest, pkgdir);
if (result != 0) {
+ fprintf(stderr, "an error occurred while writing manifest data\n");
manifest_free(manifest);
- return -3;
+ return -5;
}
+ free(pkgdir);
manifest_free(manifest);
return result;
}