1#!/bin/mksh 2# $MirOS: src/scripts/tarsets,v 1.12 2009/09/15 15:42:48 tg Exp $ 3#- 4# Copyright (c) 2004, 2006, 2007, 2009 5# Thorsten Glaser <tg@mirbsd.org> 6# 7# Provided that these terms and disclaimer and all copyright notices 8# are retained or reproduced in an accompanying document, permission 9# is granted to deal in this work without restriction, including un- 10# limited rights to use, publicly perform, distribute, sell, modify, 11# merge, give away, or sublicence. 12# 13# This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to 14# the utmost extent permitted by applicable law, neither express nor 15# implied; without malicious intent or gross negligence. In no event 16# may a licensor, author or contributor be held liable for indirect, 17# direct, other damage, loss, or other issues arising in any way out 18# of dealing in the work, even if advised of the possibility of such 19# damage or existence of a defect, except proven that it results out 20# of said person's immediate fault when using the work as intended. 21 22me=${0##*/} 23cwd=$(realpath .) 24arch=${MACHINE:-$(uname -m)} 25 26function tarsets { 27 set=${1##*/} 28 [[ -e $cwd/$set/mi && -e $cwd/$set/md.$arch ]] || return 0 29 cat "$cwd/$set/mi" "$cwd/$set/md.$arch" 2>/dev/null | sort $2 30} 31 32function usage { 33 print -u2 "Syntax: $me [check | make <release>]" 34 exit 1 35} 36 37if [[ -z $DESTDIR ]]; then 38 print "Must set DESTDIR before calling ${0##*/}!" 39 exit 1 40fi 41 42if [[ $doz = [Nn]?([Oo]) ]]; then 43 compressor=cat 44 extension=newc 45 zt=uncompressed 46else 47 [[ $doz = [1-9] ]] || doz=9 48 compressor="gzip -n$doz" 49 extension=ngz 50 zt="gzip'd" 51fi 52 53case $1 { 54(c*) 55 T=$(mktemp /tmp/_tmp.XXXXXXXXXX) || exit 1 56 trap 'rm -f $T ; exit 0' 0 57 trap 'rm -f $T ; exit 1' 1 2 3 5 13 15 58 59 for set in */mi; do 60 tarsets "${set%/mi}" 61 done | cat - ignfiles 2>/dev/null | sort >$T 62 63 ( cd "$DESTDIR"; find . \( -type d -o -type f -o -type l \) ) \ 64 | grep -v -e '^\./snapshot' -e '^.$' | sort | diff -du $T - 65 ;; 66(m*) 67 rel=$2 68 [[ -n $rel ]] || usage 69 70 if [[ -z $RELEASEDIR ]]; then 71 print -u2 "Must set RELEASEDIR before calling $me!" 72 exit 1 73 fi 74 75 print "Generating $zt release tarballs for MirOS #${rel}/${arch}" 76 77 cd "$DESTDIR" 78 for set in $cwd/*/mi; do 79 set=${set%/mi} 80 [[ -e $set/md.$arch ]] || continue 81 print -n "${set##*/}..." 82 tarsets "$set" -u | \ 83 sed -n 's!^\.//*!!p' | \ 84 cpio -oC512 -Hsv4cpio -Mset | \ 85 $compressor >"$RELEASEDIR/${set##*/}$rel.$extension" 86 print done. 87 done 88 cd "$cwd" 89 ;; 90(*) 91 usage 92 ;; 93} 94