Simplify repo structure.
This commit is contained in:
1 parent
fd2484b561
commit
6ab810814d
30 files changed
+689
-32
No files matched your search
@@ -0,0 +1,18 @@
|
||||
def intersect(x;y):
|
||||
( (x|unique) + (y|unique) | sort) as $sorted
|
||||
| reduce range(1; $sorted|length) as $i
|
||||
([];
|
||||
if $sorted[$i] == $sorted[$i-1] then . + [$sorted[$i]] else . end) ;
|
||||
|
||||
def difference($a; $b):
|
||||
($a | unique) - $b;
|
||||
|
||||
{
|
||||
cs9: {
|
||||
common: ((intersect($aarch64;$x86_64)) | sort_by(ascii_downcase)),
|
||||
arch: {
|
||||
x86_64: (($x86_64 - $aarch64) | sort_by(ascii_downcase)),
|
||||
aarch64: (($aarch64 - $x86_64) | sort_by(ascii_downcase))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
def basenames:
|
||||
.path | split("/") | last;
|
||||
|
||||
def parseURL:
|
||||
capture("^((?<scheme>[^:/?#]+):)?(//(?<authority>(?<domain>[^/?#:]*)(:(?<port>[0-9]*))?))?(?<path>[^?#]*)(\\?(?<query>([^#]*)))?(#(?<fragment>(.*)))?");
|
||||
|
||||
def splitRPM:
|
||||
capture("(?<name>(.*))\\.(?<arch>[a-zA-Z0-9_]+).rpm");
|
||||
|
||||
def manifestUrls:
|
||||
.sources["org.osbuild.curl"].items | to_entries[] | .value | parseURL;
|
||||
|
||||
def urlsToRpms:
|
||||
basenames | splitRPM;
|
||||
|
||||
def mergeArches:
|
||||
reduce .[] as $item ({}; .[$item.arch][$item.name] = true) | with_entries(.value = (.value | keys));
|
||||
|
||||
manifestUrls | select(.domain == "mirror.stream.centos.org") | urlsToRpms | .name
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Generates single-file from-scratch and delta update files for all or some of the
|
||||
# refs in an OSTree repo.
|
||||
#
|
||||
# To use it run "generate-deltas REPODIR DESTDIR" which will look at all the refs in the
|
||||
# repo and make updates to the latest version putting them in the DESTDIR directory.
|
||||
|
||||
# To apply these on a live system, do something like:
|
||||
# $ ostree static-delta apply-offline cs9-x86_64-qemu-upgrade-demo-79da0b2f1b119e99137eaef9680fae9820a9edcd5cac4f6d7c23279498c578f6.update
|
||||
# $ rpm-ostree rebase 79da0b2f1b119e99137eaef9680fae9820a9edcd5cac4f6d7c23279498c578f6
|
||||
|
||||
if [ "$#" -lt 2 ]; then
|
||||
echo "Usage generate-deltas REPODIR DESTDIR [REFS..]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
REPO=$1
|
||||
DIR=$2
|
||||
|
||||
shift 2
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
REFS="$@"
|
||||
else
|
||||
REFS=$(ostree --repo=$REPO refs)
|
||||
fi
|
||||
|
||||
mkdir -p $DIR
|
||||
|
||||
NUM_DELTAS=3
|
||||
for REF in $REFS; do
|
||||
REF_AS_FILE=$(echo $REF | sed "s%/%-%g" )
|
||||
HEAD=$(ostree --repo=$REPO rev-parse $REF)
|
||||
|
||||
# Generate full update for HEAD:
|
||||
echo Generating non-delta update for $REF commit $HEAD
|
||||
ostree static-delta generate --repo=$REPO --inline --min-fallback-size=0 --empty --filename=$DIR/$REF_AS_FILE-$HEAD.update $HEAD
|
||||
|
||||
# Generate deltas to HEAD from up to the last 3 parents
|
||||
PARENT=$HEAD
|
||||
for i in seq $NUM_DELTAS; do
|
||||
if ! PARENT=$(ostree --repo=$REPO rev-parse $PARENT^ 2>/dev/null); then
|
||||
break;
|
||||
fi
|
||||
echo Generating delta update for $REF commit $HEAD from commit $PARENT
|
||||
ostree static-delta generate --repo=$REPO --inline --min-fallback-size=0 --from=$PARENT --filename=$DIR/$REF_AS_FILE-$PARENT-$HEAD.update $HEAD
|
||||
done
|
||||
|
||||
done
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This is a helper used by the makefile to handle the OSTREE_REPO mpp
|
||||
# support. It creates a json dict mapping all the refs in the repo
|
||||
# (if it exists) to the latest commit. This is then passed to osbuild-mpp
|
||||
# as the ostree_parent_refs variable that is used by the manifests to pick
|
||||
# the right parent commit.
|
||||
|
||||
REPOPATH=$1
|
||||
FIRST=1
|
||||
echo -n "{"
|
||||
if test -d $REPOPATH; then
|
||||
for ref in $(ostree refs --repo=$REPOPATH); do
|
||||
if [ $FIRST == 1 ]; then
|
||||
FIRST=0
|
||||
else
|
||||
echo -n ,
|
||||
fi
|
||||
echo -n \"$ref\":\"$(ostree rev-parse --repo=$REPOPATH $ref)\"
|
||||
done
|
||||
fi
|
||||
echo -n "}"
|
||||
Executable
+106
@@ -0,0 +1,106 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This is a helper for the makefile rule to build a particular image
|
||||
# from the preprocessed json manifest. It is a shellscript rather
|
||||
# than just some make lines because some of the complexities just
|
||||
# are painful to do in make.
|
||||
#
|
||||
# Features:
|
||||
#
|
||||
# * Knows what target to export based on the extensions.
|
||||
# * Knows what the exported filename based on the extensions.
|
||||
# * Supports building natively or in a VM via osbuildvm.
|
||||
# * Runs only the minimal required commands as root, and
|
||||
# chowns the resulting files to the user
|
||||
# * Supports exporting an extra ostree commit and pulling that
|
||||
# into an existing repo.
|
||||
|
||||
set -e
|
||||
|
||||
DEST="$1"
|
||||
JSON="$2"
|
||||
TARGET="$3"
|
||||
IMAGETYPE="$4"
|
||||
ARCH="$5"
|
||||
EXTENSION="$6"
|
||||
|
||||
# Map extension => export pipeline name
|
||||
declare -A EXPORT_BY_EXT
|
||||
EXPORT_BY_EXT[img]=image
|
||||
EXPORT_BY_EXT[oci.tar]=container
|
||||
EXPORT_BY_EXT[qcow2]=qcow2
|
||||
EXPORT_BY_EXT[repo]=ostree-commit
|
||||
EXPORT_BY_EXT[rootfs]=rootfs
|
||||
EXPORT_BY_EXT[ext4]=ext4
|
||||
EXPORT_BY_EXT[tar]=tar
|
||||
|
||||
# Map extension to name of exported file by pipeline
|
||||
declare -A EXPORT_FILE_BY_EXT
|
||||
EXPORT_FILE_BY_EXT[img]=disk.img
|
||||
EXPORT_FILE_BY_EXT[qcow2]=disk.qcow2
|
||||
EXPORT_FILE_BY_EXT[oci.tar]=container.tar
|
||||
EXPORT_FILE_BY_EXT[repo]=repo
|
||||
EXPORT_FILE_BY_EXT[rootfs]=
|
||||
EXPORT_FILE_BY_EXT[ext4]=rootfs.ext4
|
||||
EXPORT_FILE_BY_EXT[tar]=rootfs.tar
|
||||
|
||||
EXPORT=${EXPORT_BY_EXT[${EXTENSION}]}
|
||||
EXPORT_FILE=${EXPORT_FILE_BY_EXT[${EXTENSION}]}
|
||||
|
||||
HOST_ARCH=$(arch)
|
||||
CURRENT_UIDGID="$(id -u):$(id -g)"
|
||||
|
||||
if [ $ARCH == $HOST_ARCH -a $VM == 0 ]; then
|
||||
SUDO="sudo"
|
||||
OSBUILD="sudo osbuild"
|
||||
else
|
||||
SUDO=
|
||||
OSBUILD="osbuildvm/osbuildvm --arch=$ARCH"
|
||||
fi
|
||||
|
||||
EXPORT_ARGS="--export $EXPORT"
|
||||
|
||||
CHECKPOINT_ARGS=
|
||||
for CP in $CHECKPOINTS; do
|
||||
CHECKPOINT_ARGS="${CHECKPOINT_ARGS} --checkpoint ${CP}"
|
||||
done
|
||||
|
||||
CHOWNARGS=
|
||||
if [ $EXTENSION == repo ]; then
|
||||
CHOWNARGS=-R # Chown entire repo dir as it doesn't care about permissions
|
||||
fi
|
||||
|
||||
EXPORTDIRS=$OUTPUTDIR/$EXPORT
|
||||
|
||||
# If OSTREE_REPO is set, and we're building an image that has an
|
||||
# ostree commit, then we also export that commit to the repo specified
|
||||
# by OSTREE_REPO.
|
||||
ALSO_EXPORT_OSTREE=0
|
||||
if [ "$OSTREE_REPO" != "" -a "$IMAGETYPE" == "ostree" ]; then
|
||||
ALSO_EXPORT_OSTREE=1
|
||||
if [ $EXPORT != "ostree-commit" ]; then
|
||||
EXPORT_ARGS="$EXPORT_ARGS --export ostree-commit"
|
||||
EXPORTDIRS="$EXPORTDIRS $OUTPUTDIR/ostree-commit"
|
||||
fi
|
||||
|
||||
# Ensure we have a repo to export to
|
||||
ostree init --repo=$OSTREE_REPO --mode archive
|
||||
fi
|
||||
|
||||
set -x
|
||||
|
||||
$SUDO rm -rf $EXPORTDIRS
|
||||
mkdir -p $EXPORTDIRS # Own export dirs by user, not root
|
||||
|
||||
$OSBUILD $CHECKPOINT_ARGS --store $STOREDIR --output-directory $OUTPUTDIR $EXPORT_ARGS $OSBUILD_ARGS $JSON
|
||||
|
||||
if [ $ALSO_EXPORT_OSTREE == "1" ]; then
|
||||
ostree pull-local --repo=$OSTREE_REPO $OUTPUTDIR/ostree-commit/repo
|
||||
fi
|
||||
|
||||
# Extract and chown exported file
|
||||
rm -rf $DEST
|
||||
$SUDO chown $CHOWNARGS $CURRENT_UIDGID $OUTPUTDIR/$EXPORT/$EXPORT_FILE
|
||||
$SUDO mv $OUTPUTDIR/$EXPORT/$EXPORT_FILE $DEST
|
||||
|
||||
$SUDO rm -rf $EXPORTDIRS
|
||||
Reference in new issue
Block a user