From 402e9d71ef133a6d013296b3371935f0e94d0468 Mon Sep 17 00:00:00 2001 From: orbiter Date: Sun, 4 Dec 2011 07:22:13 +0000 Subject: [PATCH] changed ording on release files: main criteria is not the svn any more; releases are now ordered by - release number - date - svn number additionally there is a new option to remove the svn number completely git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@8135 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/ConfigUpdate_p.java | 67 ++++++++-------- readme.txt | 2 +- .../net/yacy/peers/operation/yacyRelease.java | 2 +- .../net/yacy/peers/operation/yacyVersion.java | 76 ++++++++++++------- 4 files changed, 82 insertions(+), 65 deletions(-) diff --git a/htroot/ConfigUpdate_p.java b/htroot/ConfigUpdate_p.java index c7c448ae4..39dc53875 100644 --- a/htroot/ConfigUpdate_p.java +++ b/htroot/ConfigUpdate_p.java @@ -9,7 +9,7 @@ // $LastChangedBy$ // // LICENSE -// +// // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or @@ -26,6 +26,7 @@ import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.Date; import java.util.NavigableSet; import java.util.Set; @@ -40,7 +41,6 @@ import net.yacy.peers.operation.yacyBuildProperties; import net.yacy.peers.operation.yacyRelease; import net.yacy.peers.operation.yacyVersion; import net.yacy.search.Switchboard; - import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; @@ -62,12 +62,12 @@ public class ConfigUpdate_p { } else { prop.put("candeploy", "0"); } - + prop.put("candeploy_configCommit", "0"); prop.put("candeploy_autoUpdate", "0"); prop.put("candeploy_downloadsAvailable", "0"); - + if (post != null) { // check if update is supposed to be installed and a release is defined if (post.containsKey("update") && !post.get("releaseinstall", "").isEmpty()) { @@ -77,16 +77,16 @@ public class ConfigUpdate_p { prop.put("candeploy", "2"); // display nothing else return prop; } - + if (post.containsKey("downloadRelease")) { // download a release final String release = post.get("releasedownload", ""); if (!release.isEmpty()) { try { yacyRelease versionToDownload = new yacyRelease(new DigestURI(release)); - + // replace this version with version which contains public key - yacyRelease.DevAndMainVersions allReleases = yacyRelease.allReleases(false, false); + final yacyRelease.DevAndMainVersions allReleases = yacyRelease.allReleases(false, false); final Set mostReleases = versionToDownload.isMainRelease() ? allReleases.main : allReleases.dev; for (final yacyRelease rel : mostReleases) { if (rel.equals(versionToDownload)) { @@ -101,7 +101,7 @@ public class ConfigUpdate_p { } } } - + if (post.containsKey("checkRelease")) { yacyRelease.allReleases(true, false); } @@ -117,7 +117,7 @@ public class ConfigUpdate_p { } } } - + if (post.containsKey("autoUpdate")) { final yacyRelease updateVersion = yacyRelease.rulebasedUpdateInfo(true); if (updateVersion == null) { @@ -142,7 +142,7 @@ public class ConfigUpdate_p { } } } - + if (post.containsKey("configSubmit")) { prop.put("candeploy_configCommit", "1"); sb.setConfig("update.process", ("manual".equals(post.get("updateMode", "manual"))) ? "manual" : "auto"); @@ -152,7 +152,7 @@ public class ConfigUpdate_p { sb.setConfig("update.onlySignedFiles", (post.getBoolean("onlySignedFiles", false)) ? "1" : "0"); } } - + // version information final String versionstring = yacyBuildProperties.getVersion() + "/" + yacyBuildProperties.getSVNRevision(); prop.putHTML("candeploy_versionpp", versionstring); @@ -163,18 +163,18 @@ public class ConfigUpdate_p { thisVersion = (float) (Math.round(thisVersion*1000.0)/1000.0); } catch (final NumberFormatException e) {} - + // list downloaded releases final File[] downloadedFiles = sb.releasePath.listFiles(); // list can be null if RELEASE directory has been deleted manually final int downloadedFilesNum = (downloadedFiles == null) ? 0 : downloadedFiles.length; - + prop.put("candeploy_deployenabled", (downloadedFilesNum == 0) ? "0" : ((devenvironment) ? "1" : "2")); // prevent that a developer-version is over-deployed - + final NavigableSet downloadedReleases = new TreeSet(); for (final File downloaded : downloadedFiles) { try { - yacyRelease release = new yacyRelease(downloaded); + final yacyRelease release = new yacyRelease(downloaded); downloadedReleases.add(release); } catch (final RuntimeException e) { // not a valid release @@ -186,11 +186,11 @@ public class ConfigUpdate_p { } } // latest downloaded release - yacyVersion dflt = (downloadedReleases.isEmpty()) ? null : downloadedReleases.last(); + final yacyVersion dflt = (downloadedReleases.isEmpty()) ? null : downloadedReleases.last(); // check if there are any downloaded releases and if there are enable the update buttons prop.put("candeploy_downloadsAvailable", (downloadedReleases.isEmpty()) ? "0" : "1"); prop.put("candeploy_deployenabled_buttonsActive", (downloadedReleases.isEmpty() || devenvironment) ? "0" : "1"); - + int relcount = 0; for(final yacyRelease release : downloadedReleases) { prop.put("candeploy_downloadedreleases_" + relcount + "_name", ((release.isMainRelease()) ? "main" : "dev") + " " + release.getReleaseNr() + "/" + release.getSvn()); @@ -204,29 +204,28 @@ public class ConfigUpdate_p { // list remotely available releases final yacyRelease.DevAndMainVersions releasess = yacyRelease.allReleases(false, false); relcount = 0; - - // main + + final ArrayList rlist = new ArrayList(); + final Set remoteDevReleases = releasess.dev; + remoteDevReleases.removeAll(downloadedReleases); + for (final yacyRelease release : remoteDevReleases) { + rlist.add(release); + } final Set remoteMainReleases = releasess.main; remoteMainReleases.removeAll(downloadedReleases); for (final yacyRelease release : remoteMainReleases) { - prop.put("candeploy_availreleases_" + relcount + "_name", ((release.isMainRelease()) ? "main" : "dev") + " " + release.getReleaseNr() + "/" + release.getSvn()); - prop.put("candeploy_availreleases_" + relcount + "_url", release.getUrl().toString()); - prop.put("candeploy_availreleases_" + relcount + "_signatures", (release.getPublicKey()!=null?"1":"0")); - prop.put("candeploy_availreleases_" + relcount + "_selected", "0"); - relcount++; + rlist.add(release); } - - // dev - dflt = (releasess.dev.isEmpty()) ? null : releasess.dev.last(); - final Set remoteDevReleases = releasess.dev; - remoteDevReleases.removeAll(downloadedReleases); - for (final yacyRelease release : remoteDevReleases) { + yacyRelease release; + for (int i = rlist.size() - 1; i >= 0; i--) { + release = rlist.get(i); prop.put("candeploy_availreleases_" + relcount + "_name", ((release.isMainRelease()) ? "main" : "dev") + " " + release.getReleaseNr() + "/" + release.getSvn()); prop.put("candeploy_availreleases_" + relcount + "_url", release.getUrl().toString()); prop.put("candeploy_availreleases_" + relcount + "_signatures", (release.getPublicKey()!=null?"1":"0")); - prop.put("candeploy_availreleases_" + relcount + "_selected", (release == dflt) ? "1" : "0"); + prop.put("candeploy_availreleases_" + relcount + "_selected", (relcount == 0) ? "1" : "0"); relcount++; } + prop.put("candeploy_availreleases", relcount); // properties for automated system update @@ -243,7 +242,7 @@ public class ConfigUpdate_p { prop.put("candeploy_lastdeploy", (sb.getConfigLong("update.time.deploy", 0) == 0) ? "0" : "1"); prop.put("candeploy_lastdeploy_time", new Date(sb.getConfigLong("update.time.deploy", 0)).toString()); prop.put("candeploy_onlySignedFiles", ("1".equals(sb.getConfig("update.onlySignedFiles", "1"))) ? "1" : "0"); - + /* if ((adminaccess) && (yacyVersion.latestRelease >= (thisVersion+0.01))) { // only new Versions(not new SVN) if ((yacyVersion.latestMainRelease != null) || @@ -257,12 +256,12 @@ public class ConfigUpdate_p { } } prop.put("hintVersionAvailable", 1); // for testing - + prop.putASIS("hintVersionDownload_versionResMain", (yacyVersion.latestMainRelease == null) ? "-" : yacyVersion.latestMainRelease.toAnchor()); prop.putASIS("hintVersionDownload_versionResDev", (yacyVersion.latestDevRelease == null) ? "-" : yacyVersion.latestDevRelease.toAnchor()); prop.put("hintVersionAvailable_latestVersion", Float.toString(yacyVersion.latestRelease)); */ - + return prop; } diff --git a/readme.txt b/readme.txt index 12f4576ce..c4b7ef876 100644 --- a/readme.txt +++ b/readme.txt @@ -65,7 +65,7 @@ NO OTHER SOFTWARE IS REQUIRED! == HOW DO I START THIS SOFTWARE? == Startup and Shutdown of YaCy: -- on Linux: +- on GNU/Linux: to start: execute ./startYACY.sh to stop : execute ./stopYACY.sh diff --git a/source/net/yacy/peers/operation/yacyRelease.java b/source/net/yacy/peers/operation/yacyRelease.java index 00d0601ce..8243cc978 100644 --- a/source/net/yacy/peers/operation/yacyRelease.java +++ b/source/net/yacy/peers/operation/yacyRelease.java @@ -85,7 +85,7 @@ public final class yacyRelease extends yacyVersion { this.url = url; } - public yacyRelease(final MultiProtocolURI url, final PublicKey publicKey) { + private yacyRelease(final MultiProtocolURI url, final PublicKey publicKey) { this(url); this.publicKey = publicKey; } diff --git a/source/net/yacy/peers/operation/yacyVersion.java b/source/net/yacy/peers/operation/yacyVersion.java index 0938ac188..df6227068 100644 --- a/source/net/yacy/peers/operation/yacyVersion.java +++ b/source/net/yacy/peers/operation/yacyVersion.java @@ -15,11 +15,11 @@ public class yacyVersion implements Comparator, Comparable, Comparable, Comparable 3) { throw new RuntimeException("release file name '" + release + "' is not valid, 3 information parts expected"); } try { @@ -62,21 +62,25 @@ public class yacyVersion implements Comparator, Comparable 2) { + try { + this.svn = Integer.parseInt(comp[2]); + } catch (final NumberFormatException e) { + throw new RuntimeException("release file name '" + release + "' is not valid, '" + comp[2] + "' should be a integer number"); + } + } else { + this.svn = 0; // we migrate to git } // finished! we parsed a relase string } - + public static final yacyVersion thisVersion() { // construct a virtual release name for this release if (thisVersion == null) { @@ -105,41 +109,45 @@ public class yacyVersion implements Comparator, Comparable - * (i.e.: start of input, 1 or more digits in front of decimal point, decimal point followed by 3 digits as major version, 4 or 5 digits for SVN-Version, end of input) + * (i.e.: start of input, 1 or more digits in front of decimal point, decimal point followed by 3 digits as major version, 4 or 5 digits for SVN-Version, end of input) * @return If the major version is < 0.11 - major version is separated from SVN-version by '/', e.g. "0.435/01818"
- * If the major version is >= 0.11 - major version is replaced by "dev" and separated SVN-version by '/', e.g."dev/01818"
- * "dev/00000" - If the input does not matcht the regular expression above + * If the major version is >= 0.11 - major version is replaced by "dev" and separated SVN-version by '/', e.g."dev/01818"
+ * "dev/00000" - If the input does not matcht the regular expression above */ public static String combined2prettyVersion(final String ver) { return combined2prettyVersion(ver, ""); } - + public static String combined2prettyVersion(final String ver, final String computerName) { - final Matcher matcher = yacyBuildProperties.versionMatcher.matcher(ver); - if (!matcher.find()) { - Log.logWarning("STARTUP", "Peer '"+computerName+"': wrong format of version-string: '" + ver + "'. Using default string 'dev/00000' instead"); + final Matcher matcher = yacyBuildProperties.versionMatcher.matcher(ver); + if (!matcher.find()) { + Log.logWarning("STARTUP", "Peer '"+computerName+"': wrong format of version-string: '" + ver + "'. Using default string 'dev/00000' instead"); return "dev/00000"; } - + final String mainversion = (Float.parseFloat(matcher.group(1)) < 0.11 ? "dev" : matcher.group(1)); String revision = matcher.group(2); for(int i=revision.length();i<5;++i) revision += "0"; @@ -147,11 +155,11 @@ public class yacyVersion implements Comparator, Comparable, Comparable, Comparable, Comparable