checkPackages

Utility for checking libsheepy version used when compiling the packages in local shpPackages
git clone https://noulin.net/git/checkPackages.git
Log | Files | Refs

commit 9e5aa0a5c6a0d1aa3a7c7aed40e82a7f60610604
Author: Remy Noulin <loader2x@gmail.com>
Date:   Wed,  1 May 2019 12:31:35 +0200

recompile local packages when needed

.gitignore      |  63 ++++++++++++++++++++++++++++++++
checkPackages.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package.yml     |  30 +++++++++++++++
3 files changed, 204 insertions(+)

Diffstat:
A.gitignore | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AcheckPackages.c | 111+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apackage.yml | 30++++++++++++++++++++++++++++++
3 files changed, 204 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,63 @@ +# Vim +*.sw* + +# Debug +.gdb_history + +# Coverage +*.gcov +*.gcda +*.gcno + +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf diff --git a/checkPackages.c b/checkPackages.c @@ -0,0 +1,111 @@ +#! /usr/bin/env sheepy +#include "libsheepyObject.h" + +#define shpPDir "shpPackages" + +#define header "\ +#! /usr/bin/env sheepy\n\ +#include \"libsheepyObject.h\"\n\ +" +// add includes +#define mainc "\ +\n\ +int main(int ARGC, char** ARGV) {\n\ +\n\ + char *cwd;\n\ +\n\ +" +#define recompileTemplate "\ + if (!isClassTemplateCompiledWithCurrentLisheepyVersion) {\n\ + cwd = getCwd();\n\ + chDir(\"shpPackages/classTemplate\");\n\ + system(\"sheepy -d ; sheepy -l\");\n\ + chDir(cwd);\n\ + }\n\ +" +#define footer "\ +\n\ +}\ +" + +#define recompileC "recompilePackages.c" + +int main(int ARGC, char** ARGV) { + + initLibsheepy(ARGV[0]); + setLogMode(LOG_PROGNDATE); + disableLibsheepyErrorLogs; + + bool atLeastOnePackage = false; + char **recompile = NULL; + char **incs = NULL; + char **recomp = NULL; + + var dirs = walkDirDir(shpPDir); + + forEachS(dirs, P) { + if (not endsWithG(P, shpPDir)) { + var s = catS(P,"/package.yml"); + createSmallJson(j); + readFileG(&j, s); + + var b = getG(&j, rtChar, "bin"); + + if (b) { + var c = catS(P,"/", b); + normalizePathG(&c); + + //logVarG(c); + + var ld = readDir(P); + + bool foundAOrSo = false; + forEachS(ld, fl) { + if (endsWithG(fl, ".a") or endsWithG(fl, ".so")) { + foundAOrSo = true; + break; + } + } + + if (foundAOrSo) { + if (!atLeastOnePackage) { + pushG(&recompile, header); + atLeastOnePackage = true; + } + setG(c, -1, 'h'); + var ic = catS("#include \"",c,"\""); + pushNFreeG(&incs, ic); + + var base = basename(P); + var rec = replaceS(recompileTemplate, "classTemplate", base, 1); + toUpper(base[0]); + iReplaceS(&rec, "ClassTemplate", base, 1); + pushNFreeG(&recomp, rec); + } + + freeG(ld); + free(c); + } + + freeG(&j); + free(s); + } + } + + freeG(dirs); + + if (not isEmptyG(recompile)) { + appendG(&recompile, incs); + pushG(&recompile, mainc); + appendG(&recompile, recomp); + pushG(&recompile, footer); + writeFileG(recompile, recompileC); + fileChmod(recompileC, 0711); + freeG(recompile); + free(incs); + free(recomp); + logSystemf("./%s", recompileC); + rmAll(recompileC); + } +} +// vim: set expandtab ts=2 sw=2: diff --git a/package.yml b/package.yml @@ -0,0 +1,30 @@ +--- + name: checkPackages + version: 0.0.1 + description: "check libsheepy version in already compiled packages in local shpPackages, recompile when it doesn't match current libsheepy version in the system" + bin: ./checkPackages.c + #cflags: -DA -ggdb -std=gnu11 -fPIC -pipe + #lflags: -lpcre + repository: + type: git + url: git+https://noulin.net/git/checkPackages.git + keywords: + - utility + - command + author: Remy Noulin + license: MIT + homepage: https://noulin.net/checkPackages/log.html + #compileHelp: # text displayed when there is a compilation error + #dependencies: + # md4c: + # Test configuration: + #testBin: ./testCheckPackages.c + #testCflags: -ggdb -std=gnu11 -fPIC -pipe -fprofile-arcs -ftest-coverage -Wall -Wextra + #testLflags: -lcheck_pic -lrt -lm -lsubunit -fprofile-arcs -ftest-coverage -rdynamic + # Memcheck configuration: + #memcheckBin: ./memcheckCheckPackages.c + #memcheckCmd: valgrind --leak-check=full --show-leak-kinds=all + #memcheckCflags: -ggdb -std=gnu11 -fPIC -pipe + #memcheckLflags: -rdynamic + #documentationCmd: # command for generating the documentation with spm doc + private: false # true for private package