Исправлены тип репозитория и формирование версии

This commit is contained in:
Andrey Sokolov 2021-08-25 15:01:28 +03:00
parent 0c427ab773
commit ba2a423d23

View File

@ -3,8 +3,8 @@ set -e
if [ -z "$4" ]
then
echo "Help: $0 <rootfs archive> <directory of main ostree repository> <branch> <output archives directory>"
echo "For example: out/acos-20210824-x86_64.tar repo acos/x86_64/sisyphus out"
echo "Help: $0 <rootfs archive> <directory of main ostree repository> <branch> <directory for output archives>"
echo "For example: $0 out/acos-20210824-x86_64.tar repo acos/x86_64/sisyphus out"
echo "You can change TMPDIR environment variable to set another directory where temporary files will be stored"
echo "If directory of main ostree repository doesn't exists, new repository will be created"
exit 1
@ -20,23 +20,38 @@ ROOTFS_ARCHIVE=$1
MAIN_REPO=$2
BRANCH=$3
OUT_DIR=$4
TMP_DIR=`mktemp --tmpdir -d rootfs_to_repo-XXXXXX`
MAIN_ROOT=$TMP_DIR/root
ACOS_ROOT=$TMP_DIR/acos_root
VAR_ARCH=$OUT_DIR/var.tar.xz
ROOT_ARCH=$OUT_DIR/acos_root.tar.xz
VERSION_DATE=`basename $ROOTFS_ARCHIVE | awk -F- '{print $2;}'`
rm -rf $TMP_DIR/* $VAR_ARCH $ROOT_ARCH
echo "Date for version: $VERSION_DATE"
if ! [[ "$VERSION_DATE" =~ ^[0-9]{8}$ ]]
then
echo "ERROR: The name of the rootfs archive contains an incorrect date"
exit 1
fi
if [ ! -d $OUT_DIR ]
then
echo "ERROR: Directory for output archives must exist"
exit 1
fi
rm -f $VAR_ARCH $ROOT_ARCH
TMP_DIR=`mktemp --tmpdir -d rootfs_to_repo-XXXXXX`
mkdir -p $MAIN_ROOT
tar xf $ROOTFS_ARCHIVE -C $MAIN_ROOT --exclude=./dev/tty --exclude=./dev/tty0 --exclude=./dev/console --exclude=./dev/urandom --exclude=./dev/random --exclude=./dev/full --exclude=./dev/zero --exclude=/dev/null --exclude=./dev/pts/ptmx --exclude=./dev/null
#####################
#Вынести в m-i-p
rm -f $MAIN_ROOT/etc/resolv.conf
ln -sf /run/systemd/resolve/resolv.conf $MAIN_ROOT/etc/resolv.conf
#####################
#Вынести в m-i-p
chroot $MAIN_ROOT systemctl enable ignition-firstboot-complete.service ostree-remount.service sshd docker
sed -i 's/^LABEL=ROOT\t/LABEL=boot\t/g' $MAIN_ROOT/etc/fstab
sed -i 's/^AcceptEnv /#AcceptEnv /g' $MAIN_ROOT/etc/openssh/sshd_config
@ -87,12 +102,12 @@ rm -rf $MAIN_ROOT/var/*
if [ ! -d $MAIN_REPO ]
then
#Создание главного ostree-репозитория
ostree init --repo=$MAIN_REPO --mode=archive
ostree init --repo=$MAIN_REPO --mode=bare
fi
ostree commit --repo=$MAIN_REPO --tree=dir=$MAIN_ROOT -b $BRANCH \
--no-xattrs --no-bindings --mode-ro-executables \
--add-metadata-string=version=sisyphus.`date +%Y%m%d`.0.0
--add-metadata-string=version=sisyphus.$VERSION_DATE.0.0
mkdir $ACOS_ROOT
ostree admin init-fs --modern $ACOS_ROOT