Newbie and POSIX

I have created a package using Package Maker, i would then like to create a script that will zip this package up but keep the file extention as .pkg.zip
I am also trying in the script, once i have seleced the package to zip, that it automaticly remembers where the .pgk file was and places the .pkg.zip file in the same folder.
An error i get is that it will install the .pkg.zip on the front end of the HD, double click it to open the .zip file and it errors but duplicates the zip file

So far i have the script below, its basic and if any one can tell me where im going wrong, please do.



set zip_file to choose file with prompt "Choose file to Zip" of type {"pmkr"} without invisibles
get {result}
set result to zip_file
set zip_file2 to zip_file's name
set the zip_file to POSIX path of result & ".zip"
do shell script " /usr/bin/ditto -rsrc -c -k --keepParent " & zip_file & " " & zip_file2 & ".zip"


This works for me. I’ve used quoted form because your name may include spaces


set z to choose file with prompt "Choose file to Zip" of type "pmkr" without invisibles
-- You should know that pkg files created in other ways may not be of type pmkr.
set N to (info for z)'s name
tell application "Finder" to set P to z's container as alias
set zP to POSIX path of (P as text) & N
set zpz to zP & ".zip"
set toZip to quoted form of zP
set theZip to quoted form of zpz
do shell script " /usr/bin/ditto -rsrc -c -k --keepParent " & toZip & " " & theZip

I assume you know that in the contextual menu obtained by right-clicking the file, there is a Create Archive that will do the same thing.

Thanks for that, I have been reacking my brian for days on the solution