{-# LANGUAGE OverloadedStrings #-}
module BDCS.RPM.Sources(mkSource)
where
import Codec.RPM.Tags(Tag, findStringTag)
import Database.Esqueleto(Key)
import qualified Data.Text as T
import BDCS.DB(Projects, Sources(..))
import BDCS.Exceptions(DBException(..), throwIfNothing)
mkSource :: [Tag] -> Key Projects -> Sources
mkSource tags projectId = let
license = T.pack $ findStringTag "License" tags `throwIfNothing` MissingRPMTag "License"
version = T.pack $ findStringTag "Version" tags `throwIfNothing` MissingRPMTag "Version"
source_ref = "SOURCE_REF"
in
Sources projectId license version source_ref