[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: unsigned repositories



I actually have a use case: injecting packages from
/var/cache/pbuilder/base.cow-somedist/repo/ into APT
from an optional cowbuilder hook script that I can
enable (chmod +x) when needed.

The hook script has the interesting constraint that
it adds a repository to APT with*out* running apt-get
update, i.e. ceteris paribus, keeping the *other*
repositories’ state as-is and NOT updating them from
the network. I sometimes rely on this.

-----BEGIN cutting here may damage your screen surface-----
#!/bin/bash
# $MirOS: contrib/hosted/tg/deb/hookdir/D01slashrepo,v 1.3 2019/02/24 03:34:00 tg Exp $
#-
# Copyright © 2014, 2018, 2019
#	mirabilos <m@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission
# is granted to deal in this work without restriction, including un‐
# limited rights to use, publicly perform, distribute, sell, modify,
# merge, give away, or sublicence.
#
# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
# the utmost extent permitted by applicable law, neither express nor
# implied; without malicious intent or gross negligence. In no event
# may a licensor, author or contributor be held liable for indirect,
# direct, other damage, loss, or other issues arising in any way out
# of dealing in the work, even if advised of the possibility of such
# damage or existence of a defect, except proven that it results out
# of said person’s immediate fault when using the work as intended.
#-
# Configure $base and $this at the beginning of the file. Do ensure:
# • base must be URI safe since we do not encode it for sources.list
# • this must be a valid basename for sources.list.d: [A-Za-z0-9._-]

base=/repo
this=D01slashrepo


unset LANGUAGE
LC_ALL=C; export LC_ALL

test -d "$base/." || {
	echo >&2 "E: D01slashrepo: base '$base' does not exist"
	exit 1
}

shopt -s extglob
base=${base%%*(/)}
pstr=${base//\//_}_._Packages

echo >&2 "I: creating Packages file for local APT cache in $base"
rm -f "$base/Packages"
(cd "$base"
#dpkg-scanpackages -h md5 -m . >Packages 2>/dev/null || \
    dpkg-scanpackages -m . >Packages 2>/dev/null || \
    dpkg-scanpackages . /dev/null >Packages)
paste -d_ <(sed -n '/^Package: /s///p' "$base/Packages") \
    <(sed -n '/^Version: /s///p' "$base/Packages") \
    <(sed -n '/^Architecture: /s///p' "$base/Packages") | \
    sed 's/^/N: /' >&2
echo >&2 "I: updating APT repository information"
cp "$base/Packages" "/var/lib/apt/lists/$pstr"
if test -d /etc/apt/sources.list.d/.; then
	echo "deb [trusted=yes] file://$base ./" >"/etc/apt/sources.list.d/$this.list"
else
	echo "deb file://$base ./" >>"/etc/apt/sources.list"
fi
apt-cache gencaches
echo >&2 "I: made $(grep -c '^Package: ' "$base/Packages") packages available from $base"
exit 0
-----END cutting here may damage your screen surface-----


It’s also much more convenient for quickly testing the
built packages: having the following snippet…
-----BEGIN cutting here may damage your screen surface-----
#!/bin/sh
cd "$(dirname "$0")"
rm -f Packages* en.gz
#dpkg-scanpackages -h md5 -m . >Packages 2>/dev/null || \
    dpkg-scanpackages -m . >Packages
gzip -n9 <Packages >Packages.gz
(: | gzip -n9 >en.gz)
-----END cutting here may damage your screen surface-----
… in /var/cache/pbuilder/result/0 (for quickly running
it from mc) and the sources.list snippet…
	deb [trusted=yes] file:///var/cache/pbuilder/result ./
… I can test-install stuff just built with an easy
	sudo apt-get update
	sudo apt-get install foo
or even
	sudo apt-get update
	sudo apt-get upgrade
instead of having to do
	sudo apt install /var/cache/pbuilder/result/{pkg1,pkg2,pkg-common}_*.deb
	sudo apt-mark auto pkg2 pkg-common
because installing .deb via apt doesn’t search the rest of
the directory for dependencies and disturbs the auto/manually
installed flag.


Please keep the code and support in APT.

Thanks,
//mirabilos
-- 
22:20⎜<asarch> The crazy that persists in his craziness becomes a master
22:21⎜<asarch> And the distance between the craziness and geniality is
only measured by the success 18:35⎜<asarch> "Psychotics are consistently
inconsistent. The essence of sanity is to be inconsistently inconsistent


Reply to: