Cosmetics / try to avoid a few unecessary error message (rm without -f) (#5)

This commit is contained in:
Alexandre Aubin 2018-03-08 20:51:10 +01:00 committed by GitHub
parent a1cd1958ba
commit 5257106fd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 20 deletions

View file

@ -123,7 +123,7 @@ if is_iso "$file"; then
then then
cp -f $BUILD_DIR/isolinux/{adgtk.cfg,adtxt.cfg,gtk.cfg,menu.cfg,stdmenu.cfg,txt.cfg} $buildtree/isolinux/ cp -f $BUILD_DIR/isolinux/{adgtk.cfg,adtxt.cfg,gtk.cfg,menu.cfg,stdmenu.cfg,txt.cfg} $buildtree/isolinux/
else else
rm $buildtree/isolinux/{adgtk.cfg,adtxt.cfg,gtk.cfg,menu.cfg,stdmenu.cfg,txt.cfg} rm -f $buildtree/isolinux/{adgtk.cfg,adtxt.cfg,gtk.cfg,menu.cfg,stdmenu.cfg,txt.cfg}
cp -f $BUILD_DIR/isolinux/{amdadgtk.cfg,amdadtxt.cfg,amdgtk.cfg,menu.cfg,stdmenu.cfg,amdtxt.cfg} $buildtree/isolinux/ cp -f $BUILD_DIR/isolinux/{amdadgtk.cfg,amdadtxt.cfg,amdgtk.cfg,menu.cfg,stdmenu.cfg,amdtxt.cfg} $buildtree/isolinux/
fi fi
@ -144,4 +144,4 @@ fi
echo "Output in $outfile" echo "Output in $outfile"
rm "$fwfile" rm -f "$fwfile"

View file

@ -4,14 +4,23 @@
# DIST stable|testing # DIST stable|testing
# DEB_DIST jessie|stretch # DEB_DIST jessie|stretch
DEFAULT_DEB_DIST="jessie" readonly DEFAULT_DEB_DIST="jessie"
readonly REPO_URL="http://repo.yunohost.org/debian/"
readonly ARCH_CHOICE=$1
readonly DIST="${2:-stable}"
readonly DEB_DIST="${3:-$DEFAULT_DEB_DIST}"
source ./common.sh
# Build Yunohost iso for amd64 or i386 arch # Build Yunohost iso for amd64 or i386 arch
# Usage: build ARCH # Usage: build ARCH
function build function build
{ {
local ARCH="$1" local ARCH="$1"
REPO_URL="http://repo.yunohost.org/debian/"
info "Starting build for arch $ARCH ..."
if [ "$DIST" = "testing" ] ; then if [ "$DIST" = "testing" ] ; then
sed -i "s#$REPO_URL jessie stable#$REPO_URL $DEB_DIST stable testing#" profiles/*.preseed sed -i "s#$REPO_URL jessie stable#$REPO_URL $DEB_DIST stable testing#" profiles/*.preseed
sed -i "s#$REPO_URL stretch stable#$REPO_URL $DEB_DIST stable testing#" profiles/*.preseed sed -i "s#$REPO_URL stretch stable#$REPO_URL $DEB_DIST stable testing#" profiles/*.preseed
@ -22,18 +31,20 @@ function build
build-simple-cdd --dist $DEB_DIST --conf ./simple-cdd-$ARCH.conf build-simple-cdd --dist $DEB_DIST --conf ./simple-cdd-$ARCH.conf
# Find the release version of debian # Find the release version of debian
DEBNUM="$(grep "Version:" tmp/${DEB_DIST}_Release | awk '{print $2;}')" local DEBNUM="$(grep "Version:" tmp/${DEB_DIST}_Release | awk '{print $2;}')"
# Find the release version of YunoHost # Find the release version of YunoHost
wget ${REPO_URL}dists/${DEB_DIST}/${DIST}/binary-i386/Packages.gz wget ${REPO_URL}dists/${DEB_DIST}/${DIST}/binary-i386/Packages.gz
gunzip Packages.gz gunzip Packages.gz
YNH_VERSION=$(grep "^Package: yunohost$" --after-context=1 Packages | grep "Version" | awk '{print $2;}') YNH_VERSION=$(grep "^Package: yunohost$" --after-context=1 Packages | grep "Version" | awk '{print $2;}')
rm Packages rm -f Packages
rm -f images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso rm -f images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso
$(pwd)/add-firmware-to images/debian-$DEBNUM-$ARCH-CD-1.iso images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso $DEB_DIST $(pwd)/add-firmware-to images/debian-$DEBNUM-$ARCH-CD-1.iso images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso $DEB_DIST
rm images/debian-$DEBNUM-$ARCH-CD-1.iso rm -f images/debian-$DEBNUM-$ARCH-CD-1.iso
rm images/debian-$DEBNUM-$ARCH-CD-1.list.gz rm -f images/debian-$DEBNUM-$ARCH-CD-1.list.gz
success "The image should now be available in images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso"
} }
# Sign the new iso # Sign the new iso
@ -41,27 +52,33 @@ function build
function sign function sign
{ {
local ARCH="$1" local ARCH="$1"
NAME="images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso" local NAME="images/yunohost-$DEB_DIST-$YNH_VERSION-$ARCH-$DIST.iso"
info "Signing image $NAME ..."
gpg --output $NAME.sig --detach-sig $NAME gpg --output $NAME.sig --detach-sig $NAME
sha256sum $NAME > $NAME.sum sha256sum $NAME > $NAME.sum
} }
function build_and_sign function build_and_sign
{ {
rm -r $(pwd)/tmp
local ARCH="$1" local ARCH="$1"
rm -r $(pwd)/tmp
build $ARCH build $ARCH
sign $ARCH sign $ARCH
} }
DIST="${2:-stable}" function main
DEB_DIST="${3:-$DEFAULT_DEB_DIST}" {
if [ -z "$ARCH_CHOICE" ]
then
info "No arch chosen, will build both i396 and amd64"
build_and_sign i386
build_and_sign amd64
else
build_and_sign $ARCH_CHOICE
fi
}
if [ -z "$1" ] main
then
build_and_sign i386
build_and_sign amd64
else
build_and_sign $1
fi

43
common.sh Normal file
View file

@ -0,0 +1,43 @@
readonly NORMAL=$(printf '\033[0m')
readonly BOLD=$(printf '\033[1m')
readonly faint=$(printf '\033[2m')
readonly UNDERLINE=$(printf '\033[4m')
readonly NEGATIVE=$(printf '\033[7m')
readonly RED=$(printf '\033[31m')
readonly GREEN=$(printf '\033[32m')
readonly ORANGE=$(printf '\033[33m')
readonly BLUE=$(printf '\033[34m')
readonly YELLOW=$(printf '\033[93m')
readonly WHITE=$(printf '\033[39m')
function success()
{
local msg=${1}
echo " "
echo "[${BOLD}${GREEN} OK ${NORMAL}] ${msg}"
echo " "
}
function info()
{
local msg=${1}
echo " "
echo "[${BOLD}${BLUE}INFO${NORMAL}] ${msg}"
echo " "
}
function warn()
{
local msg=${1}
echo " "
echo "[${BOLD}${ORANGE}WARN${NORMAL}] ${msg}"
echo " "
}
function error()
{
local msg=${1}
echo " "
echo "[${BOLD}${RED}FAIL${NORMAL}] ${msg}"
echo " "
}