package org.tizen.cli.exec.sign;
import static org.tizen.common.util.FilenameUtil.addTailingPath;
+import static org.tizen.common.util.IOUtil.tryClose;
import static org.tizen.common.util.ObjectUtil.nvl;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.text.MessageFormat;
import java.util.List;
import static org.tizen.cli.exec.LaunchOptionConstants.OPT_NOCHECK;
import static org.tizen.cli.exec.LaunchOptionConstants.DESC_NOCHECK;
-import static org.tizen.cli.exec.LaunchOptionConstants.OPT_DEVELOP;
-import static org.tizen.cli.exec.LaunchOptionConstants.DESC_DEVELOP_PROFILE;
import org.tizen.cli.exec.AbstractLauncher;
import org.tizen.cli.exec.Help;
import org.tizen.common.sign.command.ReadSigningProfileFileCommand;
import org.tizen.common.sign.command.SignCommand;
import org.tizen.common.sign.preferences.SigningProfile;
+import org.tizen.common.sign.preferences.SigningProfileContainer;
+import org.tizen.common.sign.preferences.SigningProfileItem;
import org.tizen.common.util.FilenameUtil;
+import org.tizen.sdblib.util.IOUtil;
+import org.tizen.sdblib.util.StringUtil;
/**
// opts.addOption( OptionBuilder.hasArg().withLongOpt( OPT_EXCLUDE ).withDescription( DESC_EXCLUDE ).create( OPT_EXCLUDE.substring( 0, 1 ) ) );
opts.addOption( OptionBuilder.hasArg().withLongOpt( OPT_PROFILE ).withDescription( DESC_PROFILE ).create( OPT_PROFILE.substring( 0, 1 ) ) );
- opts.addOption( OptionBuilder.withLongOpt( OPT_DEVELOP ).withDescription( DESC_DEVELOP_PROFILE ).create( OPT_DEVELOP.substring( 0, 1 ) ) );
+// opts.addOption( OptionBuilder.withLongOpt( OPT_DEVELOP ).withDescription( DESC_DEVELOP_PROFILE ).create( OPT_DEVELOP.substring( 0, 1 ) ) );
return opts;
}
}
profilesFilePath = convertPath( profilesFilePath );
+ SigningProfileContainer container = new SigningProfileContainer() {
+ @Override
+ protected void preprocessForItemLoad(SigningProfile profile,
+ String version) {
+ // remove automatically insert dist1 for CLI
+ }
+ };
+ InputStream in = getFileHandler().read( profilesFilePath );
+ try {
+ String version = container.readProfileXML( in );
+ if ( version == null ) {
+ getPrompter().error( "Cannot load profiles in " + profilesFilePath );
+ return;
+ }
+
+ // if old version
+ if ( StringUtil.isEmpty( version ) ) {
+ getPrompter().notify( "Old version profile detected. Converting this automatically." );
+
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ container.writeProfileXML( outStream );
+ InputStream inForOut = new ByteArrayInputStream( outStream.toByteArray() );
+
+ try {
+ getFileHandler().write( profilesFilePath, inForOut );
+ } finally {
+ tryClose( in );
+ }
+ }
+ } finally {
+ IOUtil.tryClose( in );
+ }
+
final ReadSigningProfileFileCommand readProfile = new ReadSigningProfileFileCommand( profilesFilePath, profileName );
getExecutor().execute( readProfile );
logger.info( "Profiles file[{}] is read", profilesFilePath );
return ;
}
- if ( cmdLine.hasOption( OPT_DEVELOP ) ) {
- // Always add a developer certificate first because must be "signature1.xml"
- profile.createProfileItemForDeveloper();
+ for ( int i = 0; i < SigningProfile.MAX_DISTRIBUTOR; i++ ) {
+ SigningProfileItem item = profile.getProfileItem( i );
+ String keyLocation = item.getKeyLocation();
+ if ( ! StringUtil.isEmpty( keyLocation ) ) {
+ String msg = ( i == SigningProfile.AUTHOR_ORDINAL ) ? "Author certficate: " : "Distributor" + i + " certificate : ";
+ getPrompter().notify( msg + item.getKeyLocation() );
+ }
}
+ // deprecated --develop option
+// if ( cmdLine.hasOption( OPT_DEVELOP ) ) {
+// // Always add a developer certificate first because must be "signature1.xml"
+// profile.createProfileItemForDeveloper();
+// }
+
final SignCommand command = new SignCommand( baseDir, profile );
command.setIncludes( null );
command.setExcludes( excludes );