From 98c14ef3a50b0b44873866c76f8653b5c2fa6d64 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 31 Aug 2013 16:31:09 +0200 Subject: [PATCH] debian/bin/init-reprepro.sh: Add. --- debian/bin/init-reprepro.sh | 90 +++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100755 debian/bin/init-reprepro.sh diff --git a/debian/bin/init-reprepro.sh b/debian/bin/init-reprepro.sh new file mode 100755 index 0000000..f16a69b --- /dev/null +++ b/debian/bin/init-reprepro.sh @@ -0,0 +1,90 @@ +# Setup a reprepro repository in /root/apt and add it to +# /etc/apt/sources.list. + +# Copyright (C) 2013 Simon Ruderich +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -e + + +sources=/etc/apt/sources.list +repo=/root/apt + +# Don't look for exact "file://$repo" match to allow modifications on the +# system. +if grep -E '^deb file:///' "$sources" >/dev/null 2>&1; then + echo "file:/// already present in '$sources'!" >&2 + exit 1 +fi + +# Create signing key for the repository if necessary. +email="apt@`hostname`" +if ! gpg --list-keys "$email" >/dev/null 2>&1; then + # See doc/DETAILS in the gpg source tree for documentation. + gpg --gen-key --batch </dev/null \ + || grep -E '^deb' "$sources" | head -n1 | awk '{ print $3 }'` + +# Create reprepro repository. +if test ! -d "$repo"; then + echo "creating reprepro repository in '$repo'" >&2 + mkdir -p "$repo/conf" + mkdir -p "$repo/morgue" + + arch=`dpkg --print-architecture` + cat >"$repo/conf/distributions" <"$repo/conf/options" <&2 + ( cd "$repo" && reprepro check ) || true + + # Does nothing if the same key is imported multiple times. + echo 'Adding key with apt-key.' >&2 + gpg --export "$keyid" | apt-key add - +fi + +echo "deb file://$repo $codename main" >>"$sources" + +echo 'Finished successfully'. >&2 -- 2.44.1