initial import
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
*.o
|
||||||
|
|
||||||
|
build
|
||||||
|
cmake-build-*
|
||||||
|
sgard
|
||||||
38
CMakeLists.txt
Normal file
38
CMakeLists.txt
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
|
project(sgard VERSION 0.0.1
|
||||||
|
LANGUAGES CXX
|
||||||
|
DESCRIPTION "Shimmer Clarity Gardener: A dot-files manager.")
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_VERBOSE_MAKEFILES TRUE)
|
||||||
|
|
||||||
|
find_package(Protobuf REQUIRED)
|
||||||
|
find_package(scsl REQUIRED)
|
||||||
|
|
||||||
|
file(GLOB ProtoFiles "${CMAKE_CURRENT_SOURCE_DIR}/proto/*.proto")
|
||||||
|
PROTOBUF_GENERATE_CPP(ProtoSources ProtoHeaders ${ProtoFiles})
|
||||||
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
include_directories(${SCSL_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
add_library(protolib STATIC ${ProtoSources} ${ProtoHeaders})
|
||||||
|
target_link_libraries(protolib INTERFACE ${Protobuf_LIBRARIES})
|
||||||
|
|
||||||
|
add_compile_options(
|
||||||
|
"-static"
|
||||||
|
"-Werror" "-Wextra" "-Wall"
|
||||||
|
"-Weffc++"
|
||||||
|
)
|
||||||
|
|
||||||
|
if (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||||
|
add_compile_options("-g" "-fsanitize=address")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(HEADER_FILES
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
set(SOURCE_FILES sgard.cc)
|
||||||
|
|
||||||
|
add_executable(sgard ${SOURCE_FILES})
|
||||||
|
target_link_libraries(sgard protolib ${SCSL_LIBRARIES})
|
||||||
11
proto/header.proto
Normal file
11
proto/header.proto
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
syntax = 'proto3';
|
||||||
|
package sgardpb;
|
||||||
|
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
|
||||||
|
// Header defines common metadata for messages in sgard.
|
||||||
|
message Header {
|
||||||
|
uint32 version = 1;
|
||||||
|
google.protobuf.Timestamp created = 2;
|
||||||
|
google.protobuf.Timestamp updated = 3;
|
||||||
|
}
|
||||||
11
proto/homedir.proto
Normal file
11
proto/homedir.proto
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
syntax = 'proto3';
|
||||||
|
package sgardpb;
|
||||||
|
|
||||||
|
import 'header.proto';
|
||||||
|
import 'path.proto';
|
||||||
|
|
||||||
|
message HomeDir {
|
||||||
|
Header header = 1;
|
||||||
|
|
||||||
|
map<string, Source> files = 5;
|
||||||
|
};
|
||||||
31
proto/path.proto
Normal file
31
proto/path.proto
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
syntax = 'proto3';
|
||||||
|
package sgardpb;
|
||||||
|
|
||||||
|
import 'header.proto';
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
|
||||||
|
enum PathType {
|
||||||
|
PATHTYPE_UNSPECIFIED = 0;
|
||||||
|
PATHTYPE_FILE = 1;
|
||||||
|
PATHTYPE_DIRECTORY = 2;
|
||||||
|
PATHTYPE_LINK = 3;
|
||||||
|
};
|
||||||
|
|
||||||
|
message FilePath {
|
||||||
|
Header header = 1;
|
||||||
|
|
||||||
|
string source_path = 2;
|
||||||
|
string dest_path = 3;
|
||||||
|
// todo: add mode, action (e.g. copy vs link)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
message Source {
|
||||||
|
Header header = 1;
|
||||||
|
PathType path_type = 2;
|
||||||
|
|
||||||
|
oneof path {
|
||||||
|
FilePath file = 5;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
106
scripts/install-depdendencies.sh
Executable file
106
scripts/install-depdendencies.sh
Executable file
@@ -0,0 +1,106 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
#####################################################################
|
||||||
|
# This script attempts to install the appopriate build dependencies #
|
||||||
|
# for the host system. #
|
||||||
|
# #
|
||||||
|
# For platforms marked as unverified, it means that I was able to #
|
||||||
|
# start a Docker container for that platform and could look up the #
|
||||||
|
# right package names. I haven't actually tried building on these #
|
||||||
|
# platforms. #
|
||||||
|
# #
|
||||||
|
# This is primarily developed on the latest Ubuntu LTS release and #
|
||||||
|
# MacOS; other platforms are best-effort. #
|
||||||
|
#####################################################################
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
install_debianesque () {
|
||||||
|
echo "[+] distribution is ${DISTRIB_ID}, choosing Debianesque install."
|
||||||
|
|
||||||
|
echo "[+] installing tools"
|
||||||
|
sudo apt-get install git cmake clang scdoc
|
||||||
|
|
||||||
|
echo "[+] installing protobuf libraries and development headers"
|
||||||
|
sudo apt-get install protobuf-compiler libprotobuf-dev
|
||||||
|
|
||||||
|
echo "[+] installing gRPC libraries and development headers"
|
||||||
|
sudo apt-get install protobuf-compiler-grpc grpc-proto libgrpc++-dev
|
||||||
|
}
|
||||||
|
|
||||||
|
install_redhat () {
|
||||||
|
echo "[+] distribution is ${DISTRIB_ID}, choosing Redhat install."
|
||||||
|
echo "[!] WARNING: installation for Redhat systems is unverified."
|
||||||
|
|
||||||
|
echo "[+] installing tools"
|
||||||
|
sudo dnf install git cmake clang scdoc
|
||||||
|
|
||||||
|
echo "[+] installing libraries and development headers"
|
||||||
|
sudo dnf install protobuf-compiler libprotobuf-dev
|
||||||
|
}
|
||||||
|
|
||||||
|
install_alpine () {
|
||||||
|
echo "[+] distribution is ${DISTRIB_ID}, choosing Alpine install."
|
||||||
|
echo "[!] WARNING: installation for Alpine systems is unverified."
|
||||||
|
|
||||||
|
echo "[+] installing tools"
|
||||||
|
sudo dnf install git cmake clang scdoc
|
||||||
|
|
||||||
|
echo "[+] installing libraries and development headers"
|
||||||
|
sudo dnf install sdl2-dev freetype-dev protobuf-compiler-grpc
|
||||||
|
}
|
||||||
|
|
||||||
|
install_macos () {
|
||||||
|
# TODO: consider supporting macports?
|
||||||
|
echo "[+] host system is MacOS"
|
||||||
|
|
||||||
|
echo "[+] installing tools"
|
||||||
|
brew install git cmake scdoc
|
||||||
|
|
||||||
|
echo "[+] installing libraries and development headers"
|
||||||
|
# TODO: look up proper package names in homebrew
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
install_linux () {
|
||||||
|
echo "[+] host system is Linux"
|
||||||
|
[[ -f "/etc/lsb-release" ]] && source /etc/lsb-release
|
||||||
|
if [ -z "${DISTRIB_ID}" ]
|
||||||
|
then
|
||||||
|
if [ -d /etc/apt ]
|
||||||
|
then
|
||||||
|
DISTRIB_ID="apt-based"
|
||||||
|
elif [ -f /etc/alpine-release ]
|
||||||
|
then
|
||||||
|
DISTRIB_ID=Alpine
|
||||||
|
elif [ -d /etc/dnf -o /etc/yum.repos.d ]
|
||||||
|
then
|
||||||
|
# I don't use Fedora, this is based on a cursory
|
||||||
|
# glance at the filesystem on a Docker image.
|
||||||
|
DISTRIB_ID="Fedora"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
case ${DISTRIB_ID} in
|
||||||
|
Ubuntu) install_debianesque ;;
|
||||||
|
Debian) install_debianesque ;;
|
||||||
|
apt-based) install_debianesque ;;
|
||||||
|
Fedora) install_redhat ;;
|
||||||
|
Alpine) install_alpine ;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "[!] distribution ${DISTRIB_ID} isn't supported in this script." > /dev/null
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case "$(uname -s)" in
|
||||||
|
Linux) install_linux ;;
|
||||||
|
Darwin) install_macos ;;
|
||||||
|
*)
|
||||||
|
echo "[!] platform $(uname -s) isn't supported in this script." > /dev/null
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
25
sgard.cc
Normal file
25
sgard.cc
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
///
|
||||||
|
/// \file sgard.cc
|
||||||
|
/// \author K. Isom <kyle@imap.cc>
|
||||||
|
/// \date 2023-10-17
|
||||||
|
/// \brief Shimmering Clarity Gardener: dot-file management.
|
||||||
|
///
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <scsl/Flag.h>
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
auto flag = new scsl::Flags("sgard", "Shimmering Clarity Gardener: dot-file management");
|
||||||
|
|
||||||
|
auto parseResult = flag->Parse(argc, argv);
|
||||||
|
if (parseResult != scsl::Flags::ParseStatus::OK) {
|
||||||
|
std::cerr << "failed to parse flags: "
|
||||||
|
<< scsl::Flags::ParseStatusToString(parseResult)
|
||||||
|
<< "\n";
|
||||||
|
flag->Usage(std::cerr, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user