Cleanup and buildup
This commit is contained in:
parent
c0cf20b869
commit
6b8d91e94c
BIN
bin/install
BIN
bin/install
Binary file not shown.
@ -6,11 +6,12 @@
|
|||||||
#define DEBUG_H
|
#define DEBUG_H
|
||||||
|
|
||||||
#include "nprint.h"
|
#include "nprint.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef debugEnabled
|
#ifdef debugEnabled
|
||||||
#define DEBUG_PRINT(fmt, ...) nprint("D", fmt, ##__VA_ARGS__)
|
#define DEBUG_PRINT(fmt, ...) nprint("D", fmt, ##__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define DEBUG_PRINT(fmg, ...) void(0)
|
#define DEBUG_PRINT(fmt, ...) do {} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //DEBUG_H
|
#endif //DEBUG_H
|
||||||
|
13
inc/fex.h
13
inc/fex.h
@ -7,14 +7,15 @@
|
|||||||
|
|
||||||
enum Flags {
|
enum Flags {
|
||||||
FLAG_INSTALL = 1 << 0,
|
FLAG_INSTALL = 1 << 0,
|
||||||
FLAG_SOURCE = 1 << 1,
|
//FLAG_SOURCE = 1 << 1,
|
||||||
FLAG_UNINSTALL = 1 << 2,
|
//FLAG_UNINSTALL = 1 << 1,
|
||||||
FLAG_LIST = 1 << 3,
|
FLAG_LIST = 1 << 1,
|
||||||
FLAG_SEARCH = 1 << 4,
|
FLAG_SEARCH = 1 << 2,
|
||||||
FLAG_FORCE = 1 << 5,
|
FLAG_FORCE = 1 << 3,
|
||||||
FLAG_UPGRADE = 1 << 6,
|
FLAG_UPGRADE = 1 << 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern char* flagNames[];
|
extern char* flagNames[];
|
||||||
|
extern int flagSource, flagUninstall;
|
||||||
|
|
||||||
#endif //FEX_H
|
#endif //FEX_H
|
||||||
|
10
inc/install.h
Normal file
10
inc/install.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
//
|
||||||
|
// Created by auric on 2/28/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef INSTALL_H
|
||||||
|
#define INSTALL_H
|
||||||
|
|
||||||
|
int installPackages(char** package, int pkgCount, int source, int uninstall);
|
||||||
|
|
||||||
|
#endif //INSTALL_H
|
BIN
obj/install.o
BIN
obj/install.o
Binary file not shown.
BIN
obj/sanity.o
BIN
obj/sanity.o
Binary file not shown.
38
src/fex.c
38
src/fex.c
@ -5,22 +5,25 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <nprint.h>
|
#include <nprint.h>
|
||||||
#include <sanity.h>
|
#include "sanity.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "fex.h"
|
#include "fex.h"
|
||||||
|
#include "install.h"
|
||||||
|
|
||||||
void help() {
|
void help() {
|
||||||
nprint("E", "Usage: fex (OPT) (PACKAGES)");
|
nprint("E", "Usage: fex (OPT) (PACKAGES)");
|
||||||
}
|
}
|
||||||
|
|
||||||
char* flagNames[] = {"INSTALL", "SOURCE", "UNINSTALL", "LIST", "SEARCH", "FORCE", "UPGRADE"};
|
char* flagNames[] = {"INSTALL","LIST", "SEARCH", "FORCE", "UPGRADE"};
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
char* packages[argc - 1];
|
char* packages[argc - 1];
|
||||||
int pkgCount = 0;
|
int pkgCount = 0;
|
||||||
|
int flagSource, flagUninstall = 0;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
help();
|
help();
|
||||||
@ -35,10 +38,12 @@ int main(int argc, char** argv) {
|
|||||||
flags |= FLAG_INSTALL;
|
flags |= FLAG_INSTALL;
|
||||||
break;
|
break;
|
||||||
case 'S': // source, 1
|
case 'S': // source, 1
|
||||||
flags |= FLAG_SOURCE;
|
//flags |= FLAG_SOURCE;
|
||||||
|
flagSource = 1;
|
||||||
break;
|
break;
|
||||||
case 'r': // remove, 2
|
case 'r': // remove, 2
|
||||||
flags |= FLAG_UNINSTALL;
|
//flags |= FLAG_UNINSTALL;
|
||||||
|
flagUninstall = 1;
|
||||||
break;
|
break;
|
||||||
case 'l': // list, 3
|
case 'l': // list, 3
|
||||||
flags |= FLAG_LIST;
|
flags |= FLAG_LIST;
|
||||||
@ -69,7 +74,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
#ifdef debugEnabled
|
#ifdef debugEnabled
|
||||||
DEBUG_PRINT("sysSanity: %d", sysSanity);
|
DEBUG_PRINT("sysSanity: %d", sysSanity);
|
||||||
unsigned int flagValues[] = {0b0000001, 0b0000010, 0b0000100, 0b0001000, 0b0010000, 0b0100000, 0b1000000};
|
unsigned int flagValues[] = {0b00001, 0b00010, 0b00100, 0b01000, 0b10000};
|
||||||
int numFlags = sizeof(flagValues) / sizeof(flagValues[0]);
|
int numFlags = sizeof(flagValues) / sizeof(flagValues[0]);
|
||||||
for(int i = 0; i < numFlags; i++) {
|
for(int i = 0; i < numFlags; i++) {
|
||||||
if (flags & flagValues[i]) {
|
if (flags & flagValues[i]) {
|
||||||
@ -86,9 +91,26 @@ int main(int argc, char** argv) {
|
|||||||
/* End Prelogic */
|
/* End Prelogic */
|
||||||
DEBUG_PRINT("[!] Break parselogic");
|
DEBUG_PRINT("[!] Break parselogic");
|
||||||
|
|
||||||
for(int i = 0; i < numFlags; i++) {
|
if(flags & FLAG_LIST) {
|
||||||
DEBUG_PRINT("Iterating over %s", flagNames[i]);
|
DEBUG_PRINT("HIT: List");
|
||||||
|
// list packages
|
||||||
|
}
|
||||||
|
if(flags & FLAG_SEARCH) {
|
||||||
|
DEBUG_PRINT("HIT: Search");
|
||||||
|
// search packages
|
||||||
|
}
|
||||||
|
if(!(getuid())) {
|
||||||
|
if (flags & FLAG_INSTALL) {
|
||||||
|
DEBUG_PRINT("HIT: Install. Source: %d; Uninstall: %d", flagSource, flagUninstall);
|
||||||
|
installPackages(packages, pkgCount, flagSource, flagUninstall);
|
||||||
|
}
|
||||||
|
if(flags & FLAG_UPGRADE) {
|
||||||
|
DEBUG_PRINT("HIT: Upgrade");
|
||||||
|
//upgrade
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nprint("E", "Superuser permissions required for this operation.");
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -2,14 +2,11 @@
|
|||||||
Created by auric on 2/21/24.
|
Created by auric on 2/21/24.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
#include "../inc/debug.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
int installPackages(char** packages, int pkgCount, int source, int uninstall) {
|
||||||
#include <stdlib.h>
|
for(int i = 0; i < pkgCount; i++) {
|
||||||
#include <string.h>
|
DEBUG_PRINT("PACKAGE: %s", packages[i]);
|
||||||
#include <nprint.h>
|
DEBUG_PRINT("pkgCount ('i'): %d", i);
|
||||||
/* Prototype main for suite instead of a unified manager. Obviously never developed
|
}
|
||||||
int main() {
|
|
||||||
nprint("I", "Information");
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
10
src/sanity.c
10
src/sanity.c
@ -13,8 +13,6 @@
|
|||||||
* exist, and if the owner can write to them. This notably does not check if the program is run as superuser.
|
* exist, and if the owner can write to them. This notably does not check if the program is run as superuser.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* For a root check - simply use conditional checking for a zero value in some way, such as !(getuid()) */
|
|
||||||
|
|
||||||
int isSysSane() {
|
int isSysSane() {
|
||||||
struct stat conStat, exeStat, utiStat, libStat, hdrStat;
|
struct stat conStat, exeStat, utiStat, libStat, hdrStat;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
@ -34,12 +32,12 @@ int isSysSane() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int isSyntaxSane(unsigned int flags, int pkgCount) {
|
int isSyntaxSane(unsigned int flags, int pkgCount) {
|
||||||
if((flags & FLAG_INSTALL) && (flags & FLAG_UNINSTALL)) {
|
/*if((flags & FLAG_INSTALL)) {
|
||||||
nprint("E", "You cannot install and uninstall at the same time"); // TODO: allow for this to happen by parsing the flags in order. e.g fex -i japes -u japes2 should install japes and uninstall japes2
|
nprint("E", "You cannot install and uninstall at the same time"); // Sequential parsing of flags would leave so many ambiguous cases and expand these checks greatly. Not worth it without extensive research
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if(((flags & FLAG_INSTALL) || (flags & FLAG_UNINSTALL)) && (pkgCount == 0)) {
|
if((flags & FLAG_INSTALL) && (pkgCount == 0)) {
|
||||||
nprint("E", "You must specify at least one package");
|
nprint("E", "You must specify at least one package");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user