Thanks for your reply, I first tried awk then gawk and get the following error:
# gawk '/^host/{h0=$0;continue}{print h0":"$0}' pkgs.txt |sort -d |awk -F':' '{if(h0!=$1){h0=$1;print h0} print $2}'
gawk: (FILENAME=pkgs.txt FNR=1) fatal: `continue' outside a loop is not allowed