X-Git-Url: http://git.grml.org/?p=grml-live.git;a=blobdiff_plain;f=db%2Fdb-to-fai;fp=db%2Fdb-to-fai;h=074cca355377a2513959ae10fe5f668c2096e930;hp=0000000000000000000000000000000000000000;hb=d761bd6cdc6b54b67883e295a0dd1694e492bd7b;hpb=e56cc393d3419a72c74aa5084525b88c6a7cf854 diff --git a/db/db-to-fai b/db/db-to-fai new file mode 100755 index 0000000..074cca3 --- /dev/null +++ b/db/db-to-fai @@ -0,0 +1,49 @@ +#!/bin/sh +# Filename: db-to-fai +# Purpose: convert output of grml-live's sqlite database for use within FAI +# Authors: grml-team (grml.org) +# Bug-Reports: see http://grml.org/bugs/ +# License: This file is licensed under the GPL v2 or any later version. +################################################################################ + +if [ -z "$2" ] ; then + echo "Usage: $0 /path/to/grml-live.db " + exit 1 +fi + +DB="$1" +BUILD_ID="$2" + +if ! [ -r "$DB" ] ; then + echo "Error: can not access database ${DB}.">&2 + bailout 1 +fi + +TMPFILE=$(mktemp) + +bailout() { + rm -f "$TMPFILE" + [ -n "$1" ] && exit "$1" || exit 0 +} + +# get information from db: +if ! echo "select package,version FROM packages, build WHERE build.id = $BUILD_ID AND packages.build = build.id and status = 'ii';" | sqlite3 $DB > $TMPFILE ; then + echo "Error retrieving values from database ${DB}." >&2 + bailout 1 +else + # make sure we god some matches: + if ! grep -q '^[a-zA-Z]*' "$TMPFILE" ; then + echo "No packages retrieved from build id $BUILD_ID - wrong id?" >&2 + bailout 1 + fi + + # write fai header and package information to stdout: + echo "# package list of build $BUILD_ID from database $DB:" + echo "PACKAGES aptitude" + awk -F\| '{print $1"="$2}' "$TMPFILE" +fi + +# clean exit: +bailout + +## END OF FILE #################################################################