]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/PackageEditor/src/org/tianocore/packaging/ForceInstallPkg.java
Initial import.
[mirror_edk2.git] / Tools / Source / PackageEditor / src / org / tianocore / packaging / ForceInstallPkg.java
1 /** @file
2 Java class ForceInstallPkg is used to install a package without DB check.
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 **/
13 package org.tianocore.packaging;
14
15 import java.io.*;
16 import java.util.jar.*;
17 import org.apache.xmlbeans.XmlException;
18
19 /**
20 Derived class from FrameworkPkg, installation skipping some checks.
21
22 @since PackageEditor 1.0
23 **/
24 public class ForceInstallPkg extends FrameworkPkg {
25
26 private String oldVer = null;
27
28 private String oldGuid = null;
29
30 /**
31 Constructor with parameters
32
33 @param s Package path to be installed
34 @param d Destination directory
35 **/
36 public ForceInstallPkg(String s, String d) {
37 super(s, d);
38
39 }
40
41 public void setOldVersion(String v) {
42 oldVer = v;
43 }
44
45 public void setOldGuid(String guid) {
46 oldGuid = guid;
47 }
48
49 /**
50 Set jar file to package name to be installed
51 **/
52 protected void pre_install() throws DirSame, IOException {
53 setJf(new JarFile(getPkg()));
54
55 }
56
57 /**
58 Update database file contents after install
59 **/
60 protected void post_install() throws IOException, XmlException {
61 //
62 // Get package info. from FDPManifest.xml file
63 //
64 setJf(new JarFile(getPkg()));
65 ManifestContents manFile = new ManifestContents(getManifestInputStream(getJf()));
66 setBName(manFile.getBaseName());
67 setPVer(manFile.getVersion());
68 setPGuid(manFile.getGuid());
69 getJf().close();
70
71 //
72 // Add force installed package info. into database file
73 //
74 setDbFile(new File(getWkSpace() + System.getProperty("file.separator") + FrameworkPkg.dbConfigFile));
75 setDfc(new DbFileContents(new File(getWkSpace() + System.getProperty("file.separator") + dbConfigFile)));
76 getDfc().updatePkgInfo(getBName(), oldVer, oldGuid, getWkDir().substring(getWkSpace().length() + 1), getPVer(),
77 getPGuid());
78 }
79
80 }