Skip to content

Commit

Permalink
Removed target for dummy #2213
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasdille committed Dec 21, 2023
1 parent 23bad25 commit 56b6b3b
Show file tree
Hide file tree
Showing 12 changed files with 328 additions and 17 deletions.
15 changes: 1 addition & 14 deletions make/tool.mk
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ $(ALL_TOOLS_RAW):%: \
$(TOOLS_DIR)/%/manifest.json \
$(TOOLS_DIR)/%/Dockerfile \
builders \
base \
; $(info $(M) Building image $(REGISTRY)/$(REPOSITORY_PREFIX)$*...)
@set -o errexit; \
PUSH=$(or $(PUSH), false); \
Expand Down Expand Up @@ -230,7 +229,7 @@ $(addsuffix --debug,$(ALL_TOOLS_RAW)):%--debug: \
--env version=$${TOOL_VERSION} \
--rm \
$(REGISTRY)/$(REPOSITORY_PREFIX)$*:$${VERSION_TAG} \
bash
bash --login

.PHONY:
$(addsuffix --buildg,$(ALL_TOOLS_RAW)):%--buildg: \
Expand Down Expand Up @@ -272,15 +271,3 @@ $(addsuffix --test,$(ALL_TOOLS_RAW)):%--test: \
.PHONY:
debug: \
debug-$(ALT_ARCH)

.PHONY:
debug-%: \
; $(info $(M) Debugging on platform $*...)
@docker container run \
--interactive \
--tty \
--privileged \
--rm \
--platform linux/$* \
$(REGISTRY)/$(REPOSITORY_PREFIX)base:$(DOCKER_TAG) \
bash
9 changes: 6 additions & 3 deletions tools/dummy/Dockerfile.template
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#syntax=docker/dockerfile:1.6.0

ARG ref=main
FROM nicholasdille/ubuntu:22.04 AS prepare
COPY --from=ghcr.io/uniget-org/tools/uniget-build:latest \
/etc/profile.d/ \
/etc/profile.d/
SHELL [ "bash", "-clo", "errexit" ]

FROM ghcr.io/uniget-org/tools/base:${ref} AS prepare
ARG name
ARG version
RUN <<EOF
touch \
"${prefix}${target}/dummy"
"${prefix}/dummy"
EOF
25 changes: 25 additions & 0 deletions tools/dummy/check-clone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -o errexit

function check-clone() {
local repo="$1"
if test -z "${repo}"; then
echo "Usage: $0 <repo> <ref>"
exit 1
fi
shift

local ref=$1
if test -z "${ref}"; then
echo "Usage: $0 <repo> <ref>"
exit 1
fi

echo "### Checking clone from repo ${repo} with ref ${ref}"
if git ls-remote --exit-code "${repo}" "${ref}"; then
echo " Found :-)"
return
fi
echo " ERROR: Unable to find ref ${ref} in repo ${repo}"
return 1
}
18 changes: 18 additions & 0 deletions tools/dummy/check-download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -o errexit

function check-download() {
local url="$1"
if test -z "${url}"; then
echo "Usage: $0 <url>"
exit 1
fi

echo "### Checking ${url}"
if curl --silent --show-error --location --fail --head --url "${url}"; then
echo " Found :-)"
return
fi
echo " ERROR: Download ${url} not found"
return 1
}
53 changes: 53 additions & 0 deletions tools/dummy/check-github-release-asset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
set -o errexit

