Use createrepo, its man page should be more than enough.

H.