Fixed some bugs in generatepkg.sh.