function check-github-release-asset() {
local repo="$1"
if test -z "${repo}"; then
echo "Usage: $0 <owner/repo> <version> <asset>"
exit 1
fi
shift

local version=$1
if test -z "${version}"; then
echo "Usage: $0 <owner/repo> <version> <asset>"
exit 1
fi
shift

local asset=$1
if test -z "${asset}"; then
echo "Usage: $0 <owner/repo> <version> <asset>"
exit 1
fi

local url="https://github.com/${repo}/releases/download/${version}/${asset}"
echo "### Checking ${repo} ${version} ${asset}"
if curl --silent --show-error --location --fail --head --url "${url}"; then
echo " Found :-)"
return
fi
echo " ERROR: Asset ${asset} not found for ${repo} ${version}"
echo " at ${url}"

echo "### Fetching release assets for ${repo} ${version}"
local id
local url="https://api.github.com/repos/${repo}/releases/tags/${version}"
id="$(curl --silent --show-error --location "${url}" | jq --raw-output '.id')"
if test -z "${id}" || test "${id}" == "null"; then
echo " ERROR: Failed to fetch release id for ${repo} ${version}"
echo " at ${url}"
return 1
fi
echo " Found release id ${id} for ${repo} ${version}"

echo "### Fetching release assets for ${repo} ${version} with id ${id}"
local url="https://api.github.com/repos/${repo}/releases/${id}/assets"
if ! curl --silent --show-error --location --fail "${url}" | jq --raw-output '.[].name'; then
echo " ERROR: Failed to fetch release assets for ${repo} ${version}"
echo " at ${url}"
return 1
fi
return 1
}
53 changes: 53 additions & 0 deletions tools/dummy/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
set -o errexit

arch="$(uname -m)"
case "${arch}" in
x86_64)
alt_arch=amd64
;;
aarch64)
alt_arch=arm64
;;
*)
echo "ERROR: Unknown architecture ${arch}."
exit 1
;;
esac
export arch
export alt_arch

export uniget_cache=/var/cache/uniget
export uniget_lib=/var/lib/uniget
export uniget_contrib="${uniget_lib}/contrib"
export uniget_manifests="${uniget_lib}/manifests"
export uniget_post_install="${uniget_lib}/post_install"
export prefix=/uniget_bootstrap

mkdir -p \
"${prefix}${uniget_cache}" \
"${prefix}${uniget_contrib}" \
"${prefix}${uniget_manifests}" \
"${prefix}${uniget_post_install}" \
"${prefix}/etc/profile.d" \
"${prefix}/etc/systemd/system" \
"${prefix}/bin" \
"${prefix}/etc" \
"${prefix}/include" \
"${prefix}/lib" \
"${prefix}/libexec/docker/cli-plugins" \
"${prefix}/opt" \
"${prefix}/sbin" \
"${prefix}/var" \
"${prefix}/share/man/man1" \
"${prefix}/share/man/man2" \
"${prefix}/share/man/man3" \
"${prefix}/share/man/man4" \
"${prefix}/share/man/man5" \
"${prefix}/share/man/man6" \
"${prefix}/share/man/man7" \
"${prefix}/share/man/man8" \
"${prefix}/share/man/man9" \
"${prefix}/share/bash-completion/completions" \
"${prefix}/share/fish/vendor_completions.d" \
"${prefix}/share/zsh/vendor-completions"
9 changes: 9 additions & 0 deletions tools/uniget-build/Dockerfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#syntax=docker/dockerfile:1.6.0

FROM nicholasdille/ubuntu:22.04 AS prepare
COPY --chmod=0755 \
init.sh \
check-download.sh \
check-github-release-asset.sh \
check-clone.sh \
/uniget_bootstrap/etc/profile.d/
25 changes: 25 additions & 0 deletions tools/uniget-build/check-clone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -o errexit

function check-clone() {
local repo="$1"
if test -z "${repo}"; then
echo "Usage: $0 <repo> <ref>"
exit 1
fi
shift

local ref=$1
if test -z "${ref}"; then
echo "Usage: $0 <repo> <ref>"
exit 1
fi

echo "### Checking clone from repo ${repo} with ref ${ref}"
if git ls-remote --exit-code "${repo}" "${ref}"; then
echo " Found :-)"
return
fi
echo " ERROR: Unable to find ref ${ref} in repo ${repo}"
return 1
}
18 changes: 18 additions & 0 deletions tools/uniget-build/check-download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -o errexit

function check-download() {
local url="$1"
if test -z "${url}"; then
echo "Usage: $0 <url>"
exit 1
fi

echo "### Checking ${url}"
if curl --silent --show-error --location --fail --head --url "${url}"; then
echo " Found :-)"
return
fi
echo " ERROR: Download ${url} not found"
return 1
}
53 changes: 53 additions & 0 deletions tools/uniget-build/check-github-release-asset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
set -o errexit

