summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--flags.c81
-rw-r--r--utils.c15
-rw-r--r--utils.h3
4 files changed, 71 insertions, 29 deletions
diff --git a/README.md b/README.md
index 209f427..8e821c2 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,7 @@ This is a C wrapper that integrates with the prebuilt package managers in variou
* Arch Linux based distros;
* Debian based distros;
+* Fedora based distros;
* Gentoo based distros;
* Void Linux *(or xbps)* derived/based distro.
diff --git a/flags.c b/flags.c
index d6b579d..bc0f22e 100644
--- a/flags.c
+++ b/flags.c
@@ -45,18 +45,22 @@ void cleanPackages(int os)
{
switch(os)
{
- case pacman:
- system("pacman -Rns \"$(pacman -Qtdq)\" || pacman -Scc");
- break;
-
case apt:
system("apt autoremove --purge || apt clean");
break;
+ case dnf:
+ system("dnf clean all && dnf autoremove");
+ break;
+
case emerge:
system("emerge -caq");
break;
+ case pacman:
+ system("pacman -Rns \"$(pacman -Qtdq)\" || pacman -Scc");
+ break;
+
case xbps:
system("xbps-remove -ROo");
}
@@ -81,15 +85,15 @@ void installPackages(int os, char *packages)
char* command = (char *) calloc(strlen(packages) + 80, sizeof(char));
switch(os)
{
- case pacman:
- strcpy(command, "pacman -S ");
+ case apt:
+ strcpy(command, "apt install ");
strcat(command, packages);
system(command);
free(command);
break;
- case apt:
- strcpy(command, "apt install ");
+ case dnf:
+ strcpy(command, "dnf install ");
strcat(command, packages);
system(command);
free(command);
@@ -102,6 +106,13 @@ void installPackages(int os, char *packages)
free(command);
break;
+ case pacman:
+ strcpy(command, "pacman -S ");
+ strcat(command, packages);
+ system(command);
+ free(command);
+ break;
+
case xbps:
strcpy(command, "xbps-install -S ");
strcat(command, packages);
@@ -119,18 +130,22 @@ void queryPackages(int os)
{
switch(os)
{
- case pacman:
- system("pacman -Qs");
- break;
-
case apt:
system("apt list --installed");
break;
+ case dnf:
+ system("dnf list --installed");
+ break;
+
case emerge:
system("cd /var/db/pkg/ && ls -d */* | sed 's:\\/$::'");
break;
+ case pacman:
+ system("pacman -Qs");
+ break;
+
case xbps:
system("xbps-query -l");
}
@@ -143,15 +158,15 @@ void removePackages(int os, char *packages)
char* command = (char *) calloc(strlen(packages) + 80, sizeof(char));
switch(os)
{
- case pacman:
- strcpy(command, "pacman -Rnsc ");
+ case apt:
+ strcpy(command, "apt autoremove --purge ");
strcat(command, packages);
system(command);
free(command);
break;
- case apt:
- strcpy(command, "apt autoremove --purge ");
+ case dnf:
+ strcpy(command, "dnf remove ");
strcat(command, packages);
system(command);
free(command);
@@ -164,6 +179,13 @@ void removePackages(int os, char *packages)
free(command);
break;
+ case pacman:
+ strcpy(command, "pacman -Rnsc ");
+ strcat(command, packages);
+ system(command);
+ free(command);
+ break;
+
case xbps:
strcpy(command, "xbps-remove -ROo ");
strcat(command, packages);
@@ -184,15 +206,15 @@ void searchPackages(int os, char *packages)
char* command = (char *) calloc(strlen(packages) + 80, sizeof(char));
switch(os)
{
- case pacman:
- strcpy(command, "pacman -Ss ");
+ case apt:
+ strcpy(command, "apt search ");
strcat(command, packages);
system(command);
free(command);
break;
- case apt:
- strcpy(command, "apt search ");
+ case dnf:
+ strcpy(command, "dnf search ");
strcat(command, packages);
system(command);
free(command);
@@ -205,6 +227,13 @@ void searchPackages(int os, char *packages)
free(command);
break;
+ case pacman:
+ strcpy(command, "pacman -Ss ");
+ strcat(command, packages);
+ system(command);
+ free(command);
+ break;
+
case xbps:
strcpy(command, "xbps-query -Rs ");
strcat(command, packages);
@@ -222,18 +251,22 @@ void updatePackages(int os)
{
switch(os)
{
- case pacman:
- system("pacman -Syyuu");
- break;
-
case apt:
system("apt update && apt upgrade -y");
break;
+ case dnf:
+ system("dnf update");
+ break;
+
case emerge:
system("emerge-webrsync && emerge -uaqDU --keep-going --with-bdeps=y --newuse @world");
break;
+ case pacman:
+ system("pacman -Syyuu");
+ break;
+
case xbps:
system("xbps-install -Su");
}
diff --git a/utils.c b/utils.c
index 65ac047..da61aed 100644
--- a/utils.c
+++ b/utils.c
@@ -15,15 +15,15 @@ int detectOsType()
{
switch (i)
{
- case pacman:
- if ( checkIfFileExists("/usr/bin/pacman") == 0 )
+ case apt:
+ if ( checkIfFileExists("/usr/bin/apt") == 0 )
{
exists = i;
}
break;
- case apt:
- if ( checkIfFileExists("/usr/bin/apt") == 0 )
+ case dnf:
+ if ( checkIfFileExists("/usr/bin/dnf") == 0 )
{
exists = i;
}
@@ -36,6 +36,13 @@ int detectOsType()
}
break;
+ case pacman:
+ if ( checkIfFileExists("/usr/bin/pacman") == 0 )
+ {
+ exists = i;
+ }
+ break;
+
case xbps:
if ( checkIfFileExists("/usr/bin/xbps-install") == 0 )
{
diff --git a/utils.h b/utils.h
index e4ddde5..2957918 100644
--- a/utils.h
+++ b/utils.h
@@ -4,9 +4,10 @@
enum os
{
- pacman,
apt,
+ dnf,
emerge,
+ pacman,
xbps,
ENUMSIZE
};