/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/** Command line interface for Pack200.
*/
class Driver {
boolean doPack = true;
boolean doUnpack = false;
boolean doRepack = false;
boolean doZip = true;
{
// Non-standard, undocumented "--unpack" switch enables unpack mode.
switch (arg0) {
case "--pack":
break;
case "--unpack":
doPack = false;
doUnpack = true;
break;
}
}
// Collect engine properties here:
if (doPack) {
} else {
}
// Collect argument properties here:
try {
for (;;) {
// Translate command line options to Pack200 properties:
break;
}
}
// Normal string or boolean.
// Normal boolean; convert to T/F.
}
}
} else {
// Collection property: pack.pass.file.cli.NNN
int idx = 1;
do {
}
}
}
}
// See if there is any other action to take.
}
}
System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.VERSION), Driver.class.getName(), "1.31, 07/05/05"));
return;
return;
} else {
break;
}
}
} catch (IllegalArgumentException ee) {
return;
}
// Deal with remaining non-engine properties:
switch (opt) {
case "--repack":
doRepack = true;
break;
case "--no-gzip":
break;
case "--log-file=":
break;
default:
}
}
} else {
//log = new BufferedOutputStream(out);
}
}
if (doRepack) {
// The first argument is the target JAR file.
// (Note: *.pac is nonstandard, but may be necessary
// if a host OS truncates file extensions.)
packfile));
}
// The optional second argument is the source JAR file.
// If only one file is given, it is the only JAR.
// It serves as both input and output.
}
doZip = false; // no need to zip the temporary file
}
// Accept jarfiles ending with .jar or .zip.
// Accept jarfile of "-" (stdout), but only if unpacking.
return;
}
if (doRepack)
else if (doPack)
doUnpack = false;
System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.DETECTED_ZIP_COMMENT), zipc));
System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.SKIP_FOR_REPACKED), jarfile));
doPack = false;
doUnpack = false;
doRepack = false;
}
}
try {
if (doPack) {
// Mode = Pack.
// Packfile must be -, *.gz, *.pack, or *.pac.
// Send warnings, etc., to stderr instead of stdout.
} else if (doZip) {
System.err.println(MessageFormat.format(RESOURCE.getString(DriverResource.WRITE_PACK_FILE), packfile));
}
} else {
System.err.println(MessageFormat.format(RESOURCE.getString(DriverResource.WIRTE_PACKGZ_FILE),packfile));
}
}
//in.close(); // p200 closes in but not out
}
// If the source and destination are the same,
// we will move the input JAR aside while regenerating it.
// This allows us to restore it if something goes wrong.
// On Windows target must be deleted see 4017593
if (!okBackup) {
throw new Error(MessageFormat.format(RESOURCE.getString(DriverResource.SKIP_FOR_MOVE_FAILED),bakfile));
} else {
// Open jarfile recovery bracket.
}
}
if (doUnpack) {
// Mode = Unpack.
else
}
else
// p200 closes in but not out
}
// At this point, we have a good jarfile (or newfile, if -r)
}
// On success, abort jarfile recovery bracket.
bakfile = "";
}
} finally {
// Close jarfile recovery bracket.
}
// In all cases, delete temporary *.pack.
}
}
static private
: base.getParentFile();
}
static private
if (!full) {
break;
}
}
}
static private
byte[] tail = new byte[1000];
// Skip sig4, disks4, entries4, clen4, coff4, cmt2
i += 4+4+4+4+4+2;
return "";
}
}
return "";
}
}
(""
+"--repack $ \n -r +>- @--repack $ \n"
+"--no-gzip $ \n -g +>- @--no-gzip $ \n"
+"--strip-debug $ \n -G +>- @--strip-debug $ \n"
+"--no-keep-file-order $ \n -O +>- @--no-keep-file-order $ \n"
+"--segment-limit= *> = \n -S +> @--segment-limit= = \n"
+"--effort= *> = \n -E +> @--effort= = \n"
+"--deflate-hint= *> = \n -H +> @--deflate-hint= = \n"
+"--modification-time= *> = \n -m +> @--modification-time= = \n"
+"--pass-file= *> &\0 \n -P +> @--pass-file= &\0 \n"
+"--unknown-attribute= *> = \n -U +> @--unknown-attribute= = \n"
+"--class-attribute= *> &\0 \n -C +> @--class-attribute= &\0 \n"
+"--field-attribute= *> &\0 \n -F +> @--field-attribute= &\0 \n"
+"--method-attribute= *> &\0 \n -M +> @--method-attribute= &\0 \n"
+"--code-attribute= *> &\0 \n -D +> @--code-attribute= &\0 \n"
+"--config-file= *> . \n -f +> @--config-file= . \n"
// Negative options as required by CLIP:
+"--no-strip-debug !--strip-debug \n"
+"--gzip !--no-gzip \n"
+"--keep-file-order !--no-keep-file-order \n"
// Non-Standard Options
+"--verbose $ \n -v +>- @--verbose $ \n"
+"--quiet !--verbose \n -q +>- !--verbose \n"
+"--log-file= *> = \n -l +> @--log-file= = \n"
//+"--java-option= *> = \n -J +> @--java-option= = \n"
+"--version . \n -V +> @--version . \n"
+"--help . \n -? +> @--help . \n -h +> @--help . \n"
// Termination:
+"-- . \n" // end option sequence here
+"- +? >- . \n" // report error if -XXX present; else use stdout
);
// Note: Collection options use "\0" as a delimiter between arguments.
// For Java version of unpacker (used for testing only):
(""
+"--deflate-hint= *> = \n -H +> @--deflate-hint= = \n"
+"--verbose $ \n -v +>- @--verbose $ \n"
+"--quiet !--verbose \n -q +>- !--verbose \n"
+"--remove-pack-file $ \n -r +>- @--remove-pack-file $ \n"
+"--log-file= *> = \n -l +> @--log-file= = \n"
+"--config-file= *> . \n -f +> @--config-file= . \n"
// Termination:
+"-- . \n" // end option sequence here
+"- +? >- . \n" // report error if -XXX present; else use stdin
+"--version . \n -V +> @--version . \n"
+"--help . \n -? +> @--help . \n -h +> @--help . \n"
);
//Pack200.Packer.PROGRESS, "--progress=",
};
//Pack200.Unpacker.PROGRESS, "--progress=",
};
/*-*
* Remove a set of command-line options from args,
* storing them in the map in a canonicalized form.
* <p>
* The options string is a newline-separated series of
* option processing specifiers.
*/
private static
//System.out.println(args+" // "+properties);
// Convert options string into optLines dictionary.
}
throw new RuntimeException(MessageFormat.format(RESOURCE.getString(DriverResource.DUPLICATE_OPTION), optline.trim()));
}
// State machine for parsing a command line.
for (;;) {
// One trip through this loop per argument.
// Multiple trips per option only if several options per argument.
if (pbp.hasPrevious()) {
} else {
// No more arguments at all.
break doArgs;
}
// One time through this loop for each matching arg prefix.
// Match some prefix of the argument to a key in optmap.
for (;;) {
// Decide on a smaller prefix to search for.
// pfxmap.lastKey is no shorter than any prefix in optmap.
// (Note: We could cut opt down to its common prefix with
// pfxmap.lastKey, but that wouldn't save many cycles.)
}
// Execute the option processing specs for this opt.
// If no actions are taken, then look for a shorter prefix.
boolean didAction = false;
boolean isError = false;
int sidx = 0;
// Deal with '+'/'*' prefixes (spec conditions).
boolean ok;
switch (specop) {
case '+':
// + means we want an non-empty val suffix.
break;
case '*':
// * means we accept empty or non-empty
ok = true;
break;
default:
// No condition prefix means we require an exact
// match, as indicated by an empty val suffix.
break;
}
switch (specop) {
case '.': // terminate the option sequence
break doArgs;
case '?': // abort the option sequence
isError = true;
break eachSpec;
case '@': // change the effective opt name
break;
case '>': // shift remaining arg val to next arg
val = "";
break;
case '!': // negation option
didAction = true;
break;
case '$': // normal "boolean" option
// If there is a given spec token, store it.
} else {
boolval = "1";
} else {
// Increment any previous value as a numeral.
}
}
didAction = true;
break;
case '=': // "string" option
case '&': // "collection" option
// Read an option.
if (pbp.hasPrevious()) {
} else {
isError = true;
break eachSpec;
}
if (append) {
// Append new val to old with embedded delim.
}
}
didAction = true;
break;
default:
throw new RuntimeException(MessageFormat.format(RESOURCE.getString(DriverResource.BAD_SPEC),opt, spec));
}
}
// Done processing specs.
continue doArgs;
}
// The specs should have done something, but did not.
// Remove anything pushed during these specs.
}
if (isError) {
throw new IllegalArgumentException(resultString);
}
if (optlen == 0) {
// We cannot try a shorter matching option.
break tryOpt;
}
}
// If we come here, there was no matching option.
// So, push back the argument, and return to caller.
break doArgs;
}
// Report number of arguments consumed.
// Report any unconsumed partial argument.
while (pbp.hasPrevious()) {
}
//System.out.println(args+" // "+properties+" -> "+resultString);
return resultString;
}
}