#!/bin/sh #A slightly modified version of mistfire's TazWoof: http://murga-linux.com/puppy/viewtopic.php?p=996352#996352 #180619-1a s243a a download failure shouldn't stop the build #180619-1b Keep track of sucfull and failed downloads #180619-1c Don't re download the file if it exists WEBSITE="http://mirror1.slitaz.org" DESKTOP="$1" curdir="$(pwd)" download_pkgs(){ pkgs="$1" PTRN="$(echo "^$pkgs-[0-9]" | sed -e "s#\+#\\\+#g")" pkgname="$(cat $curdir/slitaz-devx/packages.list | grep -E "$PTRN")" if [ "$pkgname" != "" ]; then if [ ! -f "$curdir/slitaz-devx/$pkgname.tazpkg" ]; then #180619-1c wget --timeout=10 $WEBSITE/packages/cooking/$pkgname.tazpkg -O $curdir/slitaz-devx/$pkgname.tazpkg if [ $? -ne 0 ]; then echo "Downloading package failed: $pkgname" #exit #180619-1 echo "$pkgname.tazpkg" >> "$curdir/slitaz-devx/packages.list.fail" #180619-1b else echo "$pkgname.tazpkg" >> "$curdir/slitaz-devx/packages.list.success" #180619-1b fi else echo "$pkgname.tazpkg" >> "$curdir/slitaz-devx/packages.list.success" #180619-1c fi fi } cleanup_TMP(){ #180619-1c rm -f $curdir/slitaz-devx/packages.list.fail rm -f $curdir/slitaz-devx/packages.list.success rm -f $curdir/slitaz-devx/packages.list rm -rf $curdir/temp-devx mkdir $curdir/temp-devx } cleanup_ROOTFS() { rm -rf $curdir/devx-rootfs } cleanup(){ rm -rf $curdir/slitaz-devx mkdir $curdir/slitaz-devx rm -rf $curdir/temp-devx mkdir $curdir/temp-devx rm -rf $curdir/devx-rootfs } extract_pkgdb(){ cd $curdir/slitaz-devx unlzma ./bundle.tar.lzma tar xvf ./bundle.tar packages.list tar xvf ./bundle.tar packages.info rm -f ./bundle.tar } download_pkgdb(){ wget --timeout=10 $WEBSITE/packages/cooking/bundle.tar.lzma -O $curdir/slitaz-devx/bundle.tar.lzma if [ $? -ne 0 ]; then echo "Downloading slitaz package database failed" exit fi } build_pkg_db(){ rm -f $curdir/slitaz-devx/packages.txt cat $curdir/slitaz-devx/packages.info | sed -e "s#\t#;#g" > $curdir/slitaz-devx/packages.txt } sniff_deps(){ pkg="$1" PTRN="$(echo "^$pkg;" | sed -e "s#\+#\\\+#g")" if [ "$pkg" == "" ]; then continue fi if [ ! -f $curdir/temp-devx/package-listed.txt ]; then echo "$pkg;" > $curdir/temp-devx/package-listed.txt elif [ "$(cat $curdir/temp-devx/package-listed.txt | grep -E "$PTRN")" == "" ]; then echo "$pkg;" >> $curdir/temp-devx/package-listed.txt else continue fi deps=$(cat $curdir/slitaz-devx/packages.txt | grep -E "$PTRN" | cut -f 8 -d ';') if [ "$deps" == "" ]; then continue fi #echo "$pkg: $deps" for dep in $deps do #echo "$dep" if [ "$dep" != "" ]; then xPTRN7="$(echo "^$dep;" | sed -e "s#\+#\\\+#g")" if [ -f $curdir/temp-devxlates/blocked-packages.txt ]; then blkinst="$(cat $curdir/temp-devxlates/blocked-packages.txt | grep -E "$xPTRN7")" fi if [ -f $curdir/temp-devxlates/slitaz-core.txt ]; then cldpkg="$(cat $curdir/temp-devxlates/slitaz-core.txt | grep -E "$xPTRN7")" fi if [ -f $curdir/temp-devxlates/puppy-core.txt ]; then puppkg="$(cat $curdir/temp-devxlates/puppy-core.txt | grep -E "$xPTRN7")" fi if [ "$blkinst" == "" ] && [ "$cldpkg" == "" ] && [ "$puppkg" == "" ]; then if [ ! -f $curdir/temp-devx/package-deps.txt ]; then echo "$dep;" > $curdir/temp-devx/package-deps.txt elif [ "$(cat $curdir/temp-devx/package-deps.txt | grep -E "$xPTRN7")" == "" ]; then echo "$dep;" >> $curdir/temp-devx/package-deps.txt fi sniff_deps "$dep" fi fi done } process_template(){ cat $curdir/templates/devx.txt | sed -e "s#;##g" | sort > $curdir/temp-devx/download-devx-packages.txt } process_package() { chksum="$(md5sum $1)" cpio -idm --quiet < "$1" && rm -f "$1" if [ -f fs.cpio.lzma ]; then unlzma < fs.cpio.lzma | cpio -idm --quiet && rm fs.cpio.lzma elif [ -f fs.cpio.gz ]; then zcat fs.cpio.gz | cpio -idm --quiet && rm fs.cpio.gz fi rm -f ./receipt > /dev/null rm -f ./md5sum > /dev/null rm -f ./files.list > /dev/null rm -f ./description.txt > /dev/null cp -arf ./fs/* ./ rm -rf ./fs } process_pkg_dir(){ if [ ! -d $curdir/devx-rootfs ]; then mkdir $curdir/devx-rootfs fi } install_packages(){ if [ ! -d $curdir/slitaz-devx ]; then echo "Devx tazpup package folder is missing." exit else if [ $(find $curdir/slitaz-devx -type f -name "*.tazpkg" | wc -l) -eq 0 ]; then echo "Tazpup package is missing." exit fi for pkg in $(find $curdir/slitaz-devx -type f -name "*.tazpkg" | sort -r) do echo "Processing package: $(basename $pkg)" cp -f $pkg $curdir/devx-rootfs/ cd $curdir/devx-rootfs/ process_package "$(basename $pkg)" done fi } fetch_pkg(){ for pkg in $(cat $curdir/temp-devx/download-devx-packages.txt) do download_pkgs "$pkg" done } make_sfs(){ mksquashfs "$curdir/devx-rootfs/" "devx_tazpup.sfs" -comp xz -Xbcj x86 -b 1M -Xdict-size 100% } #### MAIN #### cleanup download_pkgdb extract_pkgdb build_pkg_db process_template fetch_pkg process_pkg_dir install_packages make_sfs