Skip to content

Commit

Permalink
zwn (deb-build/slack-build): implement %pet <url> command
Browse files Browse the repository at this point in the history
%pet pkg-url.pet

downloads and installs the pet package.

it can be fixed to record the installed package
  • Loading branch information
wdlkmpx committed Aug 7, 2019
1 parent de477c6 commit 9724cf5
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 3 deletions.
44 changes: 43 additions & 1 deletion zwn/builders/deb-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,42 @@ download_pkg() {
return $retval
}

###
# $1-URL, $2-retry
download_pet_pkg() {
local retval=0 local
local PKGPATH=$1
local PKGFILE=${PKGPATH##*/} #basename
[ "$2" ] && echo "Bad md5sum $PKGFILE, attempting to re-download ..."
if ! [ -e "$REPO_DIR/$PKGFILE" ] ; then
echo Downloading "$PKGFILE" ...
wget -q --no-check-certificate -O $REPO_DIR/$PKGFILE "$PKGPATH"
if [ $? -eq 0 ] ; then
( cd $REPO_DIR ; md5sum $PKGFILE > ${PKGFILE}.md5 )
fi
fi
( cd $REPO_DIR ; md5sum -c ${PKGFILE}.md5 >/dev/null )
[ $? -ne 0 -a -z "$2" ] && rm -f "$REPO_DIR/$PKGFILE" && download_pet_pkg "$1" retry && retval=0
return $retval
}
# $1-URL
install_pet_pkg() {
local retval=0 PKGFILE=${1##*/} #basename
head -c -32 "$REPO_DIR/$PKGFILE" > "$REPO_DIR/$PKGFILE".tar
PETPREFIX=$(tar -tf "$REPO_DIR/$PKGFILE".tar | head -1)
case "$PETPREFIX" in
"./"*) tar --strip=2 --directory=${CHROOT_DIR} -xf "$REPO_DIR/$PKGFILE".tar ;;
*) tar --strip=1 --directory=${CHROOT_DIR} -xf "$REPO_DIR/$PKGFILE".tar ;;
esac
retval=$?
if [ $retval -eq 0 ] && [ -f ${CHROOT_DIR}/pinstall.sh ] ; then
( cd ${CHROOT_DIR} ; sh pinstall.sh )
fi
rm -f "$REPO_DIR/$PKGFILE".tar
rm -f ${CHROOT_DIR}/pet.specs ${CHROOT_DIR}/pinstall.sh ${CHROOT_DIR}/puninstall.sh
return $retval
}

# $@-all, doc, gtkdoc, locales, cache
cutdown() {
local options="$*" LIBDIR=lib
Expand Down Expand Up @@ -451,7 +487,7 @@ flatten_pkglist() {
%exit) break ;;
%include)
[ "$2" ] && flatten_pkglist "$2" ;;
%dpkg|%dpkgchroot|%bootstrap|%bblinks|%makesfs|%remove|%addbase|%addpkg|%dummy|%dpkg_configure|%lock|%cutdown|%import)
%pet|%dpkg|%dpkgchroot|%bootstrap|%bblinks|%makesfs|%remove|%addbase|%addpkg|%dummy|%dpkg_configure|%lock|%cutdown|%import)
echo "$pp" ;;
%symlink|%rm|%mkdir|%touch|%chroot)
echo "$pp" ;;
Expand Down Expand Up @@ -590,6 +626,12 @@ process_pkglist() {
shift # $@ commands
chroot $CHROOT_DIR "$@"
;;
%pet)
shift
download_pet_pkg "$1"
[ "$DOWNLOAD_ONLY" ] && continue
install_pet_pkg "$1" || { echo Installation of ${1##*/} failed. && exit 1; }
;;

# anything else - install package
*)
Expand Down
43 changes: 42 additions & 1 deletion zwn/builders/slack-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,41 @@ download_pkg() {
return $retval
}

###
# $1-URL, $2-retry
download_pet_pkg() {
local retval=0 local
local PKGPATH=$1
local PKGFILE=${PKGPATH##*/} #basename
[ "$2" ] && echo "Bad md5sum $PKGFILE, attempting to re-download ..."
if ! [ -e "$REPO_DIR/$PKGFILE" ] ; then
echo Downloading "$PKGFILE" ...
wget -q --no-check-certificate -O $REPO_DIR/$PKGFILE "$PKGPATH"
if [ $? -eq 0 ] ; then
( cd $REPO_DIR ; md5sum $PKGFILE > ${PKGFILE}.md5 )
fi
fi
( cd $REPO_DIR ; md5sum -c ${PKGFILE}.md5 >/dev/null )
[ $? -ne 0 -a -z "$2" ] && rm -f "$REPO_DIR/$PKGFILE" && download_pet_pkg "$1" retry && retval=0
return $retval
}
# $1-URL
install_pet_pkg() {
local retval=0 PKGFILE=${1##*/} #basename
head -c -32 "$REPO_DIR/$PKGFILE" > "$REPO_DIR/$PKGFILE".tar
PETPREFIX=$(tar -tf "$REPO_DIR/$PKGFILE".tar | head -1)
case "$PETPREFIX" in
"./"*) tar --strip=2 --directory=${CHROOT_DIR} -xf "$REPO_DIR/$PKGFILE".tar ;;
*) tar --strip=1 --directory=${CHROOT_DIR} -xf "$REPO_DIR/$PKGFILE".tar ;;
esac
retval=$?
if [ $retval -eq 0 ] && [ -f ${CHROOT_DIR}/pinstall.sh ] ; then
( cd ${CHROOT_DIR} ; sh pinstall.sh )
fi
rm -f "$REPO_DIR/$PKGFILE".tar
rm -f ${CHROOT_DIR}/pet.specs ${CHROOT_DIR}/pinstall.sh ${CHROOT_DIR}/puninstall.sh
return $retval
}

######## commands handler ########

Expand Down Expand Up @@ -395,7 +430,7 @@ flatten_pkglist() {
%exit) break ;;
%include)
[ "$2" ] && flatten_pkglist "$2" ;;
%bblinks|%makesfs|%remove|%addbase|%addpkg|%dummy|%cutdown|%import)
%pet|%bblinks|%makesfs|%remove|%addbase|%addpkg|%dummy|%cutdown|%import)
echo "$pp" ;;
%symlink|%rm|%mkdir|%touch|%chroot)
echo "$pp" ;;
Expand Down Expand Up @@ -509,6 +544,12 @@ process_pkglist() {
shift # $@ commands
chroot $CHROOT_DIR "$@"
;;
%pet)
shift
download_pet_pkg "$1"
[ "$DOWNLOAD_ONLY" ] && continue
install_pet_pkg "$1" || { echo Installation of ${1##*/} failed. && exit 1; }
;;

# anything else - install package
*)
Expand Down
3 changes: 2 additions & 1 deletion zwn/woof-distro/arm/devuan/ascii/basesfs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
# %rm file ... (-rf flag is always used)
# %mkdir dir ... (-p flag is always used)
# %touch file ...
# % %chroot command ...
# %chroot command ...
# %pet pet package url
#
# start with %pkgs_by_prio required. Otherwise start with libc6.
#
Expand Down

0 comments on commit 9724cf5

Please sign in to comment.