libdevuansdk

common library for devuan's simple distro kits
git clone https://git.parazyd.org/libdevuansdk
Log | Files | Refs | Submodules | README | LICENSE

commit 57bda192d5a0cd6853094c30298ab37afbe9be2d
parent fbf3c68b5a948fc76367f8ff8233645e5d9ba962
Author: parazyd <parazyd@dyne.org>
Date:   Thu, 29 Sep 2016 23:19:15 +0200

add rsync and packing to imaging

Diffstat:
Mzlibs/imaging | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Azlibs/rsync | 36++++++++++++++++++++++++++++++++++++
2 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/zlibs/imaging b/zlibs/imaging @@ -81,6 +81,48 @@ image_partition_raw_gpt() { sudo mkfs.ext4 -L rootfs $rootpart } +image_package_dist() { + fn image_package_dist + req=(mappdevice loopdevice image_name strapdir workdir) + ckreq || return 1 + + notice "packaging image for dist" + + act "rechecking filesystem" + sudo e2fsck -f ${mappdevice}p2 + sudo resize2fs ${mappdevice}p2 + + sleep 2 + + # TODO: decide how to check gpt + # [[ $gpt = 0 ]] || { + # sudo cgpt repair $loopdevice + # sleep 2 + # } + + sudo kpartx -dv $loopdevice || { die "kpartx failed to remove $loopdevice"; zerr } + sudo losetup -d $loopdevice || { die "losetup failed to remove $loopdevice"; zerr } + + notice "compressing image with xz" + silly + pushd $workdir + xz -zv ${image_name}.img + + notice "generating sha256 for ${image_name}.img.xz" + sha256sum ${image_name}.img.xz > ${image_name}.img.xz.sha + + mkdir -p $R/dist + mv -v ${image_name}.img.xz $R/dist/ + mv -v ${image_name}.img.xz.sha $R/dist/ + popd + + [[ $DEBUG = 1 ]] || { sudo rm -r $workdir } + + notice "finished packing $image_name" + act "find it in $R/dist/" + act "thanks for being patient!" +} + image_raw_mount() { fn image_raw_mount req=(workdir bootpart rootpart) @@ -90,3 +132,12 @@ image_raw_mount() { sudo mount $bootpart $workdir/boot && act "mounted boot partition" || zerr sudo mount $rootpart $workdir/root && act "mounted root partition" || zerr } + +image_raw_umount() { + fn image_raw_umount + req=(workdir bootpart rootpart) + ckreq || return 1 + + sudo umount $workdir/boot && act "unmounted boot partition" || zerr + sudo umount $workdir/root && act "unmounted root partition" || zerr +} diff --git a/zlibs/rsync b/zlibs/rsync @@ -0,0 +1,36 @@ +#!/usr/bin/env zsh +# Copyright (c) 2016 Dyne.org Foundation +# libdevuansdk is maintained by Ivan J. <parazyd@dyne.org> +# +# This file is part of libdevuansdk +# +# This source code 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 software 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 source code. If not, see <http://www.gnu.org/licenses/>. + +## ilporcodio + +rsync_to_raw_image() { + fn rsync_to_raw_image + req=(workdir strapdir bootpart rootpart) + + notice "rsyncing strapdir to raw image..." + image_raw_mount + + silly + pushd $strapdir + sudo rsync -HPavz -q --exclude={./boot} ./* $workdir/root + sudo rsync -HPavz -q ./boot/* $workdir/boot + popd + + image_raw_umount +}