From 84bf2bc8740e69de640d08d71c98b24321847a74 Mon Sep 17 00:00:00 2001 From: hastmu Date: Wed, 6 Nov 2024 00:14:18 +0100 Subject: [PATCH] first items for repo build --- .include.build.deb.sh | 58 +++++++++++++++++++++++++++++++++++++++ deploy-deb.sh | 64 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 .include.build.deb.sh create mode 100755 deploy-deb.sh diff --git a/.include.build.deb.sh b/.include.build.deb.sh new file mode 100644 index 0000000..4d6d4be --- /dev/null +++ b/.include.build.deb.sh @@ -0,0 +1,58 @@ + +declare -A DEBIAN + +DEBIAN["Package"]="apt-proxy-detect" +DEBIAN["Version"]="${branch_type}-${branch_tag}-${branch}" +DEBIAN["Section"]="base" +DEBIAN["Priority"]="optional" +DEBIAN["Architecture"]="all" +DEBIAN["Depends"]="coreutils, grep, sed, wget, avahi-utils" +DEBIAN["Conflict"]="squid-deb-proxy-client" +DEBIAN["Maintainer"]="nomail@nomail.no" +DEBIAN["Description"]="apt proxy detection" + +function gen_control_file() { + + local item="" + for item in ${!DEBIAN[@]} + do + echo "${item}: ${DEBIAN[${item}]}" + done + +} + +function gen_rootfs() { + + # create dirs + mkdir "${DPKG_BUILD_ROOT}/usr/local/bin" + mkdir "${DPKG_BUILD_ROOT}/etc/apt/apt.conf.d" + + # copy files + cp -av apt-proxy-detect.sh "${DPKG_BUILD_ROOT}/usr/local/bin/." + + # create files + echo "Acquire::http::ProxyAutoDetect \""/usr/local/bin/apt-proxy-detect.sh"\";" > "${DPKG_BUILD_ROOT}/etc/apt/apt.conf.d/30apt-proxy-detect.conf" + echo "Acquire::https::ProxyAutoDetect \""/usr/local/bin/apt-proxy-detect.sh"\";" >> "${DPKG_BUILD_ROOT}/etc/apt/apt.conf.d/30apt-proxy-detect.conf" + + # set permissions + chmod -R a+rx "${DPKG_BUILD_ROOT}" + chmod -R a-x "${DPKG_BUILD_ROOT}/etc/apt/apt.conf.d/30apt-proxy-detect.conf" + +} + + + +if [ 1 -eq 0 ] +then + # defaults + + DPKG_NAME="${NAME}_${VERSION}_${BRANCH//\//-}_${HEADHASH}.deb" + if dpkg -b "${T_DIR}" "${DPKG_NAME}" + then + apt-cache show "$(pwd)/${DPKG_NAME}" + apt-get install --allow-downgrades -y "$(pwd)/${DPKG_NAME}" + rm -fv "$(pwd)/${DPKG_NAME}" + dpkg -l "${NAME}" + fi + +fi \ No newline at end of file diff --git a/deploy-deb.sh b/deploy-deb.sh new file mode 100755 index 0000000..1a7c3e1 --- /dev/null +++ b/deploy-deb.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +echo "- deploying..." + +( + cd "$(dirname "$0")" + pwd +# git branch -r -v + GIT_CLONE_URL=$(git ls-remote --get-url origin) + + # tag to hash + declare -A tag_hash + for tag in $(git tag) + do + tag_hash[$(git rev-list -n 1 ${tag})]="${tag}" + done + declare -p tag_hash + + T_DIR=$(mktemp -d) + trap 'rm -Rf ${T_DIR}' EXIT + mkdir "${T_DIR}/.dpkg-root" + ( cd ${T_DIR} ; git clone ${GIT_CLONE_URL} ) + + + for branch in $(git branch -r | awk '{ print $1 }') + do + branch_type="feature" + branch_hash="$(git rev-parse ${branch})" + if [[ ${branch} =~ origin/main ]] + then + # unstable + #echo "unstable: ${branch}" + branch_type="unstable" + elif [[ ${branch} =~ origin/release/ ]] + then + # stable + #echo "stable: ${branch}" + branch_type="stable" + else + # feature + : #echo "feature: ${branch}" + continue + fi + + branch_tag=${tag_hash[${branch_hash}]:="none"} + echo "${branch_type} - ${branch_hash} - ${branch} - TAG[${branch_tag}]" + + DPKG_BUILD_ROOT="${T_DIR}/.dpkg-root/${branch_hash}" + mkdir -p "${DPKG_BUILD_ROOT}" + + ( + cd ${T_DIR}/* ; git checkout "${branch_hash}" + if [ -r ".include.build.deb.sh" ] + then + echo "- sourcing build..." + source ".include.build.deb.sh" + find "${DPKG_BUILD_ROOT}" + fi + ) + + done + +) +