This repository contains all scripts needed to create your very own BeeSlack. See https://hackaday.io/project/10145-backend-library-for-the-iot-bee-hive-monitor for a little more information...

UpdateRepo.sh 6.6KB

    #!/bin/bash # Copyright 2016 Johann Wilhelm # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # loosely based on the build_minirootfs.sh script by Stuart Winter # # copy this list from "build_minirootfs.sh" to get a recent file-list... # be aware of iptools* which was changed to iptools and the seems to be a missing \ after a/xz... # PKGLIST="a/aaa_base \ a/aaa_elflibs \ a/aaa_terminfo \ a/acl \ a/attr \ a/bash \ a/bin \ a/btrfs-progs \ a/bzip2 \ a/coreutils \ a/dbus \ a/dcron \ a/devs \ a/dialog \ a/e2fsprogs \ a/ed \ a/elvis \ a/etc \ a/file \ a/findutils \ a/hwdata \ a/lvm2 \ a/less \ a/gawk \ a/gettext \ a/getty-ps \ a/glibc-solibs \ a/glibc-zoneinfo \ a/gptfdisk \ a/grep \ a/gzip \ a/kbd \ a/jfsutils \ a/inotify-tools \ a/kmod \ a/mtd-utils \ a/openssl-solibs \ a/pkgtools \ a/procps-ng \ a/reiserfsprogs \ a/shadow \ a/sed \ a/sysklogd \ a/tar \ a/u-boot-tools \ a/eudev \ a/libgudev \ a/usbutils \ a/util-linux \ a/vboot-utils \ a/which \ a/xfsprogs \ a/xz \ ap/nano \ ap/slackpkg \ n/dhcpcd \ n/lftp \ n/links \ n/network-scripts \ n/nfs-utils \ n/ntp \ n/iputils \ n/net-tools \ n/iproute2 \ n/openssh \ n/rpcbind \ n/libtirpc \ n/rsync \ n/telnet \ n/traceroute \ n/wget \ n/wpa_supplicant \ n/wireless-tools \ l/lzo \ l/libnl3 \ a/sysvinit \ a/sysvinit-scripts \ l/pcre" # the additional packages needed for beestalker PKGLIST="$PKGLIST \ n/curl \ n/gnupg \ n/gnupg2 \ n/ca-certificates \ n/openssl \ d/perl \ n/ntp \ ap/diffutils \ d/git \ a/usb_modeswitch \ n/ppp \ a/logrotate \ l/libpcap \ n/cyrus-sasl" AdditionalPkgs="ap/beestalker \ d/avrdude \ d/libelf \ l/libbcmrpi" # source repo... i.e a slackware-current tree... SRC=$(pwd)/slackwarearm-current/slackware #the package source... # destination... this is your actual BeeSlack directory DST=$(pwd)/repo/slackware #the repo # the changelog CHANGES=$(pwd)/Changes.txt ################ borrowed from Slackwares own upgradepgk ######### #same license text as stated above but different copyright notice: # # Copyright 1999 Patrick Volkerding, Moorhead, Minnesota, USA # Copyright 2001, 2002, 2003 Slackware Linux, Inc., Concord, California, USA # Copyright 2009, 2015 Patrick J. Volkerding, Sebeka, MN, USA # Copyright 2015 Michal Nazarewicz <mina86@mina86.com> pkgbase() { PKGRETURN=${1##*/} case "$PKGRETURN" in *.t[gblx]z) PKGRETURN=${PKGRETURN%.*} esac echo "$PKGRETURN" } package_name() { STRING=$(pkgbase "$1") case "$STRING" in *-*-*-*) # At least four segments, strip version arch and build and return name: echo "${STRING%-*-*-*}" # cruft for later ;) # BUILD=${STRING##*-} # STRING=${STRING%*-} # ARCH=${STRING##*-} # STRING=${STRING%*-} # VER=${STRING%*-} ;; *) # Old style package name with one segment or we don't have four # segments: return the old-style (or out of spec) package name. echo $STRING esac } ######################## EOB (end of borrow :) ############### echo "Updated to current NEWLINE ">$CHANGES #install all BeeSlack specific packages... echo "Check Additional Packages..." for Package in $AdditionalPkgs; do IFS='/' read -r -a PARTS <<< "$Package" SERIES=${PARTS[0]} PKG=${PARTS[1]} echo "\" $Package \"" if [ ! -d "$DST/$SERIES" ]; then mkdir "$DST/$SERIES" fi SRCpkg=$(find ./AdditionalPkgs -maxdepth 1 -regextype posix-extended -regex ".*/$PKG-[^-]+-[^-]+-[^-]+\.t[gblx]z") SRCpkg=$(basename $SRCpkg) SRCpkg=$(pkgbase "$SRCpkg") DSTpkg=$(find $DST/$SERIES -maxdepth 1 -regextype posix-extended -regex ".*/$PKG-[^-]+-[^-]+-[^-]+\.t[gblx]z") DSTpkg=$(basename $DSTpkg) DSTpkg=$(pkgbase "$DSTpkg") if [ "$DSTpkg" == "" ]; then echo "New package \"$SRCpkg\"..." echo " $SERIES/$SRCpkg: Added. NEWLINE ">>$CHANGES cp ./AdditionalPkgs/$SRCpkg.* $DST/$SERIES else #replace old pkg if needed... if [ "$SRCpkg" != "$DSTpkg" ]; then echo need update for $SERIES/$DSTpkg to $SRCpkg echo " $SERIES/$SRCpkg: Upgraded. LINEFEED Updated from $DSTpkg NEWLINE ">>$CHANGES rm $DST/$SERIES/$DSTpkg.* cp ./AdditionalPkgs/$SRCpkg.* $DST/$SERIES fi fi done #update Slackware... echo "Check Slackware Packages..." for Package in $PKGLIST; do IFS='/' read -r -a PARTS <<< "$Package" SERIES=${PARTS[0]} PKG=${PARTS[1]} if [ ! -d "$DST/$SERIES" ]; then mkdir "$DST/$SERIES" fi SRCpkg=$(find $SRC/$SERIES -maxdepth 1 -regextype posix-extended -regex ".*/$PKG-[^-]+-[^-]+-[^-]+\.t[gblx]z") SRCpkg=$(basename $SRCpkg) SRCpkg=$(pkgbase "$SRCpkg") DSTpkg=$(find $DST/$SERIES -maxdepth 1 -regextype posix-extended -regex ".*/$PKG-[^-]+-[^-]+-[^-]+\.t[gblx]z") DSTpkg=$(basename $DSTpkg) DSTpkg=$(pkgbase "$DSTpkg") if [ "$DSTpkg" == "" ]; then echo "New package \"$SRCpkg\"..." echo " $SERIES/$SRCpkg: Added. NEWLINE ">>$CHANGES cp $SRC/$SERIES/$SRCpkg.* $DST/$SERIES else #replace old pkg if needed... if [ "$SRCpkg" != "$DSTpkg" ]; then echo need update for $SERIES/$DSTpkg to $SRCpkg echo " $SERIES/$SRCpkg: Upgraded. LINEFEED Updated from $DSTpkg NEWLINE ">>$CHANGES rm $DST/$SERIES/$DSTpkg.* cp $SRC/$SERIES/$SRCpkg.* $DST/$SERIES fi fi done #remove others... echo "Cleanup..." SERIES=$(find $DST/* -maxdepth 1 -type d -printf "%f\n") for SERIE in $SERIES; do PACKAGES=$(find $DST/$SERIE/*.t[gblx]z -maxdepth 1 -type f -printf "%f\n") for PKG in $PACKAGES; do PkgName="$(package_name $PKG)" Pkgbase=$(pkgbase "$PKG") if [[ ! " ${PKGLIST[@]} " =~ " $SERIE/${PkgName} " ]]; then if [[ ! " ${AdditionalPkgs[@]} " =~ " $SERIE/${PkgName} " ]]; then echo "removing package $PkgName" echo " $SERIE/$PkgName: Removed. NEWLINE ">>$CHANGES rm -v $DST/$SERIE/$Pkgbase.* fi fi done done echo Done