function check-github-release-asset() {
local repo="$1"
if test -z "${repo}"; then
echo "Usage: $0 <owner/repo> <version> <asset>"
exit 1
fi
shift

local version=$1
if test -z "${version}"; then
echo "Usage: $0 <owner/repo> <version> <asset>"
exit 1
fi
shift

local asset=$1
if test -z "${asset}"; then
echo "Usage: $0 <owner/repo> <version> <asset>"
exit 1
fi

local url="https://github.com/${repo}/releases/download/${version}/${asset}"
echo "### Checking ${repo} ${version} ${asset}"
if curl --silent --show-error --location --fail --head --url "${url}"; then
echo " Found :-)"
return
fi
echo " ERROR: Asset ${asset} not found for ${repo} ${version}"
echo " at ${url}"

echo "### Fetching release assets for ${repo} ${version}"
local id
local url="https://api.github.com/repos/${repo}/releases/tags/${version}"
id="$(curl --silent --show-error --location "${url}" | jq --raw-output '.id')"
if test -z "${id}" || test "${id}" == "null"; then
echo " ERROR: Failed to fetch release id for ${repo} ${version}"
echo " at ${url}"
return 1
fi
echo " Found release id ${id} for ${repo} ${version}"

echo "### Fetching release assets for ${repo} ${version} with id ${id}"
local url="https://api.github.com/repos/${repo}/releases/${id}/assets"
if ! curl --silent --show-error --location --fail "${url}" | jq --raw-output '.[].name'; then
echo " ERROR: Failed to fetch release assets for ${repo} ${version}"
echo " at ${url}"
return 1
fi
return 1
}
53 changes: 53 additions & 0 deletions tools/uniget-build/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
set -o errexit

arch="$(uname -m)"
case "${arch}" in
x86_64)
alt_arch=amd64
;;
aarch64)
alt_arch=arm64
;;
*)
echo "ERROR: Unknown architecture ${arch}."
exit 1
;;
esac
export arch
export alt_arch

export uniget_cache=/var/cache/uniget
export uniget_lib=/var/lib/uniget
export uniget_contrib="${uniget_lib}/contrib"
export uniget_manifests="${uniget_lib}/manifests"
export uniget_post_install="${uniget_lib}/post_install"
export prefix=/uniget_bootstrap

mkdir -p \
"${prefix}${uniget_cache}" \
"${prefix}${uniget_contrib}" \
"${prefix}${uniget_manifests}" \
"${prefix}${uniget_post_install}" \
"${prefix}/etc/profile.d" \
"${prefix}/etc/systemd/system" \
"${prefix}/bin" \
"${prefix}/etc" \
"${prefix}/include" \
"${prefix}/lib" \
"${prefix}/libexec/docker/cli-plugins" \
"${prefix}/opt" \
"${prefix}/sbin" \
"${prefix}/var" \
"${prefix}/share/man/man1" \
"${prefix}/share/man/man2" \
"${prefix}/share/man/man3" \
"${prefix}/share/man/man4" \
"${prefix}/share/man/man5" \
"${prefix}/share/man/man6" \
"${prefix}/share/man/man7" \
"${prefix}/share/man/man8" \
"${prefix}/share/man/man9" \
"${prefix}/share/bash-completion/completions" \
"${prefix}/share/fish/vendor_completions.d" \
"${prefix}/share/zsh/vendor-completions"
14 changes: 14 additions & 0 deletions tools/uniget-build/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# yaml-language-server: $schema=https://tools.uniget.dev/schema.yaml
$schema: https://tools.uniget.dev/schema.yaml
name: uniget-build
version: "0.0.1"
binary: "false"
check: "" # No version check possible
platforms:
- linux/amd64
- linux/arm64
tags:
- org/uniget
- category/development
homepage: https://github.com/uniget-org/tools
description: Defaults and helpers for building uniget tools

0 comments on commit 56b6b3b

Please sign in to comment.