Skip to content

Commit

Permalink
work on dependency type writing for installed packages ( #7 )
Browse files Browse the repository at this point in the history
  • Loading branch information
em1lyy committed Jan 14, 2021
1 parent 9c5adc2 commit dda77e8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION = 0.3

PREFIX =
PREFIX = /usr
MANPREFIX = $(PREFIX)/share/man

CC = gcc
Expand Down
2 changes: 1 addition & 1 deletion depresolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void resolve_recursive(struct pkglist *nodelist, struct pkg_update *updatepkgs[]

if (current_installed && !ignore_updates) {
struct pkg_update *pkgupdt = pkg_has_update(current, database, installed);
if (pkgupdt != NULL) {
if (pkgupdt != NULL && updatepkgs != NULL) {
updatepkgs[*updatec] = pkgupdt;
*updatec = *updatec + 1;
}
Expand Down
1 change: 1 addition & 0 deletions install.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ int install_no_deps(struct package *currpkg, struct pkglist *database, int manua
}

int add_db_entry(struct package *package, int manual_installed, struct pkglist *database) {
// TODO: Write Dependency Types to package->depends field
struct stat st = {0};

// compute path
Expand Down
16 changes: 11 additions & 5 deletions remove.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int pkg_remove(int pkgc, char *pkgnames[]) {
}
}
if (!package_installed) {
printf("Error: package %s is not installed", pkgnames[i]);
fprintf(stderr, "Error: package %s is not installed", pkgnames[i]);
return 1;
}
}
Expand All @@ -35,7 +35,7 @@ int pkg_remove(int pkgc, char *pkgnames[]) {

// remove requested packages
for (int i = 2; i < pkgc; i++) {
retval += remove_single(pkgnames[i], installed);
retval += remove_single(pkgnames[i], installed, database);
}

retval += write_installed_packages(installed, database);
Expand All @@ -47,24 +47,30 @@ int pkg_remove(int pkgc, char *pkgnames[]) {
return 0;
}

int remove_single(char pkgname[], struct pkglist *installed) {
int remove_single(char pkgname[], struct pkglist *installed, struct pkglist *database) {
struct package *currpkg;
int *i;
if (!(i = malloc(sizeof(int)))) malloc_fail();
currpkg = bsearch_pkg(pkgname, installed, i, 0);
free(i);

struct package *currpkg_db;
if (!(i = malloc(sizeof(int)))) malloc_fail();
currpkg_db = bsearch_pkg(pkgname, database, i, 0);
free(i);

// unregister package
remove_db_entry(currpkg, installed);
kawafile_dir_remove(currpkg);

// remove the package using the function provided by the package type class
// use database version because of the way metapkg handle dependency removal
if (!strcmp(currpkg->type, "source"))
return sourcepkg_remove(currpkg);
return sourcepkg_remove(currpkg_db);
else if (!strcmp(currpkg->type, "patch"))
return 0; // TODO: sourcepkg_install(patch=pkgname)
else if (!strcmp(currpkg->type, "meta"))
return metapkg_remove(currpkg);
return metapkg_remove(currpkg_db);
else if (!strcmp(currpkg->type, "binary"))
return binarypkg_remove(pkgname);
return 1;
Expand Down
2 changes: 1 addition & 1 deletion remove.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "sourcepkg.h"

int pkg_remove(int pkgc, char *pkgnames[]);
int remove_single(char pkgname[], struct pkglist *installed);
int remove_single(char pkgname[], struct pkglist *installed, struct pkglist *database);
void remove_db_entry(struct package *package, struct pkglist *installed);

#endif // REMOVE_H

0 comments on commit dda77e8

Please sign in to comment.