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
pull/1/head
orbiter 13 years ago
parent 11729061f2
commit 402e9d71ef

@ -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<yacyRelease> 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<yacyRelease> downloadedReleases = new TreeSet<yacyRelease>();
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<yacyRelease> rlist = new ArrayList<yacyRelease>();
final Set<yacyRelease> remoteDevReleases = releasess.dev;
remoteDevReleases.removeAll(downloadedReleases);
for (final yacyRelease release : remoteDevReleases) {
rlist.add(release);
}
final Set<yacyRelease> 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<yacyRelease> 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;
}

@ -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

@ -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;
}

@ -15,11 +15,11 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
public static final float YACY_POVIDES_REMOTECRAWL_LISTS = (float) 0.550;
public static final float YACY_STANDARDREL_IS_PRO = (float) 0.557;
private static yacyVersion thisVersion = null;
/**
* information about latest release, retrieved by other peers release version,
* this value is overwritten when a peer with later version appears*/
public static double latestRelease = 0.1; //
public static double latestRelease = 0.1; //
private float releaseNr;
private final String dateStamp;
@ -38,7 +38,7 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
* i.e. yacy_v0.51_20070321_3501.tar.gz
* @param release
*/
public yacyVersion(String release, String host) {
public yacyVersion(String release, final String host) {
this.name = release;
if (release == null || !(release.endsWith(".tar.gz") || release.endsWith(".tar"))) {
@ -54,7 +54,7 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
// now all release names have the form
// ${releaseVersion}_${DSTAMP}_${releaseNr}
final String[] comp = release.split("_"); // should be 3 parts
if (comp.length != 3) {
if (comp.length < 2 || comp.length > 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<yacyVersion>, Comparable<yacyVers
} catch (final NumberFormatException e) {
throw new RuntimeException("release file name '" + release + "' is not valid, '" + comp[0] + "' should be a float number");
}
this.mainRelease = ((int) (this.getReleaseNr() * 100)) % 10 == 0 || (host != null && host.endsWith("yacy.net"));
this.mainRelease = ((int) (getReleaseNr() * 100)) % 10 == 0 || (host != null && host.endsWith("yacy.net"));
//System.out.println("Release version " + this.releaseNr + " is " + ((this.mainRelease) ? "main" : "std"));
this.dateStamp = comp[1];
if (this.getDateStamp().length() != 8) {
if (getDateStamp().length() != 8) {
throw new RuntimeException("release file name '" + release + "' is not valid, '" + comp[1] + "' should be a 8-digit date string");
}
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");
if (comp.length > 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<yacyVersion>, Comparable<yacyVers
* a ordered structure, like TreeSet or TreeMap
*/
public int compare(final yacyVersion v0, final yacyVersion v1) {
int r = (Float.valueOf(v0.getReleaseNr())).compareTo(Float.valueOf(v1.getReleaseNr()));
if (r != 0) return r;
r = v0.getDateStamp().compareTo(v1.getDateStamp());
if (r != 0) return r;
return (Integer.valueOf(v0.getSvn())).compareTo(Integer.valueOf(v1.getSvn()));
}
public boolean equals(final Object obj) {
if (obj instanceof yacyVersion) {
final yacyVersion v = (yacyVersion) obj;
return (this.getSvn() == v.getSvn()) && (this.getName().equals(v.getName()));
return (getReleaseNr() == v.getReleaseNr()) && (getSvn() == v.getSvn()) && (getName().equals(v.getName()));
}
return false;
}
public int hashCode() {
return this.getName().hashCode();
return getName().hashCode();
}
/**
* Converts combined version-string to a pretty string, e.g. "0.435/01818" or "dev/01818" (development version) or "dev/00000" (in case of wrong input)
*
* @param ver Combined version string matching regular expression: "\A(\d+\.\d{3})(\d{4}|\d{5})\z" <br>
* (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 &lt; 0.11 - major version is separated from SVN-version by '/', e.g. "0.435/01818" <br>
* If the major version is &gt;= 0.11 - major version is replaced by "dev" and separated SVN-version by '/', e.g."dev/01818" <br>
* "dev/00000" - If the input does not matcht the regular expression above
* If the major version is &gt;= 0.11 - major version is replaced by "dev" and separated SVN-version by '/', e.g."dev/01818" <br>
* "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<yacyVersion>, Comparable<yacyVers
}
public static int revision(final String ver) {
final Matcher matcher = yacyBuildProperties.versionMatcher.matcher(ver);
final Matcher matcher = yacyBuildProperties.versionMatcher.matcher(ver);
if (!matcher.find()) return 0;
return Integer.parseInt(matcher.group(2));
}
/**
* Combines the version of YaCy with the versionnumber from SVN to a
* combined version
@ -169,7 +177,7 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
* @return timestamp
*/
public String getDateStamp() {
return dateStamp;
return this.dateStamp;
}
/**
@ -177,15 +185,15 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
* @return svn revision as integer
*/
public int getSvn() {
return svn;
return this.svn;
}
/**
* Whether this is a stable main release or not
* @return
* @return
*/
public boolean isMainRelease() {
return mainRelease;
return this.mainRelease;
}
/**
@ -193,12 +201,22 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
* @return
*/
public float getReleaseNr() {
return releaseNr;
return this.releaseNr;
}
public String getName() {
return name;
return this.name;
}
public static void main(final String[] args) {
final yacyVersion y1 = new yacyVersion("yacy_v0.51_20070321_3501.tar.gz", null);
final yacyVersion y2 = new yacyVersion("yacy_v1.0_20111203_8134.tar.gz", null);
final yacyVersion y3 = new yacyVersion("yacy_v1.01_20111206_8140.tar.gz", null);
final yacyVersion y4 = new yacyVersion("yacy_v1.01_20111207.tar.gz", null);
System.out.println(y1.compareTo(y2));
System.out.println(y2.compareTo(y3));
System.out.println(y3.compareTo(y4));
}
}

Loading…
Cancel
Save