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;
// 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 );
+ // preload profile XML for convert
+ boolean bSuccess = tryConvert( cmdLine, profilesFilePath );
+ if ( ! bSuccess ) {
+ return;
}
+ // read a selected profile from XML
final ReadSigningProfileFileCommand readProfile = new ReadSigningProfileFileCommand( profilesFilePath, profileName );
getExecutor().execute( readProfile );
logger.info( "Profiles file[{}] is read", profilesFilePath );
return ;
}
+ // notify items of selected profile
for ( int i = 0; i < SigningProfile.MAX_DISTRIBUTOR; i++ ) {
SigningProfileItem item = profile.getProfileItem( i );
String keyLocation = item.getKeyLocation();
}
}
- // deprecated --develop option
-// if ( cmdLine.hasOption( OPT_DEVELOP ) ) {
-// // Always add a developer certificate first because must be "signature1.xml"
-// profile.createProfileItemForDeveloper();
-// }
+ if ( cmdLine.hasOption( OPT_DEVELOP ) ) {
+ // Always add a developer certificate first because must be "signature1.xml"
+ profile.createProfileItemForDeveloper();
+ }
+ // sign
final SignCommand command = new SignCommand( baseDir, profile );
command.setIncludes( null );
command.setExcludes( excludes );
getExecutor().execute( command );
}
+ protected boolean tryConvert(final CommandLine cmdLine, String profilesFilePath) throws IOException {
+ SigningProfileContainer container = null;
+
+ // preload profile XML for convert
+ if ( cmdLine.hasOption( OPT_DEVELOP ) ) {
+ container = new SigningProfileContainer();
+ } else {
+ 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 false;
+ }
+
+ // if old version, rewrite to new 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( inForOut );
+ }
+ }
+ } finally {
+ IOUtil.tryClose( in );
+ }
+
+ return true;
+ }
+
/**
* Return default profiles.xml's path
*