merge the scripts dealing with package/target metadata to remove some redundant code