aboutsummaryrefslogtreecommitdiff
path: root/src/spm.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2020-02-26 16:09:32 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2020-02-26 16:09:32 -0500
commitd3580f8c0b5c17150382c4b4456e0b1bfa81a50f (patch)
tree5d0fa6911974b2a0541738a7cffc408b09918b8b /src/spm.c
parent639aa9dbf60050bf1bbaeea67df13729239c3a31 (diff)
downloadspmc-d3580f8c0b5c17150382c4b4456e0b1bfa81a50f.tar.gz
Multiple things:
* Add strdup_array() * Begin consolidating spm root information into SPM_Hierarchy * Begin consolidating metadata * Begin trimming repeated code (mostly file reading) * Store information about installed packages under [root]/var/db/records
Diffstat (limited to 'src/spm.c')
-rw-r--r--src/spm.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/spm.c b/src/spm.c
index 7f58ad1..8444990 100644
--- a/src/spm.c
+++ b/src/spm.c
@@ -175,36 +175,24 @@ int main(int argc, char *argv[], char *arge[]) {
sprintf(rootdir, "%s%c%s", getenv("HOME"), DIRSEP, "spm_root");
}
+ SPM_Hierarchy *rootfs = spm_hierarchy_init(rootdir);
+
// Construct installation runtime environment
RuntimeEnv *rt = runtime_copy(arge);
// TODO: Move environment allocation out of (above) this loop if possible
// TODO: replace variables below with SPM_Hierarchy, and write some control functions
- char *spm_bindir = join((char *[]) {rootdir, "bin", NULL}, DIRSEPS);
- char *spm_includedir = join((char *[]) {rootdir, "include", NULL}, DIRSEPS);
- char *spm_libdir = join((char *[]) {rootdir, "lib", NULL}, DIRSEPS);
- char *spm_datadir = join((char *[]) {rootdir, "share", NULL}, DIRSEPS);
- char *spm_mandir = join((char *[]) {spm_datadir, "man", NULL}, DIRSEPS);
- char *spm_localstatedir = join((char *[]) {rootdir, "var", NULL}, DIRSEPS);
-
- runtime_set(rt, "SPM_BIN", spm_bindir);
- runtime_set(rt, "SPM_INCLUDE", spm_includedir);
- runtime_set(rt, "SPM_LIB", spm_libdir);
- runtime_set(rt, "SPM_DATA", spm_datadir);
- runtime_set(rt, "SPM_MAN", spm_mandir);
- runtime_set(rt, "SPM_LOCALSTATE", spm_localstatedir);
+ runtime_set(rt, "SPM_BIN", rootfs->bindir);
+ runtime_set(rt, "SPM_INCLUDE", rootfs->includedir);
+ runtime_set(rt, "SPM_LIB", rootfs->libdir);
+ runtime_set(rt, "SPM_DATA", rootfs->datadir);
+ runtime_set(rt, "SPM_MAN", rootfs->mandir);
+ runtime_set(rt, "SPM_LOCALSTATE", rootfs->localstatedir);
runtime_apply(rt);
- free(spm_bindir);
- free(spm_includedir);
- free(spm_libdir);
- free(spm_datadir);
- free(spm_mandir);
- free(spm_localstatedir);
-
if (RUNTIME_INSTALL) {
int status_install = 0;
- if ((status_install = do_install(mf, rootdir, packages)) == -1) {
+ if ((status_install = do_install(rootfs, mf, packages)) == -1) {
// failed to create temporary destination root
exit(1);
}
@@ -287,5 +275,6 @@ int main(int argc, char *argv[], char *arge[]) {
free_global_config();
strlist_free(packages);
manifestlist_free(mf);
+ spm_hierarchy_free(rootfs);
return 0;
}