From: donghyuk.yang Date: Mon, 3 Jun 2013 02:47:43 +0000 (+0900) Subject: [Title] Install package to the device for pkgcmd tool if project is efl X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d9d90147304d00d748bdf9fb6a058db8a589662;p=sdk%2Fide%2Fnativeplatform-eplugin.git [Title] Install package to the device for pkgcmd tool if project is efl --- diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java index 9c4867d..4c20bed 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java @@ -99,6 +99,7 @@ import org.tizen.nativeplatform.build.PlatformConfigurationManager; import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils; import org.tizen.nativeplatform.launch.wizards.ShowPackageStatusDialog; import org.tizen.nativeplatform.pkg.commander.IPackager; +import org.tizen.nativeplatform.pkg.commander.IPkgCommander; import org.tizen.nativeplatform.pkg.commander.PackagerFactory; import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget; import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; @@ -358,7 +359,12 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate { monitor.subTask(PlatformLaunchMessages.INSTALL_PACKAGES_TO_DEVICE); if (selecteDvPkgs != null && !selecteDvPkgs.isEmpty()) { - launchUtils.installPkgsToDevice(selecteDvPkgs, monitor); + if (PlatformProjectUtil.isEFLApplication(platformProject)) { + launchUtils.installPkgsToDevice(selecteDvPkgs, IPkgCommander.TOOL.PKGCMD, + monitor); + } else { + launchUtils.installPkgsToDevice(selecteDvPkgs, monitor); + } } monitor.done(); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchUtils.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchUtils.java index 3ce65b3..b722473 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchUtils.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchUtils.java @@ -103,7 +103,8 @@ public class PlatformLaunchUtils { PkgMgrInitializer initializer = new PkgMgrInitializer(target); initializer.initRootstrapRepoInfo(); } - return installPkgs(target.getRootstrapCommander(), packages, monitor); + return installPkgs(target.getRootstrapCommander(), IPkgCommander.TOOL.ZYPPER, packages, + monitor); } public boolean installPkgsToDevice(List packages, IProgressMonitor monitor) @@ -116,11 +117,25 @@ public class PlatformLaunchUtils { PkgMgrInitializer initializer = new PkgMgrInitializer(target); initializer.initDeviceRepoInfo(); } - return installPkgs(target.getDeviceCommander(), packages, monitor); + return installPkgs(target.getDeviceCommander(), IPkgCommander.TOOL.ZYPPER, packages, + monitor); } - private boolean installPkgs(IPkgCommander commander, List packages, + public boolean installPkgsToDevice(List packages, IPkgCommander.TOOL type, IProgressMonitor monitor) throws InterruptedException { + if (!target.getDevice().isOnline()) { + newException(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE); + } else if (!target.getDevice().isRoot()) { + newException(PlatformLaunchMessages.DEVICE_IS_NOT_ROOT_ON); + } else { + PkgMgrInitializer initializer = new PkgMgrInitializer(target); + initializer.initDeviceRepoInfo(); + } + return installPkgs(target.getDeviceCommander(), type, packages, monitor); + } + + private boolean installPkgs(IPkgCommander commander, IPkgCommander.TOOL type, + List packages, IProgressMonitor monitor) throws InterruptedException { monitor.beginTask("Installing packages to rootstrap", 2); List paths = new ArrayList(); @@ -130,7 +145,8 @@ public class PlatformLaunchUtils { paths.add(filePath.trim()); } - ICommandStatus status = commander.installLocalPkg(paths.toArray(new String[0]), monitor); + ICommandStatus status = commander.installLocalPkg(paths.toArray(new String[0]), type, + monitor); monitor.worked(1); if (!status.isOk()) { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java index fa75bdf..e66a94f 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java @@ -53,8 +53,10 @@ import org.tizen.nativeplatform.build.PlatformConfigurationManager; import org.tizen.nativeplatform.launch.PlatformLaunchMessages; import org.tizen.nativeplatform.launch.wizard.pages.PlatformLaunchSettingAppPage; import org.tizen.nativeplatform.launch.wizard.pages.PlatformLaunchSettingBinPage; +import org.tizen.nativeplatform.pkg.commander.IPkgCommander; import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget; import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; +import org.tizen.nativeplatform.util.PlatformProjectUtil; import org.tizen.sdblib.IDevice; public class PlatformLaunchWizard extends Wizard implements IPageChangingListener, @@ -224,7 +226,12 @@ public class PlatformLaunchWizard extends Wizard implements IPageChangingListene monitor.subTask(PlatformLaunchMessages.INSTALL_PACKAGES_TO_DEVICE); if (selecteDvPkgs != null && !selecteDvPkgs.isEmpty()) { - launchUtil.installPkgsToDevice(selecteDvPkgs, monitor); + if (PlatformProjectUtil.isEFLApplication(project)) { + launchUtil.installPkgsToDevice(selecteDvPkgs, + IPkgCommander.TOOL.PKGCMD, monitor); + } else { + launchUtil.installPkgsToDevice(selecteDvPkgs, monitor); + } } monitor.done(); } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgCommander.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgCommander.java index 7179f2d..7a5f586 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgCommander.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgCommander.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + package org.tizen.nativeplatform.pkg.commander; import java.util.List; @@ -8,6 +35,10 @@ import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver; import org.tizen.nativeplatform.pkgmgr.model.Package; public interface IPkgCommander { + + enum TOOL { + RPM, ZYPPER, PKGCMD + } PackageManagerOuputReceiver getOutputReceiver(); @@ -24,6 +55,8 @@ public interface IPkgCommander { String[] getName(String pkg); String[] getVer(String pkg); + + ICommandStatus installLocalPkg(String[] files, TOOL type, IProgressMonitor monitor); ICommandStatus installLocalPkg(String[] files, IProgressMonitor monitor); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java index 32dc484..0d53126 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + package org.tizen.nativeplatform.pkg.commander.rpm; import java.io.File; @@ -14,6 +41,7 @@ import org.slf4j.LoggerFactory; import org.tizen.common.ui.view.console.ConsoleManager; import org.tizen.nativeplatform.pkg.commander.ICommandStatus; import org.tizen.nativeplatform.pkg.commander.IPkgCommander; +import org.tizen.nativeplatform.pkg.tools.PkgcmdTool; import org.tizen.nativeplatform.pkg.tools.RpmTool; import org.tizen.nativeplatform.pkg.tools.ZypperTool; import org.tizen.nativeplatform.pkg.tools.ZypperXmlParser; @@ -73,7 +101,7 @@ public abstract class RpmCommanderCommon implements IPkgCommander { public RpmCommanderCommon(String consoleName) { rec = getNewOuputReceiver(consoleName); } - + public PackageManagerOuputReceiver getOutputReceiver() { return rec; } @@ -234,7 +262,7 @@ public abstract class RpmCommanderCommon implements IPkgCommander { return result.toArray(new String[0]); } - public ICommandStatus installLocalPkg(String[] files, IProgressMonitor monitor) { + public ICommandStatus installLocalPkg(String[] files, TOOL type, IProgressMonitor monitor) { ICommandStatus status = copyFiles(files); if (!status.isOk()) { logger.error(status.getMessage(), status.getException()); @@ -244,17 +272,28 @@ public abstract class RpmCommanderCommon implements IPkgCommander { List value = status.getValues(); if (value != null && value.size() > 0) { changeUpdateMode(); - /* - * String command = makeCommand(getResetRpmDb(), - * RpmTool.installCommand(value.toArray(new String[0]))); - */ - String command = makeCommand(getResetRpmDb(), - ZypperTool.installLocalCommand(value.toArray(new String[0]))); - status = execute(command, monitor); + if (type == TOOL.RPM) { + String command = makeCommand(getResetRpmDb(), + RpmTool.installCommand(value.toArray(new String[0]))); + status = execute(command, monitor); + } else if (type == TOOL.ZYPPER) { + String command = makeCommand(getResetRpmDb(), + ZypperTool.installLocalCommand(value.toArray(new String[0]))); + status = execute(command, monitor); + } else if (type == TOOL.PKGCMD) { + String command = makeCommand(getResetRpmDb(), + PkgcmdTool.installCommand(value.toArray(new String[0]))); + status = execute(command, monitor); + } } + return status; } + public ICommandStatus installLocalPkg(String[] files, IProgressMonitor monitor) { + return installLocalPkg(files, TOOL.ZYPPER, monitor); + } + public ICommandStatus installLocalPkg(String file, IProgressMonitor monitor) { String[] files = { file }; return installLocalPkg(files, monitor); @@ -280,9 +319,9 @@ public abstract class RpmCommanderCommon implements IPkgCommander { /* * Following error can be occurred in case of using zypper. - * - * Error: Subprocess failed. Error: RPM failed: error: db4 error(-30971) from - * dbenv->open: DB_VERSION_MISMATCH: Database environment version + * + * Error: Subprocess failed. Error: RPM failed: error: db4 error(-30971) + * from dbenv->open: DB_VERSION_MISMATCH: Database environment version * mismatch error: cannot open Packages index using db4 - (-30971) * error: cannot open Packages database in /var/lib/rpm error: db4 * error(-30971) from dbenv->open: DB_VERSION_MISMATCH: Database diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/tools/PkgcmdTool.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/tools/PkgcmdTool.java new file mode 100644 index 0000000..7bb052c --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/tools/PkgcmdTool.java @@ -0,0 +1,59 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.nativeplatform.pkg.tools; + +public class PkgcmdTool { + + private final static String WS = " "; + private final static String TOOL = "pkgcmd"; + private final static String INSTALL_OP = "--install"; + + private final static String PKGTYPE_OP = "--package-type"; + private final static String PKGPATH_OP = "--package-path"; + + private final static String QUIET_OP = "--quiet"; + + public static String installCommand(String[] list) { + return installCommand(list[0]); + } + + public static String installCommand(String file) { + return makeCommand(INSTALL_OP, QUIET_OP, PKGTYPE_OP, "rpm", PKGPATH_OP, file); + } + + private static String makeCommand(String... options) { + String command = TOOL + WS; + for (String op : options) { + op = op.trim(); + if (op.isEmpty()) + continue; + command += op + WS; + } + return command.trim(); + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/tools/RpmTool.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/tools/RpmTool.java index 11b8687..21e7a90 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/tools/RpmTool.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/tools/RpmTool.java @@ -1,6 +1,31 @@ -package org.tizen.nativeplatform.pkg.tools; +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ -import java.util.List; +package org.tizen.nativeplatform.pkg.tools; public class RpmTool { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/tools/ZypperTool.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/tools/ZypperTool.java index 7488f70..d219e8c 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/tools/ZypperTool.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/tools/ZypperTool.java @@ -1,6 +1,31 @@ -package org.tizen.nativeplatform.pkg.tools; +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ -import java.util.List; +package org.tizen.nativeplatform.pkg.tools; public class ZypperTool {