#!/bin/bash

LOCKSFILE=/etc/zypp/locks
NEWLOCKSFILE=/tmp/newlocks

append_new_lock(){
  echo $# $1
  case "$#" in
    1 )
    echo "
    solvable_name: $1
    string_type: glob
    " >> ${NEWLOCKSFILE}
    ;;
    2 ) #TODO version
    echo "
    solvable_name: $1
    string_type: glob
    " >> ${NEWLOCKSFILE}
    ;;
    3 ) #TODO version
    echo "
    solvable_name: $1
    string_type: glob
    " >> ${NEWLOCKSFILE}
    ;;
  esac

  }

  die() {
    echo $1
    exit 1
  }

rm $NEWLOCKSFILE || die "cannot remove previously converted locks"
while read line
  do 
    append_new_lock $line
  done < ${LOCKSFILE}
  echo "complete"
