01: /**
02: * LibreSource
03: * Copyright (C) 2004-2008 Artenum SARL / INRIA
04: * http://www.libresource.org - contact@artenum.com
05: *
06: * This file is part of the LibreSource software,
07: * which can be used and distributed under license conditions.
08: * The license conditions are provided in the LICENSE.TXT file
09: * at the root path of the packaging that enclose this file.
10: * More information can be found at
11: * - http://dev.libresource.org/home/license
12: *
13: * Initial authors :
14: *
15: * Guillaume Bort / INRIA
16: * Francois Charoy / Universite Nancy 2
17: * Julien Forest / Artenum
18: * Claude Godart / Universite Henry Poincare
19: * Florent Jouille / INRIA
20: * Sebastien Jourdain / INRIA / Artenum
21: * Yves Lerumeur / Artenum
22: * Pascal Molli / Universite Henry Poincare
23: * Gerald Oster / INRIA
24: * Mariarosa Penzi / Artenum
25: * Gerard Sookahet / Artenum
26: * Raphael Tani / INRIA
27: *
28: * Contributors :
29: *
30: * Stephane Bagnier / Artenum
31: * Amadou Dia / Artenum-IUP Blois
32: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33: */package org.libresource.so6.core.exec;
34:
35: import org.libresource.so6.core.engine.DBType;
36: import org.libresource.so6.core.engine.PatchFile;
37: import org.libresource.so6.core.engine.util.FileUtils;
38:
39: import java.io.File;
40:
41: /**
42: * The <code>ApplyPatch</code> class is used to apply a set of patch on a
43: * local directory
44: *
45: * @author Smack
46: * @version 1.0, 26/05/04
47: * @see org.libresource.so6.core.exec.Main
48: * @since JDK1.4
49: */
50: public class ApplyPatch {
51: /**
52: * Instantiate and execute the applying patch process
53: *
54: * @param args
55: * <ul>
56: * <li>Path where we want to apply the patch set</li>
57: * <li>List of patch file path in the proper order</li>
58: * </ul>
59: * @throws Exception
60: */
61: public static void main(String[] args) throws Exception {
62: if (args.length < 2) {
63: System.err.println("Usage: dirToPatch patch1 patch2 ...");
64: System.err.println(" (1) dirToPatch: base path to patch");
65: System.err.println(" (2) patch(x): file path of the patch");
66: } else {
67: File[] patchList = new File[args.length - 1];
68:
69: for (int i = 0; i < patchList.length; i++) {
70: patchList[i] = new File(args[i + 1]);
71:
72: if (!patchList[i].exists()) {
73: System.err
74: .println("File "
75: + args[i + 1]
76: + " does not exist... Please set a valide path");
77: }
78: }
79:
80: File dbTypeFile = new File(FileUtils.createTmpDir(),
81: "dbType.data");
82: DBType dbType = new DBType(dbTypeFile.getPath(), "");
83:
84: for (int i = 0; i < patchList.length; i++) {
85: PatchFile pf = new PatchFile(patchList[i].getPath());
86: pf.patch(args[0], dbType);
87: }
88: }
89: }
90: }
|