Package names may have a different number of fields separated by hyphen in their name, so it is not a simple task to extract the name using awk. But you can use the rpm command itself, using the --queryformat option. This let you ask rpm to print only the names of the packages, without version number and architecture. For example if you have some downloaded packages you can try
Code:
rpm -qp --queryformat '%{NAME}\n' *.rpm
the format is in C-style, with specific tags like NAME, VERSION, RELEASE, ARCH and so on. To see the whole (long) list of available tags, use