#
# Copyright (c) 2011-2013 LAAS/CNRS
# All rights reserved.
#
# Permission to use, copy, modify, and distribute this software for any purpose
# with or without   fee is hereby granted, provided   that the above  copyright
# notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS  SOFTWARE INCLUDING ALL  IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR  BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR  ANY DAMAGES WHATSOEVER RESULTING  FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION,   ARISING OUT OF OR IN    CONNECTION WITH THE USE   OR
# PERFORMANCE OF THIS SOFTWARE.
#
#                                           Anthony Mallet on Sun Oct 16 2011
#

# --- rmpkg ----------------------------------------------------------------
#
proc rmpkg { db pkg } {
  set db [opendb $db]

  $db eval { select id,tag from pkg where pkgname = $pkg } {
    infox "deleting $pkg for $tag"
    $db eval { delete from pkg where id is $id }
    $db eval { delete from meta where id is $id }
    $db eval { delete from breaks where id is $id or breaks is $id }
    $db eval { delete from category where id is $id }
    $db eval { delete from log where id is $id }
  }

  closedb $db on
  return
}


# --- rmarch ---------------------------------------------------------------
#
proc rmarch { db arch } {
  set db [opendb $db]

  $db eval { select id,pkgname from pkg where tag = $arch } {
    infox "deleting $pkgname for $arch"
    $db eval { delete from pkg where id is $id }
    $db eval { delete from meta where id is $id }
    $db eval { delete from breaks where id is $id or breaks is $id }
    $db eval { delete from category where id is $id }
    $db eval { delete from log where id is $id }
  }

  infox "deleting $arch logs"
  $db eval { delete from session where tag is $tag }

  closedb $db on
  return
}


# --- runarch --------------------------------------------------------------
#
proc runarch { db arch } {
  set db [opendb $db]

  infox "setting $arch as running"

  set now [clock seconds]
  $db eval {
    insert into session (tag, running, date, updates, log)
    values ($arch, 1, $now, 0, NULL)
  }

  closedb $db off
  return
}
package provide rbulk-report 20260610
