commit 520f161fa9eeb4a3ab2ff15eb90b148cb91ea0ef Author: Gardouille Date: Mon Aug 7 18:16:38 2023 +0200 Init repo diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f7896d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..74f2320 --- /dev/null +++ b/LICENSE @@ -0,0 +1,5 @@ +Copyright 2023-2023 Gardouille + +DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + + http://www.wtfpl.net/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..21533f4 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# exa-docker-build + +This repository contains the source to build [Exa](https://github.com/ogham/exa). + +## Usage Docker + +If you have [Docker](https://www.docker.com/) installed locally, just run the following: + +```bash +user@hostname$ ./build-in-container.sh +``` + +By default this will build the last version on Debian Bookworm and put the +archive to `target/` directory. + +## Build on current host + +```bash +user@hostname$ ./build.sh +``` diff --git a/build-in-container.sh b/build-in-container.sh new file mode 100755 index 0000000..4406ed5 --- /dev/null +++ b/build-in-container.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -eu + +TARGET="$(dirname "$0" | xargs realpath)" +IMAGE="debian:bookworm" + +while getopts "v:i:h" opt +do + case "$opt" in + i) + IMAGE="$OPTARG" + ;; + h) + echo "Usage: $0 [-i image]" + exit 0 + ;; + *) + exit 1 + ;; + esac +done + +docker run --rm \ + --name exa-build-$$ \ + -v "$TARGET:/target" \ + -w /target \ + --user root \ + "$IMAGE" \ + sh build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..6a9b6f0 --- /dev/null +++ b/build.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +set -xeu + +DEBIAN_FRONTEND=noninteractive +TARGET="$PWD" + +export DEBIAN_FRONTEND + +dependencies() { + # Update system and install basic tools + apt-get update -yq && apt-get install -yq aptitude curl git wget + # Install dependencies for Exa + aptitude --quiet --assume-yes install gcc libgit2-dev +} + +install_rust() { + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-host x86_64-unknown-linux-gnu --default-toolchain nightly + . ~/.cargo/env +} + +get_exa_sources() { + # Clone Exa repo + cd "$(mktemp -d)" + git clone https://github.com/ogham/exa + cd exa +} + +build_exa() { + # Build + cargo build --release + + # Test + cargo test + + # Move to previous directory + #cd - +} + +copy() { + TARGET_UID="$(stat --printf %u "$TARGET")" + TARGET_GID="$(stat --printf %g "$TARGET")" + install -o "$TARGET_UID" -g "$TARGET_GID" -t "$TARGET/target" target/release/exa +} + +main() { + dependencies + install_rust + get_exa_sources + build_exa + copy +} + +main diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..2e840cc --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +set -xeu + +DEBIAN_FRONTEND=noninteractive +TARGET="$PWD" + +export DEBIAN_FRONTEND + +dependencies() { + # Update system and install basic tools + apt-get update -yq && apt-get install -yq aptitude curl git wget + # Install dependencies for Exa + aptitude --quiet --assume-yes install gcc libgit2-dev +} + +install_rust() { + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-host x86_64-unknown-linux-gnu --default-toolchain nightly + . ~/.cargo/env +} + +get_exa_sources() { + # Clone Exa repo + cd "$(mktemp -d)" + git clone https://github.com/ogham/exa + cd exa +} + +build_exa() { + ## Build + cargo build --release + + # Test + cargo test + + ## Move to previous directory + cd - +} + +copy() { + TARGET_UID="$(stat --printf %u "$TARGET")" + TARGET_GID="$(stat --printf %g "$TARGET")" + install -o "$TARGET_UID" -g "$TARGET_GID" -t "$TARGET/target" /*.tar.gz +} + +main() { + dependencies + install_rust + get_exa_sources + build_exa + copy +} + +main