diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a0bafdb --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ + +PREFIX=/usr +BINDIR=${PREFIX}/bin + +DEST= + +all: + @echo "make install" + +install: + @mkdir -vp ${DEST}${BINDIR} + @cp -vax iee-alpha bee-alpha beefind.pl ${DEST}${BINDIR} diff --git a/bee-alpha b/bee-alpha new file mode 100755 index 0000000..67fb0d8 --- /dev/null +++ b/bee-alpha @@ -0,0 +1,412 @@ +#!/bin/bash +set -e + +PKGDIR=/usr/src/bee/pkgs +SKIPLIST=/etc/bee.skiplist + +#root dir for bee +BEEROOT=/tmp/beeroot + +BEESTORE=/usr/src/bee/bees + +TEMPDIR=/tmp + +#architecture +ARCH=$(arch) + +#load default files +BEEFAULTS=/etc/bee.defaults + +############################################################################### +############################################################################### +############################################################################### + +#### init() ################################################################### + +init() { + pname=$1 + surl=$2 + + if [ -z ${pname} ] ; then + echo "$0 -i [url]" + echo "$0 -i " + exit + fi + + if [ -z ${surl} ] ; then + surl=${pname} + pname=$(basename $(basename ${surl} .tar.bz2) .tar.gz) + if [ ${pname} = ${surl} ] ; then + surl="" + else + pname=${pname}-0 + fi + fi + + echo "creating ${pname}.bee with default SRCURL='${surl}'" + + cat >${pname}.bee <> ${D}/META + echo "PVF=${PVF}" >> ${D}/META + echo "PR=${PR}" >> ${D}/META + echo "PGRP=( ${PGRP} )" >> ${D}/META +} + +#### show_help() ############################################################## + +show_help() { + echo "create .bee file with 2 entries .." + echo " #!/bin/env be-alpha" + echo " SRCURL=\"http:// ..\"" + + echo + echo "follwing entries are optional .." + echo " PGRP=( 'group 1' .. )" + echo " EXCLUDE=\"regex1 ..\"" + echo " SKIPLIST=\"path/to/skiplist\"" +} + +# args: $PATH $PATTERN + +#### get_bee_list() ########################################################### + +get_bee_list() { + PATH=${BEESTORE} + PATTERN=.*\.bee + + HITS=$(find ${PATH} -maxdepth 1 -mindepth 1 -iregex "${PATH}/${PATTERN}$") + + echo $HITS +} + +#### print_bee_list() ######################################################### + +# args: $LIST +print_bee_list() { + LIST=$@ + + for l in $LIST ; do + if [ -z "$DIR" ] ; then + DIR=$(dirname $l) + echo $DIR + fi + if [ "$DIR" != "$(dirname $l)" ] ; then + DIR=$(dirname $l) + echo $DIR + fi + echo " - $(basename ${l})" + done +} + +#### bee_init_builddir() ###################################################### + +bee_init_builddir() { + if [ -d ${W} ] ; then + if [ "${OPT_FORCE}" = "yes" ] ; then + echo "cleaning work-dir ${W} .." + rm -fr ${W} + else + echo "error initializing build-dir ${W}" + exit 1 + fi + fi + mkdir -p ${S} + mkdir -p ${B} + mkdir -p ${D} +} + +#### bee_getsources() ######################################################### + +bee_getsources() { + for s in ${SRCURL} ; do + bs=$(basename ${s}) + mkdir -p "${F}" + echo "fetching source ${F}/${bs} .." + wget \ + --no-check-certificate \ + --output-document="${F}/${bs}" \ + --quiet \ + --no-clobber \ + "${s}" || true + #archive + A="${A:+ }${bs}" + done +} + +#### bee_unpack() ############################################################# + +bee_unpack() { + for s in ${A} ; do + echo "unpacking source ${s} .." + tar xof ${F}/${s} --strip-components 1 -C ${S} + done +} + +#### bee_patch() ############################################################## + +bee_patch() { + for p in ${PATCHES} ; do + patch -Np1 -i ${p} + done +} + +#### bee_configure() ########################################################## + +bee_configure() { + echo "configuring .." + echo " => ${S}/configure ${DEFCONFIG} \"$@\"" + ${S}/configure ${DEFCONFIG} "$@" +} + +#### bee_build() ############################################################## + +bee_build() { + make "$@" +} + +#### bee_install() ############################################################ + +bee_install() { + make install DESTDIR=${D} "$@" +} + +#### bee_pkg_pack() ########################################################### + +# $EXCLUDE is read from .bee file +# $SKIPLIST is found in $BEEFAULTS +bee_pkg_pack() { + for e in ${EXCLUDE} ; do + exargs="${exargs} --exclude=${e}"; + done + + beefind.pl --excludelist=${SKIPLIST} \ + --exclude='^/FILES$' ${exargs} \ + --cutroot=${D} ${D} > ${D}/FILES 2>/dev/null + + DUMP=${TEMPDIR}/bee.$$.dump + + beefind.pl --dump ${D}/FILES | sed -e "s,^,${D}," - > ${DUMP} + + cat ${BEE} > ${D}/BUILD + + create_meta + + echo "${PKGDIR}/${PF}.${PARCH}.iee.tar.bz2 contains .." + + tar cjvvf ${PKGDIR}/${PF}.${PARCH}.iee.tar.bz2 \ + -T ${DUMP} \ + --transform="s,${D},," \ + --show-transformed-names \ + --sparse \ + --absolute-names \ + --no-recursion \ + --transform="s,^/FILES$,FILES," \ + --transform="s,^/BUILD$,BUILD," \ + --transform="s,^/META$,META," \ + ${D}/{FILES,BUILD,META} + + rm ${DUMP} + + cp ${BEE} ${BEESTORE} +} + + +#### mee_*() ################################################################## + +mee_getsources() { bee_getsources ; } +mee_unpack() { bee_unpack; } +mee_patch() { bee_patch; } + +mee_configure() { bee_configure; } +mee_build() { bee_build; } +mee_install() { bee_install ; } + +############################################################################### +############################################################################### +############################################################################### + +OPTIONS=$(getopt -o fhil --long force,help,init,list -n bee-option-parser -- "$@") + +if [ $? != 0 ] ; then + echo "Terminating..." >&2 + exit 1 +fi + +eval set -- "${OPTIONS}" + +OPT_FORCE="no" + +while true ; do + case "$1" in + -f|--force) + OPT_FORCE=yes + shift + ;; + -h|--help) + show_help + exit 0 + ;; + -i|--init) + shift 2 + init "${@}" + exit 0 + ;; + -l|--list) + LIST=$(get_bee_list) + print_bee_list ${LIST} + exit 0 + ;; + --) + shift + break + ;; + *) + echo "Internal error!" + exit 1 + ;; + esac +done + + +BEE=$1 +if [ ! $BEE = "/.*" ] ; then + BEE=${PWD}/$BEE +fi + +PF=$(basename $BEE .bee) + +#parse pkg name +# PF = glibc-2.10.1_rc5-1 - full package name +# PN = glibc - package name +# PV = 2.10.1 - version +# PS = _rc5 - unterversion +# PR = 1 - revision +# PVF = 2.10.1_rc5 - version unterversion +# PVR = 2.10.1_rc5-1 - version-revision (full version) +# P = glibc-2.10.1_rc5 - package name (ohne version revision) +PN=$(echo ${PF} | sed -e 's,^\(.*\)-\(.*\)-\(.*\)$,\1,' -) +PV=$(echo ${PF} | sed -e 's,^\(.*\)-\(.*\)-\(.*\)$,\2,' - | sed -e 's,^\(.*\)\(_.*\)$,\1,' -) +PS=$(echo ${PF} | sed -e 's,^\(.*\)-\(.*\)-\(.*\)$,\2,' - | sed -e 's,^\(.*\)\(_.*\)$,\2,' -) +PR=$(echo ${PF} | sed -e 's,^\(.*\)-\(.*\)-\(.*\)$,\3,' -) + +PVF=${PV}${PS} +PVR=${PVF}-${PR} +P=${PN}-${PVF} + +#pkg root +R=${BEEROOT}/${PN} + +#pkg files .tar .patch .. +F=${R}/files + +#working dir for current build +W=${R}/${PF} + +S=${W}/source +B=${W}/build +D=${W}/image + +. ${BEE} + +if [ -e ${BEEFAULTS} ] ; then + . ${BEEFAULTS} +fi + +: ${PARCH:=${ARCH}} +: ${PKGDIR:=${PWD}} + +#define default directories + +: ${PREFIX:=/usr} +: ${EPREFIX:=${PREFIX}} +: ${BINDIR:=${EPREFIX}/bin} + +: ${SBINDIR:=${EPREFIX}/sbin} +: ${LIBEXECDIR:=${EPREFIX}/lib/${PN}} +: ${SYSCONFDIR:=/etc} + +: ${LOCALSTATEDIR:=/var} +: ${SHAREDSTATEDIR:=${LOCALSTATEDIR}} +: ${LIBDIR:=${EPREFIX}/lib} +: ${INCLUDEDIR:=${PREFIX}/include} +: ${DATAROOTDIR:=${PREFIX}/share} +: ${DATADIR:=${DATAROOTDIR}} +: ${INFODIR:=${DATAROOTDIR}/info} +: ${MANDIR:=${DATAROOTDIR}/man} +: ${DOCDIR:=${DATAROOTDIR}/doc/gtkhtml} +: ${LOCALEDIR:=${DATAROOTDIR}/locale} + + +if [ ${IGNORE_DATAROOTDIR} ] ; then + unset DATAROOTDIR +fi +if [ ${IGNORE_LOCALEDIR} ] ; then + unset LOCALEDIR +fi +if [ ${IGNORE_DOCDIR} ] ; then + unset DOCDIR +fi + + +#define default configure +: ${DEFCONFIG:="\ +--prefix=${PREFIX} \ +--exec-prefix=${EPREFIX} \ +--bindir=${BINDIR} \ +--sbindir=${SBINDIR} \ +--libexecdir=${LIBEXECDIR} \ +--sysconfdir=${SYSCONFDIR} \ +--sharedstatedir=${SHAREDSTATEDIR} \ +--localstatedir=${LOCALSTATEDIR} \ +--libdir=${LIBDIR} \ +--includedir=${INCLUDEDIR} \ +${DATAROOTDIR:+--datarootdir=${DATAROOTDIR}} \ +--datadir=${DATADIR} \ +--infodir=${INFODIR} \ +${LOCALEDIR:+--localedir=${LOCALEDIR}} \ +--mandir=${MANDIR} \ +${DOCDIR:+--docdir=${DOCDIR}} \ +"} + +bee_init_builddir +mee_getsources +mee_unpack +cd ${S} +mee_patch +cd ${B} +mee_configure +cd ${B} +mee_build +cd ${B} +mee_install +cd ${D} +bee_pkg_pack diff --git a/bee.pkgdb b/bee.pkgdb new file mode 100644 index 0000000..1db515f --- /dev/null +++ b/bee.pkgdb @@ -0,0 +1 @@ +S \ No newline at end of file diff --git a/bee_check b/bee_check new file mode 100755 index 0000000..0371b74 --- /dev/null +++ b/bee_check @@ -0,0 +1,285 @@ +#!/bin/bash + + + +############################################################################### +############################################################################### +############################################################################### + +VERSION=0.1 + +. /etc/bee.defaults + +PKGMETADIR=${PKGMETADIR:-/usr/share/bee} +PKGDIR=${PKGDIR:-.} + + +############################################################################### +## +## +pkg_check_all() { + + if [ ! "${1}" ] ; then + pkg_check + return + fi + + for pkg in ${@} ; do + pkg_check ${pkg} + done +} + + +############################################################################### +## +## +pkg_check_deps() { + installed=$(get_installed_versions ${1}) + + if [ ! "${installed}" -a $OPT_F -gt 0 ] ; then + installed=$(get_pkg_list_installed ${1}) + fi + + if [ "${installed}" ] ; then + for i in ${installed} ; do + do_check_deps "${i}" + done + fi + exit 0 +} + +############################################################################### +## +## +pkg_check() { + installed=$(get_installed_versions ${1}) + + if [ ! "${installed}" -a $OPT_F -gt 0 ] ; then + installed=$(get_pkg_list_installed ${1}) + fi + + if [ "${installed}" ] ; then + for i in ${installed} ; do + do_check "${i}" + done + return 0 + fi + + installed=$(get_pkg_list_installed ${1}) + + if [ "${installed}" ] ; then + echo "packages matching '${1}':" + for i in ${installed} ; do + echo " [*] ${i}" + done + fi + + +} + + +############################################################################### +## +## +do_check_deps() { + local pkg=${1} + local filesfile=${PKGMETADIR}/${pkg}/FILES + + for line in $(cat ${filesfile}) ; do + local IFS=":" + + for ff in ${line} ; do + # evil 8)... don't hack me... hrhr + eval $ff + done + + # save and strip possible symbolic link destination.. + symlink=${file#*//} + file=${file%%//*} + + if [ ! -f "${file}" -o -h ${file} ] ; then + continue + fi + +# echo ${file} + + readelf -d ${file} 2>/dev/null | egrep "(NEEDED|SONAME)" + + done \ + | sed -e 's,.*Shared library: \[\(.*\)\].*,needs \1,' \ + -e 's,.*Library soname: \[\(.*\)\].*,provides \1,' \ + | sort -u +} + +############################################################################### +## +## +do_check() { + local pkg=${1} + + local filesfile=${PKGMETADIR}/${pkg}/FILES + + echo "checking ${pkg} .." + + for line in $(cat ${filesfile}) ; do + local IFS=":" + + for ff in ${line} ; do + # evil 8)... don't hack me... hrhr + eval $ff + done + + # save and strip possible symbolic link destination.. + symlink=${file#*//} + file=${file%%//*} + + if [ ! -e "${file}" ] ; then + echo " [missing] <${md5}> ${file}" + continue + fi + + if [ "${md5}" = "link" ] ; then + if [ ! -h "${file}" ] ; then + echo " [changed] ${file}" + else + sdest=$(readlink ${file}) + if [ "${sdest}" != "${symlink}" ] ; then + echo " [changed] ${file}" + fi + #echo " [ DEBUG ] ${file} -> ${symlink}" + fi + continue + fi + + if [ "${md5}" = "directory" ] ; then + if [ ! -d "${file}" ] ; then + echo " [changed] ${file}" + fi + continue + fi + + # regular file - check md5sum.. + + md5now=$(md5sum ${file} | sed -e 's,^\([a-z0-9]*\).*$,\1,') + + if [ "${md5}" != "${md5now}" ] ; then + echo " [changed] <${md5} != ${md5now}> ${file}" + continue + fi + done + +} + +############################################################################### +### get_installed_versions ### +## +## IN: full_packagename +## +## OUT: list of installed packages matching pkgname(full_packagename) +## +## DESCRIPTION: ... +## +get_installed_versions() { + local pkg=${1} + + local pname=$(get_name_from_pkg ${pkg}) + local list + + for i in $(get_pkg_list_installed "${pname}") ; do + local installed=$(get_name_from_pkg ${i}) + if [ "${installed}" = "${pname}" ] ; then + list="${list:+${list} }${i}" + fi + done + + echo "${list}" +} + +############################################################################### +### get_pkg_list_installed ### +## +## IN: +## +## +## +get_pkg_list_installed() { + local search=${1} + + local hits arch + + hits=$(find ${PKGMETADIR} -maxdepth 1 -mindepth 1 -type d -printf "%f\n" \ + | egrep "${search}" | sort) + + echo ${hits} +} + +############################################################################### +## +## + +#sub1-sub2-subn-name-V.V.V.V-R.A.iee.tar.bz2 + +get_fullversion_from_pkg() { + echo $(echo $1 | sed -e 's,^\(.*\)-\(.*\)-\(.*\)\.\(.*\)$,\2-\3,' - ) +} + +############################################################################### +## +## +get_name_from_pkg() { + echo $(echo $1 | sed -e 's,^\(.*\)-\(.*\)-\(.*\)$,\1,' - ) +} + + + +############################################################################### +## +## +options=$(getopt -n bee_check \ + -o iadvfuh \ + --long install,upgrade,verbose,all,force,help \ + -- "$@") +if [ $? != 0 ] ; then + iee_usage + exit 1 +fi +eval set -- "${options}" + +declare -i OPT_A=0 +declare -i OPT_F=0 + +while true ; do + case "$1" in + -a|--all|-v|--verbose) + shift; + OPT_A=$OPT_A+1 + ;; + -f|--force) + shift; + OPT_F=$OPT_F+1 + ;; + -d|--deps) + shift 2; + pkg_check_deps ${@} + exit 0 + ;; + -u|--upgrade) + shift + pkg_upgrade $@ + exit 0 + ;; + -h|--help) + iee_usage + exit 0 + ;; + -i|--install) + shift + ;; + *) + shift + pkg_check_all ${@} + + exit 0; + ;; + esac +done diff --git a/bee_install b/bee_install new file mode 100755 index 0000000..f9ed628 --- /dev/null +++ b/bee_install @@ -0,0 +1,321 @@ +#!/bin/bash + +############################################################################### +############################################################################### +############################################################################### + +VERSION=0.1 + +. /etc/bee.defaults + +PKGMETADIR=${PKGMETADIR:-/usr/share/bee} +PKGDIR=${PKGDIR:-.} + + +##### iee_usage ############################################################### +iee_usage() { + echo "bee_install v${VERSION} 2009-2010" + echo "" + echo " by Tobias Dreyer and Marius Tolzmann <{dreyer,tolzmann}@molgen.mpg.de>" + echo "" + echo " Usage: $0 [action] [options] " + echo "" + echo " action:" + echo " -i | --install install package (default action)" + echo " -u | --upgrade install package" + echo " -h | --help display this help.. 8)" + echo "" + echo " options:" + echo " -f | --force can be used to force installation come what may" + echo " -v | --verbose bee more verbose (can be used twice e.g. -vv)" + echo +} + +############################################################################### +## +## +pkg_install_all() { + for pkg in ${@} ; do + pkg_install ${pkg} + done +} + +############################################################################### +## +## + +#sub1-sub2-subn-name-V.V.V.V-R.A.iee.tar.bz2 + +get_fullversion_from_pkg() { + echo $(echo $1 | sed -e 's,^\(.*\)-\(.*\)-\(.*\)\.\(.*\)$,\2-\3,' - ) +} + +############################################################################### +## +## +get_name_from_pkg() { + echo $(echo $1 | sed -e 's,^\(.*\)-\(.*\)-\(.*\)$,\1,' - ) +} + +############################################################################### +### pkg_install ### +## +## IN: search-pattern +## +## OUT: ... +## +## DESCRIPTION: ... +## +pkg_install() { + search=${1} + + # install specific package + + if [ -f "${search}" ] ; then + do_install "${search}" + fi + + # install package from repository + + if [ -f "${PKGDIR}/${search}" ] ; then + do_install "${PKGDIR}/${search}" + fi + + for e in "" ".$(arch)" ".any" ; do + if [ -f "${PKGDIR}/${search}${e}.iee.tar.bz2" ] ; then + do_install "${PKGDIR}/${search}${e}.iee.tar.bz2" + fi + done + + avail=$(get_pkg_list_repository "${search}") + + print_pkg_list ${avail} +} + + +############################################################################### +### get_installed_versions ### +## +## IN: full_packagename +## +## OUT: list of installed packages matching pkgname(full_packagename) +## +## DESCRIPTION: ... +## +get_installed_versions() { + local pkg=${1} + + local pname=$(get_name_from_pkg ${pkg}) + local list + + for i in $(get_pkg_list_installed "${pname}") ; do + local installed=$(get_name_from_pkg ${i}) + if [ "${installed}" = "${pname}" ] ; then + list="${list:+${list} }${i}" + fi + done + + echo "${list}" +} + +############################################################################### +### check_installed ### +## +## IN: full_packagename +## +## OUT: n/a - only returns if package is not installed in any version +## +## DESCRIPTION: +## - print installed versions of "full_packagename" +## - exit(2) if installed version of "full_packagename" exists +## +check_installed() { + local pkgname=${1} + + local installed=$(get_installed_versions ${pkgname}) + + if [ "${installed}" != "" ] ; then + for i in ${installed} ; do + local v=$(get_fullversion_from_pkg ${i}) + local n=$(get_name_from_pkg ${i}) + + if [ ${i} = ${pkgname} ] ; then + echo "[ already installed ] ${n} - version ${v}" + else + echo "[alternative installed] ${n} - version ${v}" + fi + done + exit 2; + fi +} + +############################################################################### +### do_install ### +## +## IN: filename +## +## OUT: n/a +## +## DESCRIPTION: +## - calls check_installed which exits if package is already installed +## (skip test if -f option was given on commandline) +## - installs package +## +do_install() { + local file=${1} + local pkgname=$(basename $(basename $(basename ${file} .tar.gz) .tar.bz2) .iee) + + if [ "${OPT_F}" = "0" ] ; then + check_installed ${pkgname} + fi + +# echo "would install ${file}" +# exit 0 + + mkdir -p ${PKGMETADIR}/${pkgname} + tar -xvvPf ${file} \ + --transform="s,FILES,${PKGMETADIR}/${pkgname}/FILES," \ + --transform="s,BUILD,${PKGMETADIR}/${pkgname}/BUILD," \ + --transform="s,META,${PKGMETADIR}/${pkgname}/META," \ + --show-transformed-names + exit $? +} + + +############################################################################### +### get_pkg_list ### +## +## IN: +## +## +## +get_pkg_list_repository() { + local search=${1} + + local hits arch + + if [ ${OPT_A} -le '1' ] ; then + arch="\.(any|$(arch))" + fi + + hits=$(find ${PKGDIR} -mindepth 1 \ + | egrep "${arch}\.iee" \ + | egrep "${search}" \ + | sort) + + echo ${hits} +} + +############################################################################### +### get_pkg_list_installed ### +## +## IN: +## +## +## +get_pkg_list_installed() { + local search=${1} + + local hits arch + + hits=$(find ${PKGMETADIR} -maxdepth 1 -mindepth 1 -type d -printf "%f\n" \ + | egrep "${search}") + + echo ${hits} +} + +############################################################################### +### print_pkg_list ### +## +## args: $LIST +## +## +## +print_pkg_list() { + local -i f=0 + + if [ ! "${1}" ] ; then + echo "no matching packages found in repository.." + exit 4 + fi + + for p in ${@} ; do + local pkgname=$(basename $(basename ${p} .tar.bz2) .iee) + + local installed=$(get_installed_versions ${pkgname}) + + local status + for i in ${installed} ; do + if [ ${i} = ${pkgname} ] ; then + status="*" + else + status=${status:--} + fi + done + status=${status:- } + if [ "${status}" = " " -o ${OPT_A} -gt 0 ] ; then + echo " [${status}] ${pkgname}" + f=$f+1 + fi + unset status + done + + echo "${f} of ${#} packages displayed matching search criteria." + + if [ ${f} -eq 0 ] ; then + echo "no new packages found in repository. try -v to list already installed packages." + exit 5 + fi +} + +############################################################################### +############################################################################### +############################################################################### + + +options=$(getopt -n bee_install \ + -o iavfuh \ + --long install,upgrade,verbose,all,force,help \ + -- "$@") +if [ $? != 0 ] ; then + iee_usage + exit 1 +fi +eval set -- "${options}" + +declare -i OPT_A=0 +declare -i OPT_F=0 + +while true ; do + case "$1" in + -a|--all|-v|--verbose) + shift; + OPT_A=$OPT_A+1 + ;; + -f|--force) + shift; + OPT_F=$OPT_F+1 + ;; + -u|--upgrade) + shift + pkg_upgrade $@ + exit 0 + ;; + -h|--help) + iee_usage + exit 0 + ;; + -i|--install) + shift + ;; + *) + shift + if [ -z ${1} ] ; then + iee_usage + exit 1 + fi + pkg_install_all ${@} + exit 0; + ;; + esac +done diff --git a/bee_remove b/bee_remove new file mode 100644 index 0000000..b54b1c0 --- /dev/null +++ b/bee_remove @@ -0,0 +1,145 @@ +#!/bin/bash + +############################################################################### +############################################################################### +############################################################################### + +VERSION=0.1 + +. /etc/bee.defaults + +PKGMETADIR=${PKGMETADIR:-/usr/share/bee} +PKGDIR=${PKGDIR:-.} + + +##### pkg_remove ############################################################## +##### IN: file +pkg_remove() { + local search = $1 + + if [ -f ] +} + + +##### do_remove ############################################################### +##### IN: absolute filename + + +do_remove() { + local pkg = $1 + # collect files + FILES=$(/project/azubi/bee/beefind.pl --dump ${pkg}/FILES) + + # removing files + for f in $FILES ; do + # test for other pkg + s = $(echo $f | sed -e "s,[\`|&^$.+?(){}],\\\&,g" -e "s,\[,\\\&," -e "s,\],\\\&,") + RELPKG=$(egrep "file=$f(|//.*)$" ${PKGMETADIR}/*/FILES) + if [ 1 -eq $(echo $RELPKG | wc -w) ] ; then + #check for directories + if [ -d $f ] ; then + DIR="$f $DIR" + else + rm -vf $f + fi + else + echo "cannot remove $f .. is related to other pkgs" + fi + done + + #removing directories + for d in $DIR ; do + if [ -z "$(ls $d)" ] ; then + rmdir -v $d + fi + done + + #cleaning up meta directory + for f in `ls ${INSTALLED}` ; do + rm -vf $f + done + rm -vfr ${INSTALLED} +} + + +##### pkg_remove ############################################################## +pkg_remove() { + while true ; do + case "$1" in + --) + shift + # create useful regex, remove whitespaces + PATTERN=$(echo $@ | sed -e 's,[[:space:]]*,,g' - ) + break + ;; + *) + shift + ;; + esac + done + + # check if $PATTERN is nonzero + if [ -z "$PATTERN" ] ; then + echo "no package passed" + exit 1 + fi + + # check for installed pkgs + INSTALLED=$(get_pkg_list $PKGMETADIR -- "${PATTERN}") + + # check for zero length + if [ -z "$INSTALLED" ] ; then + echo "no installed package matching '${PATTERN}' .." + exit 1 + fi + + # check if more than 1 pkg matches + if [ ! 1 -eq $(echo $INSTALLED | wc -w) ] ; then + echo "installed packages matching '${PATTERN}' .." + print_pkg_list "$INSTALLED" + exit 1 + fi + + #check if pattern is package + PKGNAME=$(basename ${INSTALLED}) + if [ "${PATTERN}" != "${PKGNAME}" ] ; then + echo "installed packages matching ${PATTERN} .." + print_pkg_list "$INSTALLED" + exit 1 + fi + + # vaild from here + # -- only 1 pkg is matching + + # collect files + FILES=$(/project/azubi/bee/beefind.pl --dump ${INSTALLED}/FILES) + + # removing files + for f in $FILES ; do + #test for other pkg + RELPKG=$(egrep "file=$f(|//.*)$" ${PKGMETADIR}/*/FILES) + if [ 1 -eq $(echo $RELPKG | wc -w) ] ; then + #check for directories + if [ -d $f ] ; then + DIR="$f $DIR" + else + rm -vf $f + fi + else + echo "cannot remove $f .. is related to other pkgs" + fi + done + + #removing directories + for d in $DIR ; do + if [ -z "$(ls $d)" ] ; then + rmdir -v $d + fi + done + + #cleaning up meta directory + for f in `ls ${INSTALLED}` ; do + rm -vf $f + done + rm -vfr ${INSTALLED} +} diff --git a/beefind.pl b/beefind.pl new file mode 100755 index 0000000..97eb7bf --- /dev/null +++ b/beefind.pl @@ -0,0 +1,308 @@ +#!/usr/bin/perl -w + +use Data::Dumper; +use File::Find; +use Time::HiRes; +use Digest::MD5; +use File::stat; +use Fcntl; +use Getopt::Long; + +$Data::Dumper::Indent=1; +$Data::Dumper::Terse=1; +my @STATNAME=(qw(dev ino mode nlink uid gid rdev size atime mtime ctime blksize blocks)); + +my %HARDLINK; +my @HARDLINKS; + +my $t0 = Time::HiRes::time; + +my @MD5SKIP = qw( pipe socket block char tty ); +my %MD5SKIP = map {($_ => undef)} @MD5SKIP; + +my $ls; + +my %opt = ( + maxdepth => -1, + md5 => 1, + xdev => 0, + help => 0, + filelist => undef, + skiplist => undef, + dumpfilelist => 0, + format => 'mxpkg', + exclude => [], + cutroot => '', + ignore => 'ino', + ignore_dirmtime => 0, + cat => 0, + +); + +sub help { + print <<"--EOH--"; + +$0 [--nomd5] [--xdev] [--maxdepth=LEVELS] PATH.. +$0 [--nomd5] --from-file=FILE + + --nomd5 don't calculate md5sum for files + --xdev don't descend directories on other filesystems + --maxdepth=LEVELS descend at most LEVELS levels of directories + --from-file=FILE get names to process from file FILE + --ignore_dirmtime ignore mtime on directories + +$0 --dumpfilenames [--format=FORMAT] [LISTFILE] + + FORMAT=mxpkg (default) + FORMAT=find-ls + + +--EOH-- +exit; +} + +$result = GetOptions ("maxdepth=i" => \$opt{maxdepth}, + "md5!" => \$opt{md5}, + "xdev!" => \$opt{xdev}, + "dumpfilenames" => \$opt{dumpfilelist}, + "format=s" => \$opt{format}, + "help" => \$opt{help}, + "ignore=s" => \$opt{ignore}, + "ignore_dirmtime!" => \$opt{ignore_dirmtime}, + "files-from|from-file=s" => \$opt{filelist}, + "excludelist=s" => \$opt{excludelist}, + "exclude=s" => $opt{exclude}, + "cutroot=s" => \$opt{cutroot}, + "cat!" => \$opt{cat}, + ); + +help() if(not $result or $opt{help}); + +if($opt{cat}){ + + my ($f, @f); + + my $filelist = shift @ARGV; + + $filelist = '-' unless($filelist); + die "can't open $filelist: $!\n" unless(open(FH, "<$filelist")); + + my %ignore = map {( $_ => undef)} split/,/, $opt{ignore}; + + foreach() { + chomp; + + unless(($f) = /(:file=.*?)$/) { + die "invalid file-format..\n"; + } + +# s/\n//g; + s/:file=.*?$//; + + my $x = join ":", grep { /^(\S+)=/ && not exists $ignore{$1} } split /:/; + + print "$x$f\n"; + + } + + + exit; +} + + + + + +#print STDERR Dumper \%opt; + +if($opt{dumpfilelist}) { + my $filelist = shift @ARGV; + $filelist = '-' unless($filelist); + die "can't open $filelist: $!\n" unless(open(FH, "<$filelist")); + foreach() { + chomp; + if($opt{format} eq 'find-ls') { + my $s=10; + s/^\s*//g; + my @L = split /\s+/, $_; + if($L[2] =~ /^[bc]/) { + $s = 9; + } + $_ = join " ", @L[$s..$#L]; + s, -> .*$,,; + print "$_\n"; + } elsif(/:file=(.*?)$/) { + $_ = $1; + s,//.*$,,g; + print "$_\n"; + } else { + print STDERR "invalid format detected:\n *** $_\n"; + } + } + exit; +} + +if($opt{filelist}) { + die "can't open $opt{filelist}: $!\n" unless(open(FH, "<$opt{filelist}")); + foreach() { + chomp; + unless($ls = lstat($_)){ + warn "can't stat '$_': $!\n"; + next + }; + print file2output($_); + } + close FH; + exit; +} + +if(@ARGV) { + scan(@ARGV); +} else { + help(); +} + + + + +sub scan_preprocess { + $__scan_DEPTH++; + return if($opt{maxdepth} >= 0 and $__scan_DEPTH > $opt{maxdepth}); +# printf STDERR "[$__scan_DEPTH] scanning $File::Find::dir ..\n"; + return sort @_; +} + +sub scan_postprocess { +# printf STDERR "[$__scan_DEPTH] finished scanning of $File::Find::dir ..\n" +# unless($opt{maxdepth} >= 0 and $__scan_DEPTH > $opt{maxdepth}); + $__scan_DEPTH--; +} + +sub scan { + + if($opt{excludelist}) { + open FH,$opt{excludelist} or die qq(can't open $opt{excludelist}: $!\n); + foreach() { + chomp; + next if(/^\s*$/); + s/\s*$//; + + push @SKIP, $_; + } + close FH; + } + + push @SKIP, @{$opt{exclude}}; + +# print STDERR Dumper \@SKIP, $opt{exclude}; + + File::Find::find({ + wanted => \&scan_process, + preprocess => \&scan_preprocess, + postprocess => \&scan_postprocess, + no_chdir => 1 + }, @_); +} + + +sub scan_process { + + my $file = $File::Find::name; + + $ls = lstat($file) or die "can't stat '$file': $!\n"; + + if($opt{xdev} && ($File::Find::prune |= ($ls->dev != $File::Find::topdev))) { + printf STDERR "skipping $file .. $File::Find::topdev != ". $ls->dev . "\n"; + print file2output($file); + return 0; + } + + + return 0 if($file eq $opt{cutroot}); + + foreach(@SKIP) { + my $f = $file; + $f =~ s/^\Q$opt{cutroot}\E//; + if($f =~ qr(${_})) { + printf STDERR "skipping $file ($f) .. in SKIP($_).. \n"; + return 0; + } + } + + if($File::Find::prune |= (exists $SKIP{$file})) { + printf STDERR "skipping $file .. in SKIP.. \n"; + print file2output($file); + return 0; + } + + print file2output($file); + return 1; +} + +sub file2output { + my $file = shift; + my $md5='off'; + my $link=''; + my $islink = 0; + + if (-f _ && $ls->nlink > 1) { + my $index = $ls->dev. "#" . $ls->ino; + + if (exists $HARDLINK{$index}) { + $islink = 1; + } + push @{$HARDLINK{$index}},$file; + } + + + if (-f _ ) { + if($opt{md5}) { + if(sysopen(FILE, "$file", O_RDONLY)) { + binmode(FILE); + $md5 = Digest::MD5->new->addfile(*FILE)->hexdigest(); + close(FILE); + } else { + warn("Can't open '$file': $!\n"); + $md5 = '#MD5OPENERROR#'; + } + } + } + + elsif (-d _) { $md5='directory'; } # plain directory + elsif (-l _) { $md5='link'; $link = '//'.readlink($file); } # plain symlink + elsif (-p _) { $md5='pipe'; } # plain pipe + elsif (-S _) { $md5='socket'; } # plain socket + elsif (-b _) { $md5='block'; } # plain block special + elsif (-c _) { $md5='char'; } # plain character special + elsif (-t _) { $md5='tty'; } # plain tty + else { + print STDERR "#?#:$file (UNKNOWN)\n"; + } + + if(exists $MD5SKIP{$md5}) { +# print STDERR "md5=$md5:file=$file (in MD5SKIP .. ignored)\n"; + return "" + } + + my @f = qw(ino mode nlink uid gid size mtime); + my %ignore = map {( $_ => undef)} split/,/, $opt{ignore}; + + if($md5 eq 'directory' and $opt{ignore_dirmtime}) { + $ignore{size} = undef; + $ignore{mtime} = undef; + $ignore{nlink} = undef; + } + if($md5 eq 'link') { + $ignore{nlink} = undef; + } + + @f = grep {not exists $ignore{$_}} @f; + + my @x = map {"$_=" . eval '$ls->$_'} @f; + + $file =~ s/^\Q$opt{cutroot}\E//; + + return join(':', "md5=$md5", @x, "file=$file$link\n"); +} + + diff --git a/compare_versions b/compare_versions new file mode 100755 index 0000000..6dedc1f --- /dev/null +++ b/compare_versions @@ -0,0 +1,41 @@ +#!/bin/bash + +################################################################### +# IN: .. +# +# OUT: -1 .. left greater than right +# 0 .. left equal to right +# +1 .. left less than right + +version1=$1 +version2=$2 + +v1_space_sep=$(echo $version1 | sed -e "s,\., ,g" - ) +v2_space_sep=$(echo $version2 | sed -e "s,\., ,g" - ) + +# check for same format +if [ $(echo $v1_space_sep | wc -w) -ne $(echo $v2_space_sep | wc -w) ] ; then + echo "cannot compare $version1 and $version2 .. different format" + exit 0 +fi + +# get shorter version number +if [ $(echo $v1_space_sep | wc -w) -lt $(echo $v2_space_sep | wc -w) ] ; then + cnt=$(echo $v1_space_sep | wc -w) +else + cnt=$(echo $v2_space_sep | wc -w) +fi + +# check whole versions +if [ "$version1" = "$version2" ] ; then + echo $version1 = $version2 +fi + +# check parts +for p in `seq 1 $cnt` ; do + v1=$(echo $version1 | cut -d '.' -f $p - ) + v2=$(echo $version2 | cut -d '.' -f $p - ) + +done + + diff --git a/fonts.dir b/fonts.dir new file mode 100644 index 0000000..573541a --- /dev/null +++ b/fonts.dir @@ -0,0 +1 @@ +0 diff --git a/iee-alpha b/iee-alpha new file mode 100755 index 0000000..77cf727 --- /dev/null +++ b/iee-alpha @@ -0,0 +1,321 @@ +#!/bin/bash +set -e + +############################################################################### +############################################################################### +############################################################################### + +##### iee_usage ############################################################### +iee_usage() { + echo "Usage: $0 [options] [pkg]" + echo "Options:" + echo " -i" + echo " --install" + echo " --ickbrauch .. install package" + echo + echo " -r" + echo " --remove .. remove package" + echo + echo " -l" + echo " --list .. prints installed and available without any option" + echo " --system .. list only installed packages" + echo " --available .. list only available packages" +} + +##### pkg_remove ############################################################## +pkg_remove() { + while true ; do + case "$1" in + --) + shift + # create useful regex, remove whitespaces + PATTERN=$(echo $@ | sed -e 's,[[:space:]]*,,g' - ) + break + ;; + *) + shift + ;; + esac + done + + # check if $PATTERN is nonzero + if [ -z "$PATTERN" ] ; then + echo "no package passed" + exit 1 + fi + + # check for installed pkgs + INSTALLED=$(get_pkg_list $PKGMETADIR -- "${PATTERN}") + + # check for zero length + if [ -z "$INSTALLED" ] ; then + echo "no installed package matching '${PATTERN}' .." + exit 1 + fi + + # check if more than 1 pkg matches + if [ ! 1 -eq $(echo $INSTALLED | wc -w) ] ; then + echo "installed packages matching '${PATTERN}' .." + print_pkg_list "$INSTALLED" + exit 1 + fi + + #check if pattern is package + PKGNAME=$(basename ${INSTALLED}) + if [ "${PATTERN}" != "${PKGNAME}" ] ; then + echo "installed packages matching ${PATTERN} .." + print_pkg_list "$INSTALLED" + exit 1 + fi + + # vaild from here + # -- only 1 pkg is matching + + # collect files + FILES=$(/project/azubi/bee/beefind.pl --dump ${INSTALLED}/FILES) + + # removing files + for f in $FILES ; do + #test for other pkg + s=$(echo $f | sed -e "s,[\`|&^$.+?(){}],\\\&,g" -e "s,\[,\\\&," -e "s,\],\\\&,") + RELPKG=$(egrep "file=$s(|//.*)$" ${PKGMETADIR}/*/FILES) + if [ 1 -eq $(echo $RELPKG | wc -w) ] ; then + #check for directories + if [ -d $f ] ; then + DIR="$f $DIR" + else + rm -vf $f + fi + else + echo "cannot remove $f .. is related to other pkgs" + fi + done + + #removing directories + for d in $DIR ; do + if [ -z "$(ls $d)" ] ; then + rmdir -v $d + fi + done + + #cleaning up meta directory + for f in `ls ${INSTALLED}` ; do + rm -vf $f + done + rm -vfr ${INSTALLED} +} + +##### pkg_install ############################################################# +pkg_install() { + while true ; do + case "$1" in + --) + shift + # create useful regex, remove whitespaces + PATTERN=$(echo $@ | sed -e 's,[[:space:]]*,,g' - ) + break + ;; + *) + shift + ;; + esac + done + + # file exists, no need to find file matching pattern + if [ -e ${PKGDIR}/${PATTERN} ] ; then + PKGNAME=$(basename $(basename $(basename $PATTERN .tar.gz) .tar.bz2) .iee) + else + + # check if $PATTERN is nonzero + if [ -z "$PATTERN" ] ; then + echo "no package passed" + exit 1 + fi + + # make sure $PATTERN ends not with .tar* and .iee + PATTERN=$(basename $(basename ${PATTERN} .tar.bz2) .iee) + + # get available pkgs + AVAIL=$(get_pkg_list $PKGDIR -- "${PATTERN}") + if [ -z "$AVAIL" ] ; then + echo "no available packages matching '${PATTERN}' .." + exit 1 + fi + + # check if more than 1 pkg available and make sure patern equals package + if [ ! 1 -eq $(echo $AVAIL | wc -w) ] ; then + echo "available packages matching '${PATTERN}'" + print_pkg_list ${AVAIL} + exit 1 + fi + + PKGNAME=$(basename $(basename $(basename $AVAIL .tar.gz) .tar.bz2) .iee) + if [ "${PATTERN}" != "${PKGNAME}" ] ; then + echo "available packages matching '${PATTERN}'" + print_pkg_list ${AVAIL} + exit 1 + fi + fi + + # if not in upgrade mode, check for installed package + # otherwise overwrite + if [ ! $UPGRADE ] ; then + INSTALLED=$(get_pkg_list $PKGMETADIR -- "${PKGNAME}") + if [ -n "$INSTALLED" ] ; then + echo "installed packages matching '${PKGNAME}' .." + print_pkg_list $INSTALLED + exit 1 + fi + fi + + ## valid from here + ## -- only 1 available pkg + ## -- no installed pkg or upgrade + + # create META dir + mkdir -p ${PKGMETADIR}/${PKGNAME} + +#echo $PKGNAME >&2 + + # install!!!111elf + echo "installing ${PKGNAME}" + tar -xvvPf $PKGDIR/$PKGNAME.iee.tar.bz2 \ + --transform="s,FILES,${PKGMETADIR}/${PKGNAME}/FILES," \ + --transform="s,BUILD,${PKGMETADIR}/${PKGNAME}/BUILD," \ + --transform="s,META,${PKGMETADIR}/${PKGNAME}/META," \ + --show-transformed-names + +} + +##### get_pkg_list ############################################################ +# args: $PATH -- $PATTERN +get_pkg_list() { + while true ; do + case "$1" in + --) + shift + # create useful regex, remove whitespaces + PATTERN=$(echo $@ | sed -e 's,[[:space:]]*,,g' - ) + break + ;; + *) + CPATH=$1 + shift + ;; + esac + done + +# ARCH=$(echo $PATTERN |cut -d . -f 2) +# if [ -z "$ARCH" ] ; then + ARCH=$(arch) +# fi + +#echo $ARCH >&2 + + PATTERN=$(basename "$(basename "${PATTERN}" .i686)" .x86_64) + + if [ "$CPATH" = "$PKGDIR" ] ; then + PATTERN="${PATTERN}.*($ARCH|any).iee.tar.bz2" + else + PATTERN="${PATTERN}.*" + fi + +#echo $PATTERN >&2 + + HITS=$(find ${CPATH} -maxdepth 1 -mindepth 1 | egrep "${PATTERN}") + + echo $HITS +} + +##### print_pkg_list ########################################################## +# args: $LIST +print_pkg_list() { + if [ -z "$1" ] ; then + echo "list is empty.. no entries found" + exit 1 + fi + + LIST=$(ls -d $@) + + for l in $LIST ; do + if [ -z "$DIR" ] ; then + DIR=$(dirname $l) + echo $DIR + fi + if [ "$DIR" != "$(dirname $l)" ] ; then + DIR=$(dirname $l) + echo $DIR + fi + echo " - $(basename ${l})" + done +} + +############################################################################### +############################################################################### +############################################################################### + +. /etc/bee.defaults + +PKGMETADIR=${PKGMETADIR:-/usr/share/bee} +PKGDIR=${PKGDIR:-.} + +. /project/azubi/bee/helpers.bee + + +OPTIONS=$(getopt -n iee-option-parser \ + -o irul::h \ + --long install,ickbrauch,remove,runta,upgrade,undruebba,list::,help \ + -- "$@") +if [ $? != 0 ] ; then + echo "Terminating..." >&2 + exit 1 +fi +eval set -- "${OPTIONS}" + +UPGRADE=false + +while true ; do + case "$1" in + + -i|--install|--ickbrauch) + shift + pkg_install $@ + exit 0 + ;; + -r|--remove|--runta) + shift + pkg_remove $@ + exit 0 + ;; + -u|--upgrade|--undruebba) + shift + UPGRADE=true + pkg_install $@ + exit 0 + ;; + + -l|--list) + case "$2" in + a|available) + shift 2 + LIST=$(get_pkg_list $PKGDIR $@) + ;; + s|system) + shift 2 + LIST=$(get_pkg_list $PKGMETADIR $@) + ;; + *) + shift + LIST=$(get_pkg_list $PKGDIR $@) + LIST="${LIST} $(get_pkg_list $PKGMETADIR $@)" + ;; + esac + print_pkg_list $LIST + exit 0 + ;; + -h|--help|*) + iee_usage + exit 0 + ;; + esac +done diff --git a/iee-alpha-db b/iee-alpha-db new file mode 100644 index 0000000..9f91108 --- /dev/null +++ b/iee-alpha-db @@ -0,0 +1,313 @@ +#!/bin/bash +set -e + +############################################################################### +############################################################################### +############################################################################### + +##### iee_usage ############################################################### +iee_usage() { + echo "Usage: $0 [options] [pkg]" + echo "Options:" + echo " -i" + echo " --install" + echo " --ickbrauch .. install package" + echo + echo " -r" + echo " --remove .. remove package" + echo + echo " -l" + echo " --list .. prints installed and available without any option" + echo " --system .. list only installed packages" + echo " --available .. list only available packages" +} + +##### pkg_remove ############################################################## +pkg_remove() { + while true ; do + case "$1" in + --) + shift + # create useful regex, remove whitespaces + PATTERN=$(echo $@ | sed -e 's,[\w]*,,g' - ) + break + ;; + *) + shift + ;; + esac + done + + # check if $PATTERN is nonzero + if [ -z "$PATTERN" ] ; then + echo "no package passed" + exit 1 + fi + + # check for installed pkgs + INSTALLED=$(get_pkg_list $PKGMETADIR -- "${PATTERN}") + + # check for zero length + if [ -z "$INSTALLED" ] ; then + echo "no installed package matching '${PATTERN}' .." + exit 1 + fi + + # check if more than 1 pkg matches + if [ ! 1 -eq $(echo $INSTALLED | wc -w) ] ; then + echo "installed packages matching '${PATTERN}' .." + print_pkg_list "$INSTALLED" + exit 1 + fi + + #check if pattern is package + PKGNAME=$(basename ${INSTALLED}) + if [ "${PATTERN}" != "${PKGNAME}" ] ; then + echo "installed packages matching ${PATTERN} .." + print_pkg_list "$INSTALLED" + exit 1 + fi + + # vaild from here + # -- only 1 pkg is matching + + # collect files + FILES=$(/project/azubi/bee/beefind.pl --dump ${INSTALLED}/FILES) + + # removing files + for f in $FILES ; do + #test for other pkg + RELPKG=$(egrep "file=$f(|//.*)$" ${PKGMETADIR}/*/FILES) + if [ 1 -eq $(echo $RELPKG | wc -w) ] ; then + #check for directories + if [ -d $f ] ; then + DIR="$f $DIR" + else + rm -vf $f + fi + else + echo "cannot remove $f .. is related to other pkgs" + fi + done + + #removing directories + for d in $DIR ; do + if [ -z "$(ls $d)" ] ; then + rmdir -v $d + fi + done + + #cleaning up meta directory + for f in `ls ${INSTALLED}` ; do + rm -vf $f + done + rm -vfr ${INSTALLED} +} + +##### pkg_install ############################################################# +pkg_install() { + while true ; do + case "$1" in + --) + shift + # create useful regex, remove whitespaces + PATTERN=$(echo $@ | sed -e 's,[\w]*,,g' - ) + break + ;; + *) + shift + ;; + esac + done + + # check if $PATTERN is nonzero + if [ -z "$PATTERN" ] ; then + echo "no package passed" + exit 1 + fi + + # make sure $PATTERN ends not with .tar* and .iee + PATTERN=$(basename $(basename ${PATTERN} .tar.bz2) .iee) + + # get available pkgs + AVAIL=$(get_pkg_list $PKGDIR -- "${PATTERN}") + if [ -z "$AVAIL" ] ; then + echo "no available packages matching '${PATTERN}' .." + exit 1 + fi + + # check if more than 1 pkg available and make sure patern equals package + if [ ! 1 -eq $(echo $AVAIL | wc -w) ] ; then + echo "available packages matching '${PATTERN}'" + print_pkg_list ${AVAIL} + exit 1 + fi + + PKGNAME=$(basename $(basename $(basename $AVAIL .tar.gz) .tar.bz2) .iee) + if [ "${PATTERN}" != "${PKGNAME}" ] ; then + echo "available packages matching '${PATTERN}'" + print_pkg_list ${AVAIL} + exit 1 + fi + + # if not in upgrade mode, check for installed packages + # otherwise overwrite + + if [ ! $UPGRADE ] ; then + INSTALLED=$(get_pkg_list $PKGMETADIR -- "${PKGNAME}") + if [ -n "$INSTALLED" ] ; then + echo "installed packages matching '${PKGNAME}' .." + print_pkg_list $INSTALLED + exit 1 + fi + fi + + ## valid from here + ## -- only 1 available pkg + ## -- no installed pkg or upgrade + + # create META dir + mkdir -p ${PKGMETADIR}/${PKGNAME} + + # install!!!111elf + echo "installing ${PKGNAME}" + tar -xvvPf $AVAIL \ + --transform="s,FILES,${PKGMETADIR}/${PKGNAME}/FILES," \ + --transform="s,BUILD,${PKGMETADIR}/${PKGNAME}/BUILD," \ + --transform="s,META,${PKGMETADIR}/${PKGNAME}/META," \ + --show-transformed-names + + pkg_to_db ${PKGNAME} +} + +##### pk_to_db ################################################################ +pkg_to_db() { + if [ ! -e ${PKGMETADIR}/bee.pkgdb ] ; then + touch ${PKGMETADIR}/bee.pkgdb + fi + + if [ -z "$(sqlite3 bee.pkgdb ".tables pkgs")" ] ; then + sqlite3 ${PKGMETADIR}/bee.pkgdb "create table pkgs (pkgname varchar(255), numfiles int)" + fi + + sqlite3 ${PKGMETADIR}/bee.pkgdb "insert into pkgs (pkgname) values (\"$@\")" +} + +##### get_pkg_list ############################################################ +# args: $PATH -- $PATTERN +get_pkg_list() { + while true ; do + case "$1" in + --) + shift + # create useful regex, remove whitespaces + PATTERN=$(echo $@ | sed -e 's,[\w]*,,g' - ) + break + ;; + *) + CPATH=$1 + shift + ;; + esac + done + + PATTERN=$(basename "$(basename "${PATTERN}" .i686)" .x86_64) + + if [ "$CPATH" = "$PKGDIR" ] ; then + PATTERN="${PATTERN}.*($(arch)|any).iee.tar.bz2" + else + PATTERN="${PATTERN}.*" + fi + + HITS=$(find ${CPATH} -maxdepth 1 -mindepth 1 | egrep "${PATTERN}") + + echo $HITS +} + +##### print_pkg_list ########################################################## +# args: $LIST +print_pkg_list() { + LIST=$(ls -d $@) + + for l in $LIST ; do + if [ -z "$DIR" ] ; then + DIR=$(dirname $l) + echo $DIR + fi + if [ "$DIR" != "$(dirname $l)" ] ; then + DIR=$(dirname $l) + echo $DIR + fi + echo " - $(basename ${l})" + done +} + +############################################################################### +############################################################################### +############################################################################### + +. /etc/bee.defaults + +PKGMETADIR=${PKGMETADIR:-/usr/share/bee} +PKGDIR=${PKGDIR:-.} + +. /project/azubi/bee/helpers.bee + + +OPTIONS=$(getopt -n iee-option-parser \ + -o irul::h \ + --long install,ickbrauch,remove,runta,upgrade,undruebba,list::,help \ + -- "$@") +if [ $? != 0 ] ; then + echo "Terminating..." >&2 + exit 1 +fi +eval set -- "${OPTIONS}" + +UPGRADE=false + +while true ; do + case "$1" in + + -i|--install|--ickbrauch) + shift + pkg_install $@ + exit 0 + ;; + -r|--remove|--runta) + shift + pkg_remove $@ + exit 0 + ;; + -u|--upgrade|--undruebba) + shift + UPGRADE=true + pkg_install $@ + exit 0 + ;; + + -l|--list) + case "$2" in + a|available) + shift 2 + LIST=$(get_pkg_list $PKGDIR $@) + ;; + s|system) + shift 2 + LIST=$(get_pkg_list $PKGMETADIR $@) + ;; + *) + shift + LIST=$(get_pkg_list $PKGDIR $@) + LIST="${LIST} $(get_pkg_list $PKGMETADIR $@)" + ;; + esac + print_pkg_list $LIST + exit 0 + ;; + -h|--help|*) + iee_usage + exit 0 + ;; + esac +done diff --git a/pkgdiff.pl b/pkgdiff.pl new file mode 100644 index 0000000..1964957 --- /dev/null +++ b/pkgdiff.pl @@ -0,0 +1,6 @@ +#!/bin/perl + +use warnings; +use strict; + +