-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial commit of building sandbox package
- Loading branch information
1 parent
c8db400
commit 70fa933
Showing
22 changed files
with
579 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": [ | ||
"config:base", | ||
":semanticCommitTypeAll(chore)" | ||
], | ||
"lockFileMaintenance": { | ||
"enabled": true, | ||
"extends": [ | ||
"schedule:weekly" | ||
] | ||
}, | ||
"nix": { | ||
"enabled": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: vorpal-sandbox | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.runner }} | ||
strategy: | ||
matrix: | ||
runner: | ||
- macos-latest | ||
- ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- if: matrix.runner != 'macos-latest' | ||
run: ./script/debian.sh "sandbox" | ||
|
||
- run: make dist | ||
|
||
- run: | | ||
echo "ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | ||
echo "OS=$(uname -s | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | ||
echo "SANDBOX_HASH=$(cat "${PWD}/script/sandbox.sha256sum")" >> $GITHUB_ENV | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: vorpal-sandbox-${{ env.ARCH }}-${{ env.OS }} | ||
path: dist/vorpal-sandbox-${{ env.SANDBOX_HASH }}.package.tar.zst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.env | ||
.vagrant | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Vagrant.configure("2") do |config| | ||
config.ssh.password = "vagrant" | ||
|
||
config.vm.box = "altf4llc/debian-bookworm" | ||
|
||
# Speed is important here as a lot of compiling is done in the vm | ||
# Be sure to set a high enough value for your system | ||
config.vm.provider :vmware_desktop do |vmware| | ||
vmware.vmx["memsize"] = "8192" | ||
vmware.vmx["numvcpus"] = "8" | ||
end | ||
|
||
config.vm.provision "shell", keep_color: true, privileged: false, inline: <<-SHELL | ||
echo 'function sync_sandbox { | ||
pushd "${HOME}" | ||
mkdir -p ./vorpal-sandbox | ||
rsync -aPW \ | ||
--exclude=".env" \ | ||
--exclude=".git" \ | ||
--exclude=".vagrant" \ | ||
--exclude="dist" \ | ||
--exclude="packer_debian_vmware_arm64.box" \ | ||
/vagrant/. ./vorpal-sandbox/. | ||
popd | ||
}' >> ~/.bashrc | ||
echo 'function build_sandbox { | ||
sync_sandbox | ||
pushd "${HOME}/vorpal-sandbox" | ||
./script/debian.sh | ||
make dist | ||
popd | ||
}' >> ~/.bashrc | ||
SHELL | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
PACKAGE_HASH := $(shell cat "${PWD}/script/sandbox.sha256sum") | ||
PACKAGE_NAME := vorpal-sandbox-$(PACKAGE_HASH).package | ||
PACKAGE_PATH := /var/lib/vorpal/store/$(PACKAGE_NAME) | ||
|
||
build: clean | ||
"${PWD}/script/sandbox.sh" | ||
|
||
clean: | ||
rm -rf $(PACKAGE_PATH) | ||
rm -rf $(PACKAGE_PATH).tar.zst | ||
rm -rf "${PWD}/dist" | ||
|
||
dist: build | ||
mkdir -p "${PWD}/dist" | ||
tar -cvf - -C "$(PACKAGE_PATH)" "${PWD}" | zstd -o "$(PACKAGE_PATH).tar.zst" | ||
cp $(PACKAGE_PATH).tar.zst "${PWD}/dist/." | ||
|
||
list: | ||
@grep '^[^#[:space:]].*:' Makefile | ||
|
||
test-vagrant: | ||
vagrant destroy --force || true | ||
vagrant up --provider "vmware_desktop" | ||
|
||
update-sha256sum: | ||
"${PWD}/script/hash_path.sh" "${PWD}" > "${PWD}/script/sandbox.sha256sum" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
ARCH="$(uname -m | tr '[:upper:]' '[:lower:]')" | ||
CPU_COUNT="" | ||
OS=$(uname -s | tr '[:upper:]' '[:lower:]') | ||
VERSION="5.2" | ||
|
||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <sandbox-package-path>" | ||
exit 1 | ||
fi | ||
|
||
if [[ -f "${1}/bin/bash" ]]; then | ||
"${1}/bin/bash" --version | head -n 1 | ||
exit 0 | ||
fi | ||
|
||
if [[ "${ARCH}" == "arm64" ]]; then | ||
ARCH="aarch64" | ||
fi | ||
|
||
if [[ "${OS}" == "linux" ]]; then | ||
CPU_COUNT="-j$(nproc)" | ||
fi | ||
|
||
curl -L \ | ||
"https://ftp.gnu.org/gnu/bash/bash-${VERSION}.tar.gz" \ | ||
-o "/tmp/bash-${VERSION}.tar.gz" | ||
|
||
tar -xvzf "/tmp/bash-${VERSION}.tar.gz" -C "/tmp" | ||
|
||
pushd "/tmp/bash-${VERSION}" | ||
|
||
./configure --prefix="${1}" | ||
|
||
make ${CPU_COUNT} | ||
|
||
make install | ||
|
||
popd | ||
|
||
rm -rf "/tmp/bash-${VERSION}" | ||
|
||
rm -rf "/tmp/bash-${VERSION}.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
ARCH="$(uname -m | tr '[:upper:]' '[:lower:]')" | ||
CPU_COUNT="" | ||
OS=$(uname -s | tr '[:upper:]' '[:lower:]') | ||
VERSION="9.5" | ||
|
||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <sandbox-package-path>" | ||
exit 1 | ||
fi | ||
|
||
if [[ -f "${1}/bin/cat" ]]; then | ||
"${1}/bin/cat" --version | head -n 1 | ||
exit 0 | ||
fi | ||
|
||
if [[ "${ARCH}" == "arm64" ]]; then | ||
ARCH="aarch64" | ||
fi | ||
|
||
if [[ "${OS}" == "linux" ]]; then | ||
CPU_COUNT="-j$(nproc)" | ||
fi | ||
|
||
curl -L \ | ||
"https://ftp.gnu.org/gnu/coreutils/coreutils-${VERSION}.tar.gz" \ | ||
-o "/tmp/coreutils-${VERSION}.tar.gz" | ||
|
||
tar -xzf "/tmp/coreutils-${VERSION}.tar.gz" -C "/tmp" | ||
|
||
pushd "/tmp/coreutils-${VERSION}" | ||
|
||
./configure --prefix="${1}" | ||
|
||
make ${CPU_COUNT} | ||
|
||
make install | ||
|
||
popd | ||
|
||
rm -rf "/tmp/coreutils-${VERSION}" | ||
|
||
rm -rf "/tmp/coreutils-${VERSION}.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
ARCH="$(uname -m | tr '[:upper:]' '[:lower:]')" | ||
CPU_COUNT="" | ||
OS=$(uname -s | tr '[:upper:]' '[:lower:]') | ||
VERSION="1.5.5" | ||
|
||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <sandbox-package-path>" | ||
exit 1 | ||
fi | ||
|
||
if [[ -f "${1}/bin/zstd" ]]; then | ||
"${1}/bin/zstd" --version | ||
exit 0 | ||
fi | ||
|
||
if [[ "${ARCH}" == "arm64" ]]; then | ||
ARCH="aarch64" | ||
fi | ||
|
||
if [[ "${OS}" == "linux" ]]; then | ||
CPU_COUNT="-j$(nproc)" | ||
fi | ||
|
||
curl -L \ | ||
"https://github.com/facebook/zstd/releases/download/v${VERSION}/zstd-${VERSION}.tar.gz" \ | ||
-o "/tmp/zstd-${VERSION}.tar.gz" | ||
|
||
tar -xzf "/tmp/zstd-${VERSION}.tar.gz" -C "/tmp" | ||
|
||
pushd "/tmp/zstd-${VERSION}" | ||
|
||
make ${CPU_COUNT} | ||
|
||
make install PREFIX="${1}" | ||
|
||
popd | ||
|
||
rm -rf "/tmp/zstd-${VERSION}" | ||
|
||
rm -rf "/tmp/zstd-${VERSION}.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../common/bash.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../common/coreutils.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../common/zstd.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
sudo apt-get update | ||
|
||
sudo apt-get install \ | ||
--no-install-recommends \ | ||
--yes \ | ||
autoconf \ | ||
automake \ | ||
bison \ | ||
build-essential \ | ||
coreutils \ | ||
flex \ | ||
gawk \ | ||
gperf \ | ||
m4 \ | ||
perl \ | ||
texinfo \ | ||
zstd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
export LC_ALL=C | ||
|
||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <path>" | ||
exit 1 | ||
fi | ||
|
||
SYSTEM_PATH="$(realpath "${1}")" | ||
|
||
if [[ ! -e "$SYSTEM_PATH" ]]; then | ||
echo "The file or directory does not exist." | ||
exit 1 | ||
fi | ||
|
||
files=$(find "$SYSTEM_PATH" -type f | sort -n) | ||
hashes="" | ||
ignore_paths=( | ||
"${SYSTEM_PATH}/.git" | ||
"${SYSTEM_PATH}/script/sandbox.sha256sum" | ||
) | ||
|
||
is_ignored() { | ||
local file_path="$1" | ||
|
||
for ignore in "${ignore_paths[@]}"; do | ||
if [[ "$file_path" == *"$ignore"* ]]; then | ||
return 0 | ||
fi | ||
done | ||
|
||
if [ -f "$SYSTEM_PATH/.gitignore" ]; then | ||
while IFS= read -r pattern; do | ||
[[ -z "$pattern" || "$pattern" == \#* ]] && continue | ||
|
||
regex=$(echo "$pattern" | sed 's/\./\\./g; s/\*/.*/g; s/\?/./g') | ||
|
||
if [[ "$file_path" =~ $regex ]]; then | ||
return 0 | ||
fi | ||
done < "$SYSTEM_PATH/.gitignore" | ||
fi | ||
|
||
return 1 | ||
} | ||
|
||
while IFS= read -r file; do | ||
if ! is_ignored "$file"; then | ||
hash=$(shasum -a 256 "$file" | awk '{print $1}') | ||
hashes="${hashes}${hash}" | ||
fi | ||
done <<< "$files" | ||
|
||
echo -n "$hashes" | shasum -a 256 | awk '{print $1}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../common/bash.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
|
||
ARCH="$(uname -m | tr '[:upper:]' '[:lower:]')" | ||
CPU_COUNT="" | ||
OS=$(uname -s | tr '[:upper:]' '[:lower:]') | ||
VERSION="2.43.1" | ||
|
||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <sandbox-package-path>" | ||
exit 1 | ||
fi | ||
|
||
if [[ "${ARCH}" == "arm64" ]]; then | ||
ARCH="aarch64" | ||
fi | ||
|
||
if [[ "${OS}" == "linux" ]]; then | ||
CPU_COUNT="-j$(nproc)" | ||
fi | ||
|
||
curl -L \ | ||
"https://ftp.gnu.org/gnu/binutils/binutils-${VERSION}.tar.gz" \ | ||
-o "/tmp/binutils-${VERSION}.tar.gz" | ||
|
||
tar -xvzf "/tmp/binutils-${VERSION}.tar.gz" -C "/tmp" | ||
|
||
pushd "/tmp/binutils-${VERSION}" | ||
|
||
mkdir -p ./build | ||
|
||
popd | ||
|
||
pushd "/tmp/binutils-${VERSION}/build" | ||
|
||
../configure --prefix="${1}" | ||
make ${CPU_COUNT} | ||
make install | ||
|
||
popd | ||
|
||
rm -rf "/tmp/binutils-${VERSION}" | ||
|
||
rm -rf "/tmp/binutils-${VERSION}.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../common/coreutils.sh |
Oops, something went wrong.