From a92db325b9b39f621fe8c2973eff48b53bd87ad2 Mon Sep 17 00:00:00 2001 From: Himanshu Shekhar Date: Sun, 18 Oct 2020 11:50:11 +0530 Subject: [PATCH 1/2] PR 1 --- Makefile | 23 +++++++++++++++++++++++ scripts/build.sh | 16 ++++++++++++++++ scripts/imperium.sh | 8 ++++++++ src/main.cpp | 5 +++++ 4 files changed, 52 insertions(+) create mode 100644 Makefile create mode 100755 scripts/build.sh create mode 100755 scripts/imperium.sh create mode 100644 src/main.cpp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7d37d97 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +CXX := g++ +CXX_FLAGS := -std=c++17 -ggdb + +BIN := bin +SRC := src +INCLUDE := +LIB := lib +LIBRARIES := +EXECUTABLE := main + + +all: $(BIN)/$(EXECUTABLE) + +run: clean all + @echo "run called" + ./$(BIN)/$(EXECUTABLE) + +$(BIN)/$(EXECUTABLE): $(SRC)/*.cpp + $(CXX) $(CXX_FLAGS) -I$(INCLUDE) -L$(LIB) $^ -o $ ~/imperium/$(BIN)/$(EXECUTABLE) $(LIBRARIES) -lssl -lcrypto + +clean: + @echo "clean called" + @rm -rf -d ~/imperium/$(BIN)/* \ No newline at end of file diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..70c9ae3 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,16 @@ +#!/bin/bash +sudo apt-get update +sudo apt-get install openssl -y +sudo apt-get install libssl-dev -y +mkdir -p ~/imperium/bin +cp imperium.sh ~/imperium +cd .. +make +cd ~/imperium/bin || echo "error" +chmod +x main +cd .. +if grep -q "source $PWD/imperium.sh" "$PWD/../.bashrc" ; then + echo 'already installed bash source'; +else + echo "source $PWD/imperium.sh" >> ~/.bashrc; +fi \ No newline at end of file diff --git a/scripts/imperium.sh b/scripts/imperium.sh new file mode 100755 index 0000000..0fc96c7 --- /dev/null +++ b/scripts/imperium.sh @@ -0,0 +1,8 @@ +#!/bin/bash +function imperium(){ + DIR=$PWD + export dir=$DIR + cd ~/imperium/bin || echo "Error" + ./main "$@" + cd "$DIR" || echo "Error" +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..6cb21e8 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,5 @@ +#include + +int main(int argc, const char** argv) { + return 0; +} \ No newline at end of file From 68008ba9b746ca438060058719942fec3600d45a Mon Sep 17 00:00:00 2001 From: Himanshu Shekhar Date: Sun, 18 Oct 2020 11:54:19 +0530 Subject: [PATCH 2/2] PR 2 - Init --- src/main.cpp | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 6cb21e8..eeb8ce8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,72 @@ #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -int main(int argc, const char** argv) { +namespace fs = std::filesystem; + +std::string root = ""; + +void init(std::string path) +{ + struct stat buffer; + + if (stat((path + "/.imperium").c_str(), &buffer) == 0) + { + std::cout << "Already initialized as imperium repository" + << "\n"; + } + else + { + std::string imperiumIgnore = path + "/.imperiumIgnore"; + std::ofstream ignore(imperiumIgnore.c_str()); + path += "/.imperium"; + ignore << ".imperium/\n" + << ".git/\n" + << "/.imperiumIgnore\n" + << ".node_modules/\n" + << "/.env\n"; + int created = mkdir(path.c_str(), 0777); + if (created == 0) + { + std::string commitLog = path + "/commit.log"; + std::ofstream commit(commitLog.c_str()); + std::string addLog = path + "/add.log"; + std::string conflictLog = path + "/conflict"; + std::ofstream conflict(conflictLog.c_str()); + std::ofstream add(addLog.c_str()); + add.close(); + commit.close(); + conflict << "false\n"; + conflict.close(); + std::cout << "Initialised imperium repository" + << "\n"; + } + else + { + std::cout << "Error with creation" + << "\n"; + } + } +} + +int main(int argc, const char **argv) +{ + const char *dir = getenv("dir"); + root = dir; + + if (strcmp(argv[1], "init") == 0) + { + init(dir); + } return 0; } \ No newline at end of file