You've already forked Reprepro-Wrapper
Inital Commit
This commit is contained in:
46
root/usr/lib/reprepro/import
Normal file
46
root/usr/lib/reprepro/import
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
|
||||
###
|
||||
#
|
||||
# Options Section
|
||||
#
|
||||
###
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
|
||||
###
|
||||
#
|
||||
# Variable Section
|
||||
#
|
||||
###
|
||||
|
||||
OUTDIR=$(/usr/bin/grep 'outdir' '/etc/reprepro/options' | /usr/bin/sed --expression='s/outdir //')
|
||||
|
||||
|
||||
###
|
||||
#
|
||||
# Runtime Environment
|
||||
#
|
||||
###
|
||||
|
||||
if [[ ! -d "${OUTDIR}" ]]; then
|
||||
/usr/bin/install --directory --group='nogroup' --owner='nobody' "${OUTDIR}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for DEBINFO in "${OUTDIR}/import"/*.rep; do
|
||||
source "${DEBINFO}"
|
||||
if [[ -f "${OUTDIR}/pool/${COMPONENT}/${DEB:0:1}/${PACKAGE}/${DEB}" ]]; then
|
||||
for VERSION_CODENAME in ${CODENAME}; do
|
||||
/usr/bin/reprepro --confdir '/etc/reprepro' --silent --component "${COMPONENT}" remove "${VERSION_CODENAME}" "${PACKAGE}" &> '/dev/null'
|
||||
done
|
||||
fi
|
||||
for VERSION_CODENAME in ${CODENAME}; do
|
||||
/usr/bin/reprepro --confdir '/etc/reprepro' --silent --component "${COMPONENT}" includedeb "${VERSION_CODENAME}" "${OUTDIR}/import/${DEB}" &> '/dev/null'
|
||||
done
|
||||
/usr/bin/rm --force "${OUTDIR}/import/${DEB}"
|
||||
/usr/bin/rm --force "${DEBINFO}"
|
||||
done
|
||||
35
root/usr/lib/reprepro/morgue
Normal file
35
root/usr/lib/reprepro/morgue
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
|
||||
###
|
||||
#
|
||||
# Options Section
|
||||
#
|
||||
###
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
|
||||
###
|
||||
#
|
||||
# Variable Section
|
||||
#
|
||||
###
|
||||
|
||||
OUTDIR=$(/usr/bin/grep 'outdir' '/etc/reprepro/options' | /usr/bin/sed --expression='s/outdir //')
|
||||
MORGUE="${OUTDIR}/morgue"
|
||||
|
||||
|
||||
###
|
||||
#
|
||||
# Runtime Environment
|
||||
#
|
||||
###
|
||||
|
||||
if [[ ! -d "${MORGUE}" ]]; then
|
||||
/usr/bin/install --directory "${MORGUE}"
|
||||
exit 0
|
||||
fi
|
||||
/usr/bin/rm --force --recursive "${MORGUE}"/*
|
||||
exit 0
|
||||
253
root/usr/sbin/repository
Normal file
253
root/usr/sbin/repository
Normal file
@@ -0,0 +1,253 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
###
|
||||
#
|
||||
# Options Section
|
||||
#
|
||||
###
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
|
||||
###
|
||||
#
|
||||
# Function Section
|
||||
#
|
||||
###
|
||||
|
||||
function import_pve () {
|
||||
local ARCHITECTURE
|
||||
local VERSION_CODENAME
|
||||
local COMPONENT
|
||||
local TEMP
|
||||
local REPOSITORY
|
||||
local DEBS
|
||||
local DEBSVERSIONS
|
||||
local DEB
|
||||
local BASENAME
|
||||
local PKGNAME
|
||||
|
||||
ARCHITECTURE="${1}"
|
||||
VERSION_CODENAME="${2}"
|
||||
COMPONENT="${3}"
|
||||
TEMP=$(/usr/bin/mktemp --directory --quiet)
|
||||
REPOSITORY="https://download.lierfang.com/pxcloud/pxvirt/dists/${VERSION_CODENAME}/${COMPONENT}/binary-${ARCHITECTURE}/"
|
||||
case "${COMPONENT}" in
|
||||
main)
|
||||
case "${VERSION_CODENAME}" in
|
||||
bookworm)
|
||||
COMPONENT='bookworm-pve'
|
||||
;;
|
||||
trixie)
|
||||
COMPONENT='trixie-pve'
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
ceph*)
|
||||
case "${VERSION_CODENAME}" in
|
||||
bookworm)
|
||||
COMPONENT='bookworm-ceph'
|
||||
;;
|
||||
trixie)
|
||||
COMPONENT='trixie-ceph'
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
/usr/bin/wget --quiet --output-document="${TEMP}/repository.html" "${REPOSITORY}"
|
||||
HTML=$(/usr/bin/grep --perl-regexp --only-matching 'href="\K[^"]*(amd64|arm64|all)[^"]*\.deb' "${TEMP}/repository.html")
|
||||
/usr/bin/sleep '3s'
|
||||
declare -A DEBS
|
||||
declare -A VERSIONS
|
||||
for DEB in ${HTML}; do
|
||||
NAME=$(/bin/echo "${DEB}" | /usr/bin/sed -E 's/(_[0-9].*)//')
|
||||
VERSION="${DEB#*_}"
|
||||
VERSION="${VERSION%_*.deb}"
|
||||
if [[ -z "${VERSIONS[$NAME]}" ]] || \
|
||||
/usr/bin/dpkg --compare-versions "$VERSION" gt "${VERSIONS[$NAME]}" 2>/dev/null; then
|
||||
DEBS[$NAME]="$DEB"
|
||||
VERSIONS[$NAME]="$VERSION"
|
||||
fi
|
||||
done
|
||||
for DEB in "${DEBS[@]}"; do
|
||||
PKGNAME="${DEB%%_*}"
|
||||
VERSION_A="${DEB#*_}"
|
||||
VERSION_A="${VERSION_A%_*.deb}"
|
||||
VERSION_B=$(/usr/bin/reprepro --confdir '/etc/reprepro' --silent --component "${COMPONENT}" list "${VERSION_CODENAME}" "${PKGNAME}" | /usr/bin/mawk '{print $NF}' | /usr/bin/head --lines='1')
|
||||
if /usr/bin/dpkg --compare-versions "$VERSION_A" gt "${VERSION_B}" 2>/dev/null; then
|
||||
/usr/bin/echo '# --- --- --- --- --- #'
|
||||
/usr/bin/echo "Download (lierfang/pxvirt): ${DEB}"
|
||||
/usr/bin/wget --quiet --output-document="${TEMP}/${DEB}" "${REPOSITORY}${DEB}"
|
||||
/usr/bin/echo "Repository (${VERSION_CODENAME}/${COMPONENT}): ${PKGNAME}"
|
||||
/usr/bin/reprepro --confdir '/etc/reprepro' --silent --component "${COMPONENT}" includedeb "${VERSION_CODENAME}" "${TEMP}/${DEB}" &> '/dev/null'
|
||||
/usr/bin/rm --force "${TEMP}/${DEB}"
|
||||
fi
|
||||
done
|
||||
/bin/rm --force --recursive "${TEMP}"
|
||||
}
|
||||
|
||||
function import_pbs () {
|
||||
local VERSION_CODENAME
|
||||
local TEMP
|
||||
local REPOSITORY
|
||||
local URLS
|
||||
local URL
|
||||
local DEB
|
||||
local PKGNAME
|
||||
|
||||
VERSION_CODENAME="${1}"
|
||||
TEMP=$(/usr/bin/mktemp --directory --quiet)
|
||||
case "${VERSION_CODENAME}" in
|
||||
bookworm)
|
||||
REPOSITORY="https://api.github.com/repos/wofferl/proxmox-backup-arm64/releases/tags/3.4.6-1"
|
||||
COMPONENT='bookworm-pbs'
|
||||
;;
|
||||
trixie)
|
||||
REPOSITORY="https://api.github.com/repos/wofferl/proxmox-backup-arm64/releases/latest"
|
||||
COMPONENT='trixie-pbs'
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
/usr/bin/wget --quiet --output-document="${TEMP}/gitapi.json" "${REPOSITORY}"
|
||||
URLS=$(/usr/bin/grep 'browser_download_url' "${TEMP}/gitapi.json" | /usr/bin/cut --delimiter='"' --fields='4')
|
||||
for URL in ${URLS}; do
|
||||
DEB=$(/usr/bin/basename "${URL}")
|
||||
PKGNAME=$(/usr/bin/basename "${URL%%_*}")
|
||||
VERSION_A="${DEB#*_}"
|
||||
VERSION_A="${VERSION_A%_*.deb}"
|
||||
VERSION_B=$(/usr/bin/reprepro --confdir '/etc/reprepro' --silent --component "${COMPONENT}" list "${VERSION_CODENAME}" "${PKGNAME}" | /usr/bin/mawk '{print $NF}' | /usr/bin/head --lines='1')
|
||||
if [[ -z "${VERSION_B}" ]] || \
|
||||
/usr/bin/dpkg --compare-versions "$VERSION_A" gt "${VERSION_B}" 2>/dev/null; then
|
||||
/usr/bin/echo '# --- --- --- --- --- #'
|
||||
/usr/bin/echo "Download (wofferl/proxmox-backup-arm64): ${DEB}"
|
||||
/usr/bin/wget --quiet --output-document="${TEMP}/${DEB}" "${URL}"
|
||||
/usr/bin/echo "Repository (${VERSION_CODENAME}/${COMPONENT}): ${PKGNAME}"
|
||||
/usr/bin/reprepro --confdir '/etc/reprepro' --silent --component "${COMPONENT}" includedeb "${VERSION_CODENAME}" "${TEMP}/${DEB}" &> '/dev/null'
|
||||
/usr/bin/rm --force "${TEMP}/${DEB}"
|
||||
fi
|
||||
done
|
||||
/usr/bin/rm --force --recursive "${TEMP}"
|
||||
}
|
||||
|
||||
|
||||
###
|
||||
#
|
||||
# Runtime Environment
|
||||
#
|
||||
###
|
||||
|
||||
if [[ "${EUID}" -ne '0' ]]; then
|
||||
/usr/bin/echo 'Error: Permission Denied'
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "${1}" ]] || \
|
||||
[[ "${1}" != @(add|remove|update) ]]; then
|
||||
/usr/bin/echo 'Usage: repository [add|remove|update]'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OUTDIR=$(/usr/bin/grep 'outdir' '/etc/reprepro/options' | /usr/bin/sed --expression='s/outdir //')
|
||||
ARGUMENT="${1}"
|
||||
VERSION_CODENAME="${2}"
|
||||
DEB_PATH="${3}"
|
||||
DEB_NAME=$(/usr/bin/basename "${DEB_PATH}")
|
||||
PKGNAME=$(/usr/bin/basename "${DEB_PATH%%_*}")
|
||||
|
||||
case "${ARGUMENT}" in
|
||||
add)
|
||||
if [[ -z "${VERSION_CODENAME}" ]] || \
|
||||
[[ "${VERSION_CODENAME}" != @(all|bookworm|trixie|noble) ]] || \
|
||||
[[ -z "${DEB_PATH}" ]]; then
|
||||
/usr/bin/echo 'Usage: repository [add] (all|bookworm|trixie|noble) (DEB)'
|
||||
exit 1
|
||||
fi
|
||||
if /usr/bin/dpkg-deb -W "${DEB_PATH}" &> '/dev/null'; then
|
||||
if [[ -d "${OUTDIR}/pool/main/${DEB_NAME:0:1}/${PKGNAME}" ]]; then
|
||||
/usr/bin/echo "Error: The Package '${PKGNAME}' already exist."
|
||||
exit 1
|
||||
fi
|
||||
if [[ "${VERSION_CODENAME}" == 'all' ]]; then
|
||||
for VERSION_CODENAME in bookworm trixie noble; do
|
||||
/usr/bin/echo '# --- --- --- --- --- #'
|
||||
/usr/bin/echo "Repository (${VERSION_CODENAME}/main) : ${PKGNAME}"
|
||||
/usr/bin/reprepro --confdir '/etc/reprepro' --silent --component 'main' includedeb "${VERSION_CODENAME}" "${DEB_PATH}" &> '/dev/null'
|
||||
/usr/bin/echo '# --- --- --- --- --- #'
|
||||
done
|
||||
elif [[ "${VERSION_CODENAME}" =~ ^(bookworm|trixie|noble)$ ]]; then
|
||||
/usr/bin/echo '# --- --- --- --- --- #'
|
||||
/usr/bin/echo "Repository (${VERSION_CODENAME}/main) : ${PKGNAME}"
|
||||
/usr/bin/reprepro --confdir '/etc/reprepro' --silent --component 'main' remove "${VERSION_CODENAME}" "${PKGNAME}" &> '/dev/null'
|
||||
/usr/bin/reprepro --confdir '/etc/reprepro' --silent --component 'main' includedeb "${VERSION_CODENAME}" "${DEB_PATH}" &> '/dev/null'
|
||||
/usr/bin/echo '# --- --- --- --- --- #'
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
remove)
|
||||
if [[ -z "${VERSION_CODENAME}" ]] || \
|
||||
[[ "${VERSION_CODENAME}" != @(all|bookworm|trixie|noble) ]] || \
|
||||
[[ -z "${DEB_PATH}" ]]; then
|
||||
/usr/bin/echo 'Usage: repository [remove] (all|bookworm|trixie|noble) (DEB)'
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -d "${OUTDIR}/pool/main/${DEB_NAME:0:1}/${PKGNAME}" ]]; then
|
||||
/usr/bin/echo "Error: The Package '${PKGNAME}' does not exist."
|
||||
exit 1
|
||||
fi
|
||||
if [[ "${VERSION_CODENAME}" == 'all' ]]; then
|
||||
for VERSION_CODENAME in bookworm trixie noble; do
|
||||
/usr/bin/echo '# --- --- --- --- --- #'
|
||||
/usr/bin/echo "Repository (${VERSION_CODENAME}/main) : ${PKGNAME}"
|
||||
/usr/bin/reprepro --confdir '/etc/reprepro' --silent --component 'main' remove "${VERSION_CODENAME}" "${PKGNAME}" &> '/dev/null'
|
||||
/usr/bin/echo '# --- --- --- --- --- #'
|
||||
done
|
||||
elif [[ "${VERSION_CODENAME}" =~ ^(bookworm|trixie|noble)$ ]]; then
|
||||
/usr/bin/echo '# --- --- --- --- --- #'
|
||||
/usr/bin/echo "Repository (${VERSION_CODENAME}/main) : ${PKGNAME}"
|
||||
/usr/bin/reprepro --confdir '/etc/reprepro' --silent --component 'main' remove "${VERSION_CODENAME}" "${PKGNAME}" &> '/dev/null'
|
||||
/usr/bin/echo '# --- --- --- --- --- #'
|
||||
fi
|
||||
;;
|
||||
update)
|
||||
if [[ -z "${VERSION_CODENAME}" ]] || \
|
||||
[[ "${VERSION_CODENAME}" != @(all|bookworm|trixie|noble) ]]; then
|
||||
/usr/bin/echo 'Usage: repository [update] (all|bookworm|trixie|noble)'
|
||||
exit 1
|
||||
fi
|
||||
case "${VERSION_CODENAME}" in
|
||||
all)
|
||||
import_pve 'arm64' 'bookworm' 'main'
|
||||
import_pve 'arm64' 'bookworm' 'ceph-squid'
|
||||
import_pbs 'bookworm'
|
||||
import_pve 'arm64' 'trixie' 'main'
|
||||
import_pve 'arm64' 'trixie' 'ceph-squid'
|
||||
import_pbs 'trixie'
|
||||
;;
|
||||
bookworm)
|
||||
import_pve 'arm64' 'bookworm' 'main'
|
||||
import_pve 'arm64' 'bookworm' 'ceph-squid'
|
||||
import_pbs 'bookworm'
|
||||
;;
|
||||
trixie)
|
||||
import_pve 'arm64' 'trixie' 'main'
|
||||
import_pve 'arm64' 'trixie' 'ceph-squid'
|
||||
import_pbs 'trixie'
|
||||
;;
|
||||
noble)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user