public void build() {
        try {
            //create package info
            PackageInfo pInfo;
            PackageName pName = new PackageName(id);
            PackageVersion pVer = new PackageVersion(version);
            PackageDescription pDesc = new PackageDescription(name);
            PackageMaintainer pMain = new PackageMaintainer(author, email);
            PackageArchitecture pArch = new PackageArchitecture(arch);
            PackageSection pSect = new PackageSection("misc");
            PackagePriority pPrior = PackagePriority.OPTIONAL;
            if(json==null) {
                json = "";
            }
            PackageSource pSource = new PackageSource(json);
                pInfo = new PackageInfo(pName, pVer, pArch, pMain,
                        pDesc, pSect, pPrior, pSource);
            if(postinst!=null) {
                pInfo.setMaintainerScript(new FileMaintainerScript(
                        MaintainerScript.Type.POSTINST, postinst));
            }
            if(prerm!=null) {
                pInfo.setMaintainerScript(new FileMaintainerScript(
                        MaintainerScript.Type.PRERM, prerm));
            }
            if(pmPostInstall!=null) {
                pInfo.setPalmScript(pmPostInstall, MaintainerScript.Type.POSTINST);
            }
            if(pmPreRemove!=null) {
                pInfo.setPalmScript(pmPreRemove, MaintainerScript.Type.PRERM);
            }
            for(int i=0; i<depends.size(); i++) {
                pInfo.addDependency(new PackageDependency(depends.get(i)));
            }
            //get destination ipkg file if not specified
            if(destIpkg==null) {
                destIpkg = new File(source.getParentFile(), id + "_" +
                        version + "_all.ipk");
            }
            if(destIpkg.exists()) {
                destIpkg.delete();
            }
            //copy files
            copyDir(source, tempDir);
            //build ipkg file
            PackageBuilder builder = new WebOSPackageBuilder(pInfo);
            builder.write(destIpkg, baseTemp);
            deleteDirectory(baseTemp);
        } catch(Exception e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
    }