#!/bin/sh
META_SUFFIX=tar.gz
# Init ths insaled package database
db_init() {
mkdir -p ${APKDB}
}
# Get description
db_get_description() {
local pkgv
pkgv=$1
if [ "$APK_COMPRESS" ] ; then
tar -zxf $APKDB/$pkgv.$META_SUFFIX -O ${pkgv}/DESC
else
cat $APKDB/$pkgv/DESC
fi
}
# All installed pacages
db_all_installed() {
local opwd i
opwd=`pwd`
cd ${APKDB}
if [ "$APK_COMPRESS" ] ; then
for i in *-[0-9]*.$META_SUFFIX ; do
basename $i .$META_SUFFIX
done
else
for i in *-[0-9]* ; do
[ -d "$i" ] && echo $i
done
fi
cd $opwd
}
############################################################
## all installed packages with description
#db_all_installed_with_desc() {
# local opwd
# opwd=`pwd`
# cd ${APKDB}
# for i in *.$META_SUFFIX ; do
# pkgv=`basename $i .$META_SUFFIX`
# echo -n -e "$pkgv\t"
# echo `db_get_description ${pkgv}`
# done
# cd $opwd
#}
##########################################################
# is package installed?
# returns pkgv or nothing if pkg is not installed
db_get_installed_pkgv() {
local p=$1
local regexp
if has_version $p ; then
regexp="^$p\$"
else
regexp="^$p-[0-9].*"
fi
db_all_installed | grep "$regexp"
}
############################################################
# get the package name and versions
#db_get_installed_pkgv() {
# local opwd wild
# opwd=`pwd`
# if has_version $1 ; ten
# wild="$1"
# else
# wild="$1-[0-9]*"
# fi
# cd ${APKDB}
# if [ "$APK_COMPRESS" ] ; then
# for i in $wild.$META_SUFFIX ; do
# basename $i .$META_SUFFIX
# done
# else
# for i in $wild ; do
# [ -d "$i" ] && echo $i
# done
# fi
# cd $opwd
#}
#
############################################################
#db_decompress_meta() {
# local metafile
# metafile=${APKDB}/${1}.$META_SUFFIX
# if [ ! -f $metafile ] ; then
# eecho "$1 does not seem to be installed. Did you specify version? Aborting."
# exit 1
# fi
# tar -C $APKDB -zxf $metafile
#}
#
#############################################################
#db_compress_meta() {
# local opwd metaball pkgv1
# opwd=`pwd`
# pkgv=$1
# metaball="${APKDB}/${pkgv}.$META_SUFFIX"
# cd $APKDB
# rm -f ${metaball}
# metas=${pkgv}
# if [ -z "$metas" ] ; then
# eecho "No meta files were found. Aborting."
# exit 1
# fi
# tar -czf ${metaball} ${metas}
# rm -rf ${metas}
# cd $opwd
#}
#
#############################################################
#db_pkgv_metafile() {
# local opwd pkgv
# opwd=`pwd`
# pkgv=$1
# cd ${APKDB}
# tar -zxf ${pkgv}.$META_SUFFIX -O ${pkgv}/$2
# cd $opwd
#}
#
#db_pkgv_listfiles() {
# db_pkgv_metafile $1 CONTENTS
#}
#
#
#db_pkgv_backupfiles() {
# db_pkgv_metafile $1 BACKUPFILES
#}
#
############################################################
## create sha1 sum of package files
## Needs the meta to be in $APK_TMPDIR
#create_sha1sum() {
# local sha1file listfile opwd
# opwd=`pwd`
# listfile=${APK_TMPDIR}/${1}/CONTENTS
# sha1file=${APK_TMPDIR}/${1}/SHA1
# cd $ROOT
# rm -f ${sha1file}
# while read i ; do
# [ -f ${i} ] && sha1sum ${i} >> ${sha1file}
# done < ${listfile}
# cd $opwd
#}
#
#
############################################################
## Create sha1 sum of backup files
#create_backup_sha1sum() {
# local sha1file listfile opwd
# opwd=`pwd`
# listfile=${APK_TMPDIR}/${1}/BACKUPFILES
# # if there is no config file, just return
# [ ! -f $listfile ] && return
# sha1file=${APKDB}/${1}.cfg.sha1
# cd ${ROOT}
# rm -f ${sha1file}
# while read i ; do
# [ -f ${i} ] && sha1sum ${i} >> ${sha1file}
# done < ${listfile}
# cd $opwd
#}
#
#