From ba2a423d23d423372930e66e32e7d7e65196065f Mon Sep 17 00:00:00 2001 From: Andrey Sokolov Date: Wed, 25 Aug 2021 15:01:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=82=D0=B8=D0=BF=20=D1=80=D0=B5=D0=BF?= =?UTF-8?q?=D0=BE=D0=B7=D0=B8=D1=82=D0=BE=D1=80=D0=B8=D1=8F=20=D0=B8=20?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rootfs_to_repo.sh | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/rootfs_to_repo.sh b/rootfs_to_repo.sh index 3a5cf97..3c7b7bb 100755 --- a/rootfs_to_repo.sh +++ b/rootfs_to_repo.sh @@ -3,8 +3,8 @@ set -e if [ -z "$4" ] then - echo "Help: $0 " - echo "For example: out/acos-20210824-x86_64.tar repo acos/x86_64/sisyphus out" + echo "Help: $0 " + 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