-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hastmu
committed
Nov 5, 2024
1 parent
6d761bf
commit 84bf2bc
Showing
2 changed files
with
122 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,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 |
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,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 | ||
|
||
) | ||
|