mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
handle upload
This commit is contained in:
parent
00e03e7520
commit
75cea8928a
@ -19,13 +19,18 @@ import java.util.zip.ZipFile;
|
|||||||
* @author gregd
|
* @author gregd
|
||||||
*/
|
*/
|
||||||
public class ManifestLoader {
|
public class ManifestLoader {
|
||||||
|
|
||||||
private static final String JAR_MANIFEST_REL_PATH = "META-INF/MANIFEST.MF";
|
private static final String JAR_MANIFEST_REL_PATH = "META-INF/MANIFEST.MF";
|
||||||
|
|
||||||
public static Attributes loadInputStream(InputStream is) throws IOException {
|
public static Attributes loadInputStream(InputStream is) throws IOException {
|
||||||
Manifest manifest = new Manifest(is);
|
Manifest manifest = loadManifest(is);
|
||||||
return manifest.getMainAttributes();
|
return manifest.getMainAttributes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Manifest loadManifest(InputStream is) throws IOException {
|
||||||
|
return new Manifest(is);
|
||||||
|
}
|
||||||
|
|
||||||
public static Attributes loadFromJar(File jarFile) throws IOException {
|
public static Attributes loadFromJar(File jarFile) throws IOException {
|
||||||
ZipFile zipFile = new ZipFile(jarFile);
|
ZipFile zipFile = new ZipFile(jarFile);
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.jar.Attributes;
|
import java.util.jar.Attributes;
|
||||||
|
import java.util.jar.Manifest;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.logging.SimpleFormatter;
|
import java.util.logging.SimpleFormatter;
|
||||||
@ -45,6 +46,7 @@ import org.xml.sax.SAXException;
|
|||||||
public class ModuleUpdates {
|
public class ModuleUpdates {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(ModuleUpdates.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ModuleUpdates.class.getName());
|
||||||
|
|
||||||
static {
|
static {
|
||||||
LOGGER.addHandler(new StreamHandler(System.out, new SimpleFormatter()));
|
LOGGER.addHandler(new StreamHandler(System.out, new SimpleFormatter()));
|
||||||
}
|
}
|
||||||
@ -183,6 +185,7 @@ public class ModuleUpdates {
|
|||||||
ModuleVersionNumbers thisVersNums = versNums.get(moduleName);
|
ModuleVersionNumbers thisVersNums = versNums.get(moduleName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
LOGGER.log(Level.INFO, "Updating for module name: " + moduleName);
|
||||||
updateProjXml(moduleDir, versNums);
|
updateProjXml(moduleDir, versNums);
|
||||||
|
|
||||||
if (thisVersNums != null) {
|
if (thisVersNums != null) {
|
||||||
@ -224,22 +227,29 @@ public class ModuleUpdates {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Attributes attributes;
|
Manifest manifest;
|
||||||
try (FileInputStream manifestIs = new FileInputStream(manifestFile)) {
|
try (FileInputStream manifestIs = new FileInputStream(manifestFile)) {
|
||||||
attributes = ManifestLoader.loadInputStream(manifestIs);
|
manifest = ManifestLoader.loadManifest(manifestIs);
|
||||||
|
}
|
||||||
|
Attributes attributes = manifest.getMainAttributes();
|
||||||
|
|
||||||
|
boolean updated = updateAttr(attributes, IMPL_KEY, Integer.toString(thisVersNums.getImplementation()), true);
|
||||||
|
updated = updateAttr(attributes, SPEC_KEY, thisVersNums.getSpec().getSemVerStr(), true) || updated;
|
||||||
|
updated = updateAttr(attributes, RELEASE_KEY, thisVersNums.getRelease().getFullReleaseStr(), true) || updated;
|
||||||
|
if (updated) {
|
||||||
|
try (FileOutputStream manifestOut = new FileOutputStream(manifestFile)) {
|
||||||
|
manifest.write(manifestOut);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAttr(attributes, IMPL_KEY, Integer.toString(thisVersNums.getImplementation()), true);
|
private static boolean updateAttr(Attributes attributes, String key, String val, boolean updateOnlyIfPresent) {
|
||||||
updateAttr(attributes, SPEC_KEY, thisVersNums.getSpec().getSemVerStr(), true);
|
|
||||||
updateAttr(attributes, RELEASE_KEY, thisVersNums.getRelease().getFullReleaseStr(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void updateAttr(Attributes attributes, String key, String val, boolean updateOnlyIfPresent) {
|
|
||||||
if (updateOnlyIfPresent && attributes.getValue(key) == null) {
|
if (updateOnlyIfPresent && attributes.getValue(key) == null) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes.putValue(key, val);
|
attributes.putValue(key, val);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateProjXml(File moduleDir, Map<String, ModuleVersionNumbers> versNums)
|
private static void updateProjXml(File moduleDir, Map<String, ModuleVersionNumbers> versNums)
|
||||||
@ -282,7 +292,6 @@ public class ModuleUpdates {
|
|||||||
|
|
||||||
// pretty print XML
|
// pretty print XML
|
||||||
//transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
//transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||||
|
|
||||||
DOMSource source = new DOMSource(projectXmlDoc);
|
DOMSource source = new DOMSource(projectXmlDoc);
|
||||||
try (FileOutputStream xmlOut = new FileOutputStream(projXmlFile)) {
|
try (FileOutputStream xmlOut = new FileOutputStream(projXmlFile)) {
|
||||||
StreamResult result = new StreamResult(xmlOut);
|
StreamResult result = new StreamResult(xmlOut);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user