Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c51f0da8e5 | ||
![]() |
6d400e3751 | ||
![]() |
d9a082bc3f | ||
![]() |
fba807a958 |
@ -4,11 +4,11 @@
|
||||
|
||||
Automated system-wide installation:
|
||||
```
|
||||
curl -fsSL https://gitea.jde.nz/public/dehydrate/releases/download/latest/install.sh | bash
|
||||
curl -fsSL https://gitea.jde.nz/public/dehydrate/releases/download/latest/install.sh | sudo bash
|
||||
```
|
||||
To download just the dehydrate executable:
|
||||
```
|
||||
curl -fsSL -o dehydrate https://gitea.jde.nz/public/dehydrate/releases/download/latest/dehydrate.amd64 && chmod a+x bb64
|
||||
curl -fsSL -o dehydrate https://gitea.jde.nz/public/dehydrate/releases/download/latest/dehydrate.amd64 && chmod a+x dehydrate
|
||||
```
|
||||
|
||||
## How it Works
|
||||
|
@ -1 +1 @@
|
||||
static const char *VERSION = "8";
|
||||
static const char *VERSION = "11";
|
||||
|
36
install.sh
36
install.sh
@ -3,24 +3,23 @@ set -e
|
||||
|
||||
PROJECT="dehydrate"
|
||||
|
||||
# RUN AS ROOT
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 0. see if we were passed a folder to install to
|
||||
# -----------------------------------------------------------------------------
|
||||
INSTALL_DIR="$1"
|
||||
if [[ -z "$INSTALL_DIR" ]]; then
|
||||
INSTALL_DIR="/usr/local/bin"
|
||||
else
|
||||
echo "Installing $PROJECT to $INSTALL_DIR"
|
||||
if [[ ! -d "$INSTALL_DIR" ]]; then
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
# 0. see if we were passed a user to chown to
|
||||
# -----------------------------------------------------------------------------
|
||||
CHOWN_USER="$2"
|
||||
if [[ -z "$CHOWN_USER" ]]; then
|
||||
CHOWN_USER=$(id -u)
|
||||
fi
|
||||
echo "Installing $PROJECT to $INSTALL_DIR"
|
||||
|
||||
# 1. Determine architecture
|
||||
# -----------------------------------------------------------------------------
|
||||
@ -35,27 +34,18 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 3. Download the appropriate binary to a temp directory
|
||||
# 3. Download the appropriate binary
|
||||
# -----------------------------------------------------------------------------
|
||||
TMPDIR=$(mktemp -d)
|
||||
trap 'rm -rf "$TMPDIR"' EXIT
|
||||
URL="https://gitea.jde.nz/public/$PROJECT/releases/download/latest/$BIN"
|
||||
echo "Downloading $BIN from $URL..."
|
||||
|
||||
curl -fsSL -o "$TMPDIR/$PROJECT" "$URL"
|
||||
URL="https://gitea.jde.nz/public/$PROJECT/releases/download/latest/$BIN"
|
||||
echo "Downloading $BIN from $URL to $TMPDIR..."
|
||||
|
||||
curl -fsSL -o "$INSTALL_DIR/$PROJECT" "$URL"
|
||||
|
||||
# 4. Make it executable
|
||||
# -----------------------------------------------------------------------------
|
||||
chmod +x "$TMPDIR/$PROJECT"
|
||||
|
||||
# 5. Move to /usr/local/bin
|
||||
# -----------------------------------------------------------------------------
|
||||
docker run --rm -v "$TMPDIR:/tmp" -v "$INSTALL_DIR:/target" alpine sh -c "cp /tmp/$PROJECT /target/$PROJECT; chown $CHOWN_USER /target/$PROJECT"
|
||||
rm "$TMPDIR/$PROJECT"
|
||||
chmod +x "$INSTALL_DIR/$PROJECT"
|
||||
|
||||
# 6. Print success message
|
||||
# -----------------------------------------------------------------------------
|
||||
echo "$PROJECT installed successfully to $INSTALL_DIR/$PROJECT (arch $ARCH)"
|
||||
echo " "
|
||||
echo "Update $PROJECT in future with:"
|
||||
echo " $PROJECT -u"
|
||||
|
@ -110,7 +110,7 @@ static bool _recreate_file_(const std::filesystem::path& outpath, uint64_t file_
|
||||
|
||||
if (needs_write) {
|
||||
bool existed = fs::exists(outpath);
|
||||
|
||||
|
||||
fs::create_directories(outpath.parent_path());
|
||||
std::ofstream out(outpath, std::ios::binary);
|
||||
out.write(reinterpret_cast<const char*>(filedata), filedata_len);
|
||||
@ -145,6 +145,7 @@ void generate_file_code(const std::string& source, const std::string& destfolder
|
||||
std::string ns = "recreate_" + sanitize(src.stem().string());
|
||||
std::string cppname = "_" + src.stem().string() + ".cpp";
|
||||
std::string hppname = "_" + src.stem().string() + ".hpp";
|
||||
std::string bothname = "_" + src.stem().string() + ".{cpp,hpp}";
|
||||
fs::create_directories(dest);
|
||||
std::ifstream in(source, std::ios::binary);
|
||||
std::ostringstream oss;
|
||||
@ -221,7 +222,7 @@ bool recreate_file(std::string destination_folder) {
|
||||
cpp << "}\n";
|
||||
|
||||
if (!silent) {
|
||||
std::cout << "[dehydrate] Generated: " << (dest / cppname) << ", " << (dest / hppname) << std::endl;
|
||||
std::cout << "[dehydrate] Generated: " << (dest / bothname) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,6 +241,7 @@ void generate_folder_code(const std::string& source, const std::string& destfold
|
||||
std::string ns = "recreate_" + sanitize(src.stem().string());
|
||||
std::string cppname = "_" + src.stem().string() + ".cpp";
|
||||
std::string hppname = "_" + src.stem().string() + ".hpp";
|
||||
std::string bothname = "_" + src.stem().string() + ".{cpp,hpp}";
|
||||
fs::create_directories(dest);
|
||||
// Collect all files
|
||||
std::vector<fs::path> files;
|
||||
@ -365,6 +367,6 @@ bool recreate_tree(std::string destination_folder) {
|
||||
cpp << "}\n";
|
||||
|
||||
if (!silent) {
|
||||
std::cout << "[dehydrate] Generated: " << (dest / cppname) << ", " << (dest / hppname) << std::endl;
|
||||
std::cout << "[dehydrate] Generated: " << (dest / bothname) << std::endl;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user