mirror of
https://github.com/fosslinux/live-bootstrap.git
synced 2026-03-02 01:18:08 +01:00
Merge pull request #419 from fosslinux/live-system-nochange
Live system nochange
This commit is contained in:
commit
3e2663b3bd
30 changed files with 294 additions and 152 deletions
|
|
@ -7,10 +7,10 @@
|
|||
#define MAX_TOKEN 64
|
||||
#define MAX_STRING 2048
|
||||
|
||||
#include <bootstrappable.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <bootstrappable.h>
|
||||
|
||||
struct Token {
|
||||
char *val;
|
||||
|
|
@ -22,7 +22,7 @@ typedef struct Token Token;
|
|||
#define TYPE_IMPROVE 2
|
||||
#define TYPE_DEFINE 3
|
||||
#define TYPE_JUMP 4
|
||||
#define TYPE_MAINT 5
|
||||
#define TYPE_UNINSTALL 5
|
||||
|
||||
struct Directive {
|
||||
Token *tok;
|
||||
|
|
@ -212,12 +212,12 @@ Token *fill(Token *tok, Directive *directive, int type) {
|
|||
|
||||
Token *logic(Token *tok, char **val) {
|
||||
/* logic = "("
|
||||
* (name |
|
||||
* (name "==" value) |
|
||||
* (name "!=" value) |
|
||||
* (logic "||" logic) |
|
||||
* (logic "&&" logic))
|
||||
* ")"
|
||||
* (name |
|
||||
* (name "==" value) |
|
||||
* (name "!=" value) |
|
||||
* (logic "||" logic) |
|
||||
* (logic "&&" logic))
|
||||
* ")"
|
||||
*/
|
||||
|
||||
char *lhs = tok->val;
|
||||
|
|
@ -237,15 +237,15 @@ Token *logic(Token *tok, char **val) {
|
|||
lhs = "False";
|
||||
}
|
||||
} else if (strcmp(tok->val, "!=") == 0) {
|
||||
/* Case for inequality. */
|
||||
rhs = tok->next->val;
|
||||
tok = tok->next->next;
|
||||
if (strcmp(get_var(lhs), rhs) == 0) {
|
||||
lhs = "False";
|
||||
} else {
|
||||
lhs = "True";
|
||||
}
|
||||
} else {
|
||||
/* Case for inequality. */
|
||||
rhs = tok->next->val;
|
||||
tok = tok->next->next;
|
||||
if (strcmp(get_var(lhs), rhs) == 0) {
|
||||
lhs = "False";
|
||||
} else {
|
||||
lhs = "True";
|
||||
}
|
||||
} else {
|
||||
fputs("Expected == or != after ", stderr);
|
||||
fputs(lhs, stderr);
|
||||
fputs(" in logic\n", stderr);
|
||||
|
|
@ -360,7 +360,7 @@ Token *define(Token *tok, Directive *directive) {
|
|||
}
|
||||
|
||||
int interpret(Directive *directive) {
|
||||
/* directive = (build | improve | define | jump | maint) predicate? */
|
||||
/* directive = (build | improve | define | jump | uninstall) predicate? */
|
||||
Token *tok = directive->tok;
|
||||
if (strcmp(tok->val, "build:") == 0) {
|
||||
tok = fill(tok->next, directive, TYPE_BUILD);
|
||||
|
|
@ -368,11 +368,23 @@ int interpret(Directive *directive) {
|
|||
tok = fill(tok->next, directive, TYPE_IMPROVE);
|
||||
} else if (strcmp(tok->val, "jump:") == 0) {
|
||||
tok = fill(tok->next, directive, TYPE_JUMP);
|
||||
} else if (strcmp(tok->val, "maint:") == 0) {
|
||||
tok = fill(tok->next, directive, TYPE_MAINT);
|
||||
} else if (strcmp(tok->val, "define:") == 0) {
|
||||
tok = define(tok->next, directive);
|
||||
return 1; /* There is no codegen for a define. */
|
||||
} else if (strcmp(tok->val, "uninstall:") == 0) {
|
||||
tok = fill(tok->next, directive, TYPE_UNINSTALL);
|
||||
while (tok != NULL) {
|
||||
if (strcmp(tok->val, "(") == 0) {
|
||||
break;
|
||||
}
|
||||
if (strlen(directive->arg) + strlen(tok->val) + 1 > MAX_STRING) {
|
||||
fputs("somehow you have managed to have too many uninstall arguments.\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
directive->arg = strcat(directive->arg, " ");
|
||||
directive->arg = strcat(directive->arg, tok->val);
|
||||
tok = tok->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (tok != NULL) {
|
||||
|
|
@ -620,8 +632,10 @@ void generate(Directive *directives) {
|
|||
fclose(out);
|
||||
out = start_script(counter, bash_build);
|
||||
counter += 1;
|
||||
} else if (directive->type == TYPE_MAINT) {
|
||||
output_call_script(out, "maint", directive->arg, bash_build, 1);
|
||||
} else if (directive->type == TYPE_UNINSTALL) {
|
||||
fputs("uninstall ", out);
|
||||
fputs(directive->arg, out);
|
||||
fputs("\n", out);
|
||||
}
|
||||
}
|
||||
fclose(out);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue