Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #jlst 2014
- case $0 in
- /usr/sbin/pacman) aconfig='/zz/aconfig' ;;
- /*) aconfig=${0%/*}'/aconfig' ;; #full path
- ./*) aconfig=${0%/*}'/aconfig' ;; #./
- *) aconfig=./aconfig ;; #...
- esac
- curdir=${PWD}
- cd ${aconfig%/*}
- . $aconfig
- [ ! "$SETUPDIR" ] && SETUPDIR='.'
- export INSTALLED
- export SETUPDIR
- #echo $INSTALLED; echo $SETUPDIR ; exit
- function GeneratePecSpecsByName() {
- file="$@"
- tarfile=${file##*/} #"$(basename "$file")"
- rootname=${tarfile%.tar.*}
- rootname=${rootname%.pet}
- pkgname=${rootname%%\-[0-9]*} #first match onwards: -X* where X is a number
- if [ "$pkgname" = "$rootname" ] ; then
- pkgname="${rootname%%\-*}" #the old way, easy way
- fi
- pkgversion="${rootname#${pkgname}\-}"
- pkgversion="${pkgversion//-*}"
- specs="${rootname}|${pkgname}|${pkgversion}||BuildingBlock|K||${tarfile}||||||"
- echo $specs
- }
- function Builtin() {
- pkg="$1"
- case $pkg in
- /*) echo -n ;;
- *) pkg=${SETUPDIR}/builtin_files/${pkg} ;;
- esac
- if [ -f "$pkg" ] ; then
- echo $pkg #if pkg exists, return pkg name
- return 0
- else
- #now try with woof-installed-packages
- return 1
- fi
- }
- #Returns full list, can be used in a pipe or stored in a variable
- function BuiltinList() {
- . ${SETUPDIR}/DISTRO_PKGS_SPECS
- pkgs=$(echo "$PKGS_SPECS_TABLE" | \
- sed -e '/^no|/d' -e 's/#.*//')
- SFI=$IFS
- IFS='|'
- while read line; do
- specsinfo=${line//||/|~|}
- specsinfo=${specsinfo//||/|~|}
- x=1
- for field in $specsinfo ; do
- [ "$field" = "~" ] && field=''
- case $x in
- #1) yesno=${field} ;;
- #2) genericpkgname=${field} ;;
- #3) pkgnames=${field} ;;
- #4) splitup=${field} ;;
- #5) repo=${field} ;;
- 2) echo ${field} ;;
- 3) [ "$field" ] && echo ' '${field//,/
- }
- esac
- let x++
- done
- done <<< "$pkgs"
- IFS=$SFI
- }
- function InstalledList() {
- filez="$(cat ${SETUPDIR}/woof-installed-packages)"
- SFI=$IFS
- IFS='|'
- (
- while read line; do
- pkginfo=${line//||/|~|}
- pkginfo=${pkginfo//||/|~|}
- x=1
- for field in $pkginfo ; do
- [ "$field" = "~" ] && field=''
- case $x in
- #1) pkgname=${field} ;;
- 2) nameonly=${field} ;;
- #3) version=${field} ;;
- #4) pkgrelease=${field} ;;
- #5) category=${field} ;;
- #6) size=${field} ;;
- #7) path=${field} ;;
- #8) fullfilename=${field} ;;
- #9) dependencies=${field} ;;
- 10) description=${field} ;;
- #11) compileddistro=${field} ;;
- #12) compiledrelease=${field};;
- #13) repo=${field} ;;
- esac
- let x++
- done
- #first field must have 40 chars wide
- length=${#nameonly}
- echo -n ${nameonly}
- for ((x=$length ; x<=40 ; x++ )) ; do echo -n ' ' ; done
- echo $description
- done <<< "$filez"
- ) > builtin.installed.txt
- IFS=$SFI
- geany builtin.installed.txt &
- }
- function BuiltinFiles() {
- pkg="$(Builtin $1)"
- if [ "$pkg" ] ; then
- x=0
- while read line; do
- case $line in
- /*) lastdir=$line ;;
- *)
- let x++
- echo "${lastdir}/${line}"
- ;;
- esac
- done < $pkg
- if [ $x -eq 0 ] ; then
- cat "$pkg" 2>/dev/null
- fi
- return 0
- else
- return 1
- fi
- }
- function CheckFiles() {
- files=$(BuiltinFiles $1)
- while read file; do
- [ ! "$file" ] && continue
- echo -n "$file... "
- if [ -e "$file" ] ; then
- echo "ok"
- else
- echo "error"
- fi
- done <<< "$files"
- }
- function Puppy2Info() {
- local specs="$@"
- pkginfo=${specs//||/|~|}
- pkginfo=${pkginfo//||/|~|}
- SFI=$IFS
- IFS='|'
- x=1
- for field in $pkginfo ; do
- [ "$field" = "~" ] && field=''
- case $x in
- #1) [ "$field" ] && echo pkgname=${field} ;;
- 2) [ "$field" ] && echo nameonly=${field} ;;
- 3) [ "$field" ] && echo version=${field} ;;
- 4) [ "$field" ] && echo pkgrelease=${field} ;;
- 5) [ "$field" ] && echo category=${field} ;;
- 6) [ "$field" ] && echo size=${field} ;;
- 7) [ "$field" ] && echo path=${field} ;;
- 8) [ "$field" ] && echo fullfilename=${field} ;;
- 9) [ "$field" ] && echo dependencies=${field} ;;
- 10) [ "$field" ] && echo description=${field} ;;
- 11) [ "$field" ] && echo compileddistro=${field};;
- 12) [ "$field" ] && echo compiledrelease=${field};;
- 13) [ "$field" ] && echo repo=${field} ;;
- esac
- let x++
- done
- IFS=$SFI
- }
- function BuiltinSpecs() {
- pkg="$(Builtin $1)"
- if [ "$pkg" ] ; then
- name=${pkg##*/}
- grep -m 1 "|${name}|" ${SETUPDIR}/woof-installed-packages
- return 0
- else
- return 1
- fi
- }
- function BuiltinSpecs2() {
- pkg="$(Builtin $1)"
- if [ "$pkg" ] ; then
- name=${pkg##*/}
- grep "|${name}|" ${SETUPDIR}/woof-installed-packages ${SETUPDIR}/DISTRO_PKGS_SPECS
- #grep "|${name}|" ${SETUPDIR}/DISTRO_PKGS_SPECS
- return 0
- else
- return 1
- fi
- }
- function BuiltinExport() {
- BuiltinSpecs="$(BuiltinSpecs $1)"
- if [ "$BuiltinSpecs" ] ; then
- pkgdir=${BuiltinSpecs%%|*}
- #echo $pkgdir
- mkdir -p $pkgdir
- echo "$BuiltinSpecs" > ${pkgdir}/pet.specs
- BuiltinFiles="$(BuiltinFiles $1)"
- while read file ; do
- if [ -f "$file" ] ; then
- filedir=${file%/*}
- targetdir=${pkgdir}${filedir}
- [ ! -d "$targetdir" ] && mkdir -p "$targetdir"
- cp -a -v --remove-destination "$file" "$targetdir"
- fi
- done <<< "$BuiltinFiles"
- tar -zcf ${pkgdir}.tar.gz ${pkgdir}
- rm -rf ${pkgdir}
- else
- echo "Error: '$1' pkg does not exist "
- return 1
- fi
- }
- function BuiltinInfo() {
- Puppy2Info "$(BuiltinSpecs $1)"
- }
- function PkgInfo() {
- pkg="$1"
- if [ -f ${SETUPDIR}/installedpkgs/${pkg} ] ; then
- read -r specs < ${SETUPDIR}/installedpkgs/${pkg}
- Puppy2Info "$specs"
- else
- specs=$(DistroSearch "|$pkg|")
- if [ "$specs" ] ; then
- echo "** NOT INSTALLED **"
- Puppy2Info "$specs"
- fi
- fi
- }
- function PkgDeps() {
- pkg=$1
- if [ -f ${SETUPDIR}/installedpkgs/${pkg} ] ; then
- read -r specs < ${SETUPDIR}/installedpkgs/${pkg}
- else
- specs=$(DistroSearch "|$pkg|")
- if [ "$specs" ] ; then
- echo "** NOT INSTALLED **"
- else
- return 1
- fi
- fi
- pkginfo=${specs//||/|~|}
- pkginfo=${pkginfo//||/|~|}
- SFI=$IFS ; IFS='|' ; x=1
- for field in $pkginfo ; do
- [ "$field" = "~" ] && field=''
- case $x in 9) [ "$field" ] && dependencies=${field} && break ;; esac
- let x++
- done
- IFS=$SFI
- if [ "$dependencies" ] ; then
- echo "$dependencies" | sed -e "s/\,/\n/g" | sed -e 's/^+//' -e 's/&.*//'
- else
- echo "* No dependencies specified..."
- fi
- }
- function CheckDeps() {
- (
- PkgDeps $1 | while read dep ; do
- if [ -f "${SETUPDIR}/installedpkgs/${dep}" ] ; then
- echo "$dep ... ok"
- elif [ -f "${SETUPDIR}/builtin_files/${dep}" ] ; then
- echo "$dep ... ok (generic puppy pkg name)"
- else
- echo "$dep ... missing"
- fi
- done
- ) | sort -u
- }
- function CheckDepsTree() {
- pkg=$1
- echo -n > packages.checked
- echo -n > packages.tocheck
- echo -n > packages.missing
- echo -n > packages.log
- while true ; do
- echo "checking: $pkg"
- echo "$pkg" >> packages.log
- PkgDeps $pkg | while read dep ; do
- echo " $dep" >> packages.log
- echo "$dep" >> packages.tocheck
- if [ -f "${SETUPDIR}/installedpkgs/${dep}" ] ; then
- echo -n
- elif [ -f "${SETUPDIR}/builtin_files/${dep}" ] ; then
- echo -n
- else
- echo "$dep" >> packages.missing
- fi
- done
- echo "$pkg" >> packages.checked
- while true ; do
- sed -i -e '/\*/d' packages.tocheck
- pkg="$(sed -n '1p' packages.tocheck)"
- #sed -i '1d' packages.tocheck
- sed -i -e "/^${pkg}$/d" packages.tocheck
- case "$pkg" in *\**) continue ;; esac
- [ ! "$(grep "^${pkg}$" packages.checked)" ] && break
- done
- if [ ! "$pkg" ] ; then
- break
- fi
- done
- sort -u packages.missing | grep -v '\*' > packages.missing2
- mv -f packages.missing2 packages.missing
- sort -u packages.checked | grep -v '\*' > packages.checked2
- mv -f packages.checked2 packages.checked
- rm -f packages.tocheck
- echo
- echo "* These packages are not installed: "
- while read line ; do echo ' '$line ; done < packages.missing
- }
- function BuiltinRemoveSpecs() { #<pkg>
- # Remove generic names only
- # woof-installed-packages contains all the installed packages
- # but won't be able to know what
- # packages belong to a specific generic name, already removed...
- local name=$1
- sed -i "/|${name}|/d" ${SETUPDIR}/DISTRO_PKGS_SPECS
- sed -i "/|${name}|/d" ${SETUPDIR}/woof-installed-packages
- # This can be useful only to generate a new puppy in woof
- }
- function BuiltinRemoveFiles() { #<pkg>
- pkg="$(Builtin $1)"
- if [ "$pkg" ] ; then
- while read line; do
- case $line in
- /*) lastdir=$line ;;
- *) rm -fv "${lastdir}/${line}" ;;
- esac
- done < $pkg
- #name=${pkg##*/}
- #BuiltinRemoveSpecs $name
- rm -fv $pkg
- return 0
- else
- echo "Error: '$1' pkg does not exist "
- return 1
- fi
- }
- function FileBytes() {
- echo "$(stat -c%s "$@")"
- }
- function FileKB() {
- bytes="$(stat -c%s "$@")"
- echo "$((bytes/1024))"'KB'
- }
- ####################
- #################### Builtin Install
- ####################
- # This converts a file list to the format in /root/.packages/builtin_files/
- function TarFilelist2Builtin() {
- while read file ; do
- [[ $file == */ ]] && file=${file%/} #no trailing slash
- if [ -f "$file" ] ; then
- echo ' '${file##*/} #basename $file
- else
- echo $file
- fi
- done
- }
- function Pkg2Builtin() {
- local file="$@"
- [ ! "$file" ] && echo "* ERROR: no file provided..." && return 1
- [ ! -f "$file" ] && echo "* ERROR: $file does not exist" && return 1
- case "$file" in
- *.tar.gz|*.pet) echo -n ;;
- *) echo "* ERROR: Only *.tar.gz and *.pet allowed" && return 1
- esac
- tarlist="-ztf"
- tardecomp="-z -x --strip=1 -f"
- filelist="$(tar $tarlist "$file" 2>/dev/null)" #; echo "$filelist"
- tarfile=${file##*/} #"$(basename "$file")"
- rootname=${tarfile%.tar.*}
- rootname=${rootname%.pet}
- pkgname=${rootname%%\-[0-9]*} #first match onwards: -X* where X is a number
- if [ "$pkgname" = "$rootname" ] ; then
- pkgname="${rootname%%\-*}" #the old way, easy way
- fi
- pkgversion="${rootname#${pkgname}\-}"
- pkgversion="${pkgversion//-*}"
- ## /root/.packages/builtin_files/ - only stores generic names, which can have many packages
- #if [ -f /root/.packages/builtin_files/${pkgname} ] ; then
- # echo "* Pkg: '$pkgname' is already installed, replacing..."
- # sed -i -e "/|${pkgname}|/d" /root/.packages/woof-installed-packages
- #fi
- ## This is the correct method...
- #if [ "$(grep -m 1 "|${pkgname}|" /root/.packages/woof-installed-packages)" ] ; then
- # echo "* Pkg: '$pkgname' is already installed, replacing..."
- # PKGINSTALLED="TRUE"
- #fi
- tar --directory="/" $tardecomp "$file"
- if [ -f /pet.specs ] ; then
- read -r specs < /pet.specs
- #specs="$(cat /pet.specs | head -1)"
- else
- specs="${rootname}|${pkgname}|${pkgversion}||BuildingBlock|K||${tarfile}||||||"
- fi
- if [ "$PKGINSTALLED" ] ; then
- sed -i -e "s/.*|${pkgname}|.*/${specs}/" /root/.packages/woof-installed-packages
- else
- echo "$specs" >> /root/.packages/woof-installed-packages
- fi
- [ -f /pinstall.sh ] && sh /pinstall.sh
- rm -f /pet.specs /pinstall.sh /puninstall.sh
- echo "$filelist" | \
- sed -e "s%^${rootname}%%" | grep -v -E '^/$|pet.specs|pinstall.sh|puninstall.sh' | \
- TarFilelist2Builtin > /root/.packages/builtin_files/${pkgname}
- }
- #$woofdir - this must be exported by the calling script
- #"$@" - txt filelist
- function InstallPkgs2Woof() {
- filez="$@"
- [ ! -f "$filez" ] && echo "* ERROR: no file or invalid txt file..." && return 1
- if [ ! "$woofdir" ] ; then
- echo '==============================================='
- echo '[FATAL] You must export the variable $woofdir'
- echo ' example: export woofdir="/initrd/mnt/dev_ro2/precise5.7.1retro"'
- echo '==============================================='
- return 1
- fi
- cat "$filez" | sort -u | while read file; do
- echo "* Processing: $file"
- tarlist="-ztf"
- tardecomp="-z -x --strip=1 -f"
- filelist="$(tar $tarlist "$file" 2>/dev/null)" #; echo "$filelist"
- tarfile=${file##*/} #"$(basename "$file")"
- rootname=${tarfile%.tar.*}
- rootname=${rootname%.pet}
- pkgname=${rootname%%\-[0-9]*} #first match onwards: -X* where X is a number
- if [ "$pkgname" = "$rootname" ] ; then
- pkgname="${rootname%%\-*}" #the old way, easy way
- fi
- pkgversion="${rootname#${pkgname}\-}"
- pkgversion="${pkgversion//-*}"
- tar --directory=${woofdir} $tardecomp "$file"
- if [ -f "${woofdir}/pinstall.sh" ] ; then
- sed -e '/^#\!\/bin/d' ${woofdir}/pinstall.sh >> ${woofdir}/pinstall.final
- fi
- if [ -f ${woofdir}/pet.specs ] ; then
- read -r specs < ${woofdir}/pet.specs
- else
- specs="${rootname}|${pkgname}|${pkgversion}||BuildingBlock|??K||${tarfile}||||||"
- fi
- if [ "$PKGINSTALLED" ] ; then
- sed -i -e "s/.*|${pkgname}|.*/${specs}/" ${woofdir}/root/.packages/woof-installed-packages
- else
- echo "$specs" >> ${woofdir}/root/.packages/woof-installed-packages
- fi
- rm -f ${woofdir}/pinstall.sh ${woofdir}/puninstall.sh ${woofdir}/pet.specs
- echo "$filelist" | sort | \
- sed -e "s%^${rootname}%%" | grep -v -E '^/$|pet.specs|pinstall.sh|puninstall.sh' | \
- while read zzfile ; do
- [[ $zzfile == */ ]] && zzfile=${zzfile%/} #no trailing slash
- if [ -f "${woofdir}/$zzfile" ] ; then
- echo ' '${zzfile##*/} #basename $zzfile
- else
- echo $zzfile
- fi
- done > ${woofdir}/root/.packages/builtin_files/${pkgname}
- #-
- done
- chroot $woofdir sh pinstall.final
- }
- #############################################
- ######### ZZNET STUFF #########
- #############################################
- scriptdir=${aconfig%/*}
- export netfile="${scriptdir}/woofnet.blacklist"
- export WOOFFILES="${SETUPDIR}/Packages-puppy-4-official
- ${SETUPDIR}/Packages-puppy-5-official
- ${SETUPDIR}/Packages-puppy-common-official
- ${SETUPDIR}/Packages-puppy-noarch-official
- ${SETUPDIR}/Packages-puppy-precise-official
- ${SETUPDIR}/Packages-puppy-quirky-official
- ${SETUPDIR}/Packages-puppy-wary5-official
- ${SETUPDIR}/DISTRO_PKGS_SPECS"
- #export WOOFFILES="${SETUPDIR}/DISTRO_PKGS_SPECS" #Testing...
- function RemoveBuiltinFilesBL() {
- #try both generic and global
- REMOVEPKGS=$(grep -E '^GENERIC |^GLOBAL ' $netfile |
- sed -e 's/^GENERIC //' \
- -e 's/^GLOBAL //' \
- -e '/^#/d' \
- -e '/^$/d' \
- -e 's/ .*//' \
- -e "s/\t.*//" | sort -u)
- for PKG in $REMOVEPKGS ; do
- BuiltinRemoveFiles $PKG
- done
- echo
- }
- function WoofRemoveGenericPkgs() {
- echo "Now going to remove GENERIC matches"
- echo "=================================="
- REMOVEPKGS=$(grep '^GENERIC ' $netfile |
- sed -e 's/^GENERIC //' \
- -e '/^#/d' \
- -e '/^$/d' \
- -e 's/ .*//' \
- -e "s/\t.*//" | sort -u)
- while read file ; do
- tmpfile="${file}.2"
- echo "* Fixing $file"
- (
- while read line ; do
- found=0
- for PKG in $REMOVEPKGS ; do
- [ ! "$PKG" ] && continue
- WPKG="*|${PKG}|*"
- [[ $line == $WPKG ]] && found=1 && break #ignore this line
- done
- [ $found -eq 0 ] && echo $line
- done < "$file"
- ) > $tmpfile
- mv -f $tmpfile $file
- done <<< "$WOOFFILES"
- echo
- }
- function WoofRemoveGlobalMatch() {
- echo "Now going to remove GLOBAL matches"
- echo "=================================="
- REMOVEPKGS=$(grep '^GLOBAL ' $netfile | \
- sed -e 's/^GLOBAL //' \
- -e '/^#/d' \
- -e '/^$/d' \
- -e 's/ .*//' \
- -e "s/\t.*//" | sort -u)
- while read file ; do
- tmpfile="${file}.2"
- echo "* Fixing $file"
- (
- while read line ; do
- found=0
- for PKG in $REMOVEPKGS ; do
- [ ! "$PKG" ] && continue
- #WPKG="*|${PKG}|*"
- WPKG="*${PKG}*"
- [[ $line == $WPKG ]] && found=1 && break #ignore this line
- done
- [ $found -eq 0 ] && echo $line
- done < "$file"
- ) > $tmpfile
- mv -f $tmpfile $file
- done <<< "$WOOFFILES"
- echo
- }
- ###############################################################
- # Extract all info from woof-installed-packages
- function GenerateInstalledPkgs() {
- echo "* Generating list of installed packages..."
- pkgsdir=${SETUPDIR}/installedpkgs
- mkdir -p ${pkgsdir}
- rm -f ${pkgsdir}/*
- SFI=$IFS ; IFS='|'
- FILESW="${SETUPDIR}/woof-installed-packages|${SETUPDIR}/devx-only-installed-packages"
- for FILEW in ${FILESW} ; do
- while read line ; do
- specs="$line"
- pkginfo=${specs//||/|~|}
- pkginfo=${pkginfo//||/|~|}
- x=1
- for field in $pkginfo ; do
- [ "$field" = "~" ] && field=''
- case $x in 2) [ "$field" ] && nameonly=${field} && break ;; esac
- let x++
- done
- [ "${nameonly}" ] && echo "$specs" > ${pkgsdir}/${nameonly}
- done < ${FILEW}
- done
- IFS=$SFI
- ls ${pkgsdir} > ${pkgsdir}.txt
- }
- function GenPackagesPuppy() {
- cd ${SETUPDIR}
- SFI=$IFS ; IFS='|'
- echo -n > packages.puppy
- ls Packages-puppy-* 2>/dev/null | sed -e '/puppy-2/d' -e '/puppy-3/d' | \
- while read puppyfile ; do
- (
- while read line ; do
- specs="$line"
- pkginfo=${specs//||/|~|}
- pkginfo=${pkginfo//||/|~|}
- x=1
- for field in $pkginfo ; do
- [ "$field" = "~" ] && field=''
- case $x in 2) [ "$field" ] && nameonly=${field} && break ;; esac
- let x++
- done
- [ "${nameonly}" ] && echo ${nameonly} $puppyfile
- done < $puppyfile
- ) >> packages.puppy
- done
- IFS=$SFI
- }
- function BuiltinSearch() {
- [ ! "$1" ] && echo "need <searchterm>" && return 1
- grep "$@" ${pkgsdir}.txt | while read pkg ; do
- echo "${pkg}... installed"
- done
- return $?
- }
- function SearchFile() {
- [ ! "$1" ] && echo "need <searchterm>" && return 1
- grep "$@" ${SETUPDIR}/builtin_files/*
- return $?
- }
- ## Generate GenericNames from Packages-distro-*
- function DistroIndex() {
- echo "* Generting index of distro packages..."
- . /etc/DISTRO_SPECS
- SFI=$IFS ; IFS='|'
- ls ${SETUPDIR}/Packages-${DISTRO_BINARY_COMPAT}-* | \
- grep -v 'index' | \
- while read file ; do
- echo "Processing: $file"
- (
- while read line ; do
- specs="$line"
- pkginfo=${specs//||/|~|}
- pkginfo=${pkginfo//||/|~|}
- x=1
- for field in $pkginfo ; do
- [ "$field" = "~" ] && field=''
- case $x in 2) [ "$field" ] && nameonly=${field} && break ;; esac
- let x++
- done
- echo ${nameonly}
- #echo "$specs"
- done < $file
- ) > ${file}.index
- done
- IFS=$SFI
- }
- # Quick search in distro generated index files
- function DistroSearchIndex() {
- . /etc/DISTRO_SPECS
- filez=$(ls ${SETUPDIR}/Packages-${DISTRO_BINARY_COMPAT}-* | grep 'index')
- grep "$@" $filez | \
- sed -e "s%${SETUPDIR}/%%" \
- -e 's|.index||' \
- -e 's|Packages-||'
- }
- function DistroSearch() {
- . /etc/DISTRO_SPECS
- filez=$(ls ${SETUPDIR}/Packages-${DISTRO_BINARY_COMPAT}-* | grep -v 'index')
- grep "$@" $filez | sed -e 's|.*:||' | sort
- }
- ### This is specifically to add all packages info specifiec in pkgs/
- function zznetpackages() {
- cd ${aconfig%/*}
- pkgs=$(ls pkgs)
- for ONEPKG in $pkgs ; do
- filelist="$(cat pkgs/$ONEPKG | sed '/^#/d')"
- pkg=${ONEPKG##*/} #"$(basename "$file")"
- rootname=${pkg%.tar.*}
- rootname=${rootname%.pet}
- pkgname=${rootname%%\-[0-9]*} #first match onwards: -X* where X is a number
- if [ "$pkgname" = "$rootname" ] ; then
- pkgname="${rootname%%\-*}" #the old way, easy way
- fi
- pkgversion="${rootname#${pkgname}\-}"
- pkgversion="${pkgversion//-*}"
- size=0
- while read file ; do
- filesize=$(stat -c%s "$file")
- size=$((size+filesize))
- done <<< "$filelist"
- size=$((size/1024))
- specs="${rootname}|${pkgname}|${pkgversion}||BuildingBlock|${size}K||${pkg}.pet||_${pkgname}_||||"
- sed -i "/|${pkgname}|/d" ${SETUPDIR}/woof-installed-packages
- echo "$specs" >> ${SETUPDIR}/woof-installed-packages
- echo "$filelist" > ${SETUPDIR}/builtin_files/${pkgname}
- done
- sort -u ${SETUPDIR}/woof-installed-packages > ${SETUPDIR}/woof-installed-packages.2
- mv -fv ${SETUPDIR}/woof-installed-packages.2 ${SETUPDIR}/woof-installed-packages
- }
- # This gathers information from DISTRO_PKGS_SPECS
- function PackageByGenericName() {
- . ${SETUPDIR}/DISTRO_PKGS_SPECS
- pkgs=$(echo "$PKGS_SPECS_TABLE" | \
- sed -e '/^#.*/d' \
- -e 's/#.*//' \
- -e '/^no/d' | \
- grep "|$1|")
- SFI=$IFS
- IFS='|'
- while read line; do
- specsinfo=${line//||/|~|}
- specsinfo=${specsinfo//||/|~|}
- x=1
- for field in $specsinfo ; do
- [ "$field" = "~" ] && field=''
- case $x in
- #2) echo ${field} ;;
- 3)
- if [ "$field" ] ; then
- packages=${field//,/|}
- for package in $packages ; do
- echo ' '${package}
- done
- fi
- ;;
- esac
- let x++
- done
- done <<< "$pkgs"
- IFS=$SFI
- }
- #####################################################
- #remaster stuff
- case "$1" in
- -zzremove)
- cd ${aconfig%/*}
- RemoveBuiltinFilesBL #1
- WoofRemoveGlobalMatch #2
- WoofRemoveGenericPkgs #3
- exit
- ;;
- esac
- #####################################################
- export pkgsdir=${SETUPDIR}/installedpkgs
- if [ ! -d "${pkgsdir}" ] || [ ! -f "${pkgsdir}.txt" ] ; then
- echo "Initializing $0 ..."
- DistroIndex
- GenerateInstalledPkgs
- fi
- #####################################################
- case "$1" in
- -export)
- [ ! "$2" ] && echo "* Syntax: $0 -export <pkg>" && exit
- BuiltinExport "$2"
- ;;
- -pkginfo) PkgInfo $2 ;;
- -pkgdeps) PkgDeps $2 ;;
- -checkdeps) CheckDeps $2 ;;
- -checkdepstree) CheckDepsTree $2 ;;
- -info)
- [ ! "$2" ] && echo "* Syntax: $0 -info <pkg>" && exit
- BuiltinInfo "$2"
- ;;
- -fullinfo)
- ( BuiltinInfo $2 ; BuiltinFiles $2 ) | more
- ;;
- -files)
- [ ! "$2" ] && echo "* Syntax: $0 -files <pkg>" && exit
- BuiltinFiles "$2"
- [ $? -ne 0 ] && echo "* ERROR: '$2' is not a builtin pkg"
- ;;
- -checkfiles) CheckFiles "$2" ;;
- -specs) BuiltinSpecs2 $2 ;;
- -installed) InstalledList ;;
- -list) BuiltinList > builtin.list ;;
- -listinfo)
- ;;
- -remove)
- [ ! "$2" ] && echo "* Syntax: $0 -remove <pkg>" && exit
- BuiltinRemoveFiles $2
- BuiltinRemoveSpecs $2
- ;;
- -install) shift; Pkg2Builtin "$@" ;;
- -install2woof) shift; InstallPkgs2Woof "$@" ;;
- -search) shift; BuiltinSearch "$@" ;;
- -searchfile) shift; SearchFile "$@" ;;
- -gen) GenerateInstalledPkgs ;;
- -genpuppy) GenPackagesPuppy ;;
- -distroindex) DistroIndex ;;
- -distrosearch) shift; DistroSearch "$@" ;;
- -distrosindex) shift; DistroSearchIndex "$@" ;;
- #-init) PacmanInit ;;
- -pkgbygeneric) PackageByGenericName $2 ;;
- ########## zznet stuff
- -removebl) WoofRemoveGenericPkgs ;;
- -removegbl) WoofRemoveGlobalMatch ;;
- -removefilesbl) RemoveBuiltinFilesBL ;;
- -net)
- #cd ${aconfig%/*}
- #RemoveBuiltinFilesBL #1
- #WoofRemoveGlobalMatch #2
- #WoofRemoveGenericPkgs #3
- echo "*** Now zznetpackages ***"
- zznetpackages #4
- echo "*** Finished zznetpackages ***"
- ;;
- -zznetpackages)
- zznetpackages
- ;;
- -ubuntufiller)
- while read pkg; do
- specs=$(DistroSearch "|$pkg|")
- if [ "$specs" ] ; then
- echo "$specs" > ${SETUPDIR}/installedpkgs/${pkg}
- echo "$specs" >> ${SETUPDIR}/woof-installed-packages
- else
- echo "* $pkg is not in distro database..."
- fi
- done < woofnet.ubuntu.fillers
- ;;
- #No args, no action, completely silent
- "") echo -n ;;
- #args provided, but not recognized...
- *) echo "${0##*/}: '$1' unrecognized command " ;;
- esac
- ### END ###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement