Skip to content

Instantly share code, notes, and snippets.

@stdevPavelmc
Created March 27, 2024 01:19
Show Gist options
  • Save stdevPavelmc/12e5f1c0674ef214e12b81c191b9a105 to your computer and use it in GitHub Desktop.
Save stdevPavelmc/12e5f1c0674ef214e12b81c191b9a105 to your computer and use it in GitHub Desktop.
Ubuntu debmirror update script
#!/bin/bash
## Author: Pavel Milanes <pavelmc@gmail.com> / Telegram: @pavelmc
## Goal: mirror ubuntu repos
## Last Mod: Tue Mar 26 07:22:45 PM EST 2024
# This script use the terms described on the ubuntu base docs
# https://ubuntu.com/landscape/docs/explanation-about-repository-mirroring
# Archs, you can set more than one, comma separated no space [a,b,c,d]
arch=amd64
# Series, you can set more than one, comma separated no space [a,b,c,d]
series=jammy,noble
# Components, you can set more than one, comma separated no space [a,b,c,d]
components=main,restricted,universe,multiverse
# pockets, the release is a dummy one
pockets=release,updates,security,backports
# server
server=ubuntu.mirror.constant.com
# path on server
inPath=/ubuntu
# Protocol [http,https,ftp,rsync]
proto=http
# final destination
outPath=./mirror/amd64
### Let's do magic...
# build the series string
series_string=""
for s in ${series//,/ } ; do
for p in ${pockets//,/ } ; do
if [ "$p" == release ] ; then
series_string="${series_string}${s},"
else
series_string="${series_string}${s}-${p},"
fi
done
done
# Remove the trailing comma
series_string=${series_string%,*}
# This is the run command, it uses a modified debmirror, see patch here
# https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=944139;filename=debmirror-1%3A2.32-arch-all.diff;msg=20
/usr/local/bin/debmirror \
--verbose \
--no-source \
-a $arch \
-d $series_string \
-s $components \
-h $server \
-r $inPath \
--method=$proto \
--rsync-options "--partial -aIL" \
--rsync-extra=none \
--ignore-missing-serie \
--ignore-serie-gpg \
--ignore-small-errors \
--i18n \
--ignore-arch-all \
--exclude='-dbg_' \
--exclude='-dbgsym_' \
--exclude='/linux-aws/*' \
--exclude='/linux-meta-aws*' \
--exclude='-modules-aws*' \
--exclude='/linux-azure*' \
--exclude='/linux-meta-azure*' \
--exclude='-modules-azure*' \
--exclude='/linux-gcp*' \
--exclude='/linux-meta-gcp*' \
--exclude='-modules-gcp*' \
--exclude='/linux-gke*' \
--exclude='/linux-meta-gke*' \
--exclude='-modules-gke*' \
--exclude='/linux-ibm*' \
--exclude='/linux-meta-ibm*' \
--exclude='-modules-ibm*' \
--exclude='/linux-intel-iotg*' \
--exclude='/linux-meta-intel-iotg*' \
--exclude='-modules-intel-iotg*' \
--exclude='/linux-oracle*' \
--exclude='/linux-meta-oracle*' \
--exclude='-modules-oracle*' \
--exclude='/Translation-.*\.xz$' \
--exclude='/Translation-.*\.gz$' \
--include='/Translation-es.*\.gz$' \
--include='/Translation-en.*\.xz$' \
--no-check-gpg \
--progress \
--postcleanup \
$outPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment