Changeset bf461ee


Ignore:
Timestamp:
Nov 28, 2011 6:00:36 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
d9dcb1e
Parents:
1339209f
Message:
  • Update: Files listed in deletelist.txt will be deleted
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • build.xml

    r1339209f rbf461ee  
    665665    <target name="preppkg-base" depends="build, preplicenses, prepConsoleDocs, prepthemeupdates, prepCertificates">
    666666        <!-- if updater200 was run previously, it left *.pack files in pkg-temp -->
     667        <!-- Also remove deletelist.txt used for updater only -->
    667668        <delete>
    668             <fileset dir="pkg-temp" includes="**/*.jar.pack **/*.war.pack" />
     669            <fileset dir="pkg-temp" includes="**/*.jar.pack **/*.war.pack deletelist.txt" />
    669670        </delete>
    670671        <copy file="build/i2p.jar" todir="pkg-temp/lib/" />
     
    890891            <arg value="EARLIER HISTORY IS AVAILABLE IN THE SOURCE PACKAGE" />
    891892        </exec>
     893        <copy file="installer/resources/deletelist.txt" todir="pkg-temp/" />
    892894      <!-- May be pointless now, people with split directories will never see this,
    893895           and for flat installs we don't want to overwrite news more recent than the update package.
  • router/java/src/net/i2p/router/Router.java

    r1339209f rbf461ee  
    99 */
    1010
     11import java.io.BufferedReader;
    1112import java.io.File;
     13import java.io.FileInputStream;
    1214import java.io.FileOutputStream;
     15import java.io.InputStreamReader;
    1316import java.io.IOException;
    1417import java.io.Writer;
     
    13721375   
    13731376    public static final String UPDATE_FILE = "i2pupdate.zip";
     1377    private static final String DELETE_FILE = "deletelist.txt";
    13741378   
    13751379    /**
     
    14121416            // Ideally, do not use I2P classes at all, new or not.
    14131417            try {
     1418                // TODO move deleteListedFiles() here after a few releases
    14141419                if (ok)
    14151420                    System.out.println("INFO: Update installed");
     
    14451450            System.exit(EXIT_HARD_RESTART);
    14461451        } else {
    1447             // Remove extracted libjbigi.so and libjcpuid.so files if we have a newer jbigi.jar,
    1448             // so the new ones will be extracted.
    1449             // We do this after the restart, not after the extract, because it's safer, and
    1450             // because people may upgrade their jbigi.jar file manually.
    1451 
    1452             // Copied from NativeBigInteger, which we can't access here or the
    1453             // libs will get loaded.
     1452            deleteJbigiFiles();
     1453            // Here so it may be used in the 0.8.12 update
     1454            // TODO move up in a few releases so it is only run after an update
     1455            deleteListedFiles();
     1456        }
     1457    }
     1458
     1459    /**
     1460     *  Remove extracted libjbigi.so and libjcpuid.so files if we have a newer jbigi.jar,
     1461     *  so the new ones will be extracted.
     1462     *  We do this after the restart, not after the extract, because it's safer, and
     1463     *  because people may upgrade their jbigi.jar file manually.
     1464     *
     1465     *  Copied from NativeBigInteger, which we can't access here or the
     1466     *  libs will get loaded.
     1467     */
     1468    private void deleteJbigiFiles() {
    14541469            String osArch = System.getProperty("os.arch");
    14551470            boolean isX86 = osArch.contains("86") || osArch.equals("amd64");
     
    14951510                }
    14961511            }
    1497         }
    1498     }
    1499    
     1512    }
     1513   
     1514    /**
     1515     *  Delete all files listed in the delete file.
     1516     *  Format: One file name per line, comment lines start with '#'.
     1517     *  All file names must be relative to $I2P, absolute file names not allowed.
     1518     *  We probably can't remove old jars this way.
     1519     *  Fails silently.
     1520     *  Use no new I2P classes here so it may be called after zip extraction.
     1521     *  @since 0.8.12
     1522     */
     1523    private void deleteListedFiles() {
     1524        File deleteFile = new File(_context.getBaseDir(), DELETE_FILE);
     1525        if (!deleteFile.exists())
     1526            return;
     1527        // this is similar to FileUtil.readTextFile() but we can't use any I2P classes here
     1528        FileInputStream fis = null;
     1529        try {
     1530            fis = new FileInputStream(deleteFile);
     1531            BufferedReader in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
     1532            String line;
     1533            while ( (line = in.readLine()) != null) {
     1534                String fl = line.trim();
     1535                if (fl.startsWith("..") || fl.startsWith("#") || fl.length() == 0)
     1536                    continue;
     1537                File df = new File(fl);
     1538                if (df.isAbsolute())
     1539                    continue;
     1540                df = new File(_context.getBaseDir(), fl);
     1541                if (df.exists() && !df.isDirectory()) {
     1542                    if (df.delete())
     1543                        System.out.println("INFO: File [" + fl + "] deleted");
     1544                }
     1545            }
     1546            fis.close();
     1547            fis = null;
     1548            if (deleteFile.delete())
     1549                System.out.println("INFO: File [" + DELETE_FILE + "] deleted");
     1550        } catch (IOException ioe) {
     1551        } finally {
     1552            if (fis != null) try { fis.close(); } catch (IOException ioe) {}
     1553        }
     1554    }
     1555
    15001556/*******
    15011557    private static void verifyWrapperConfig() {
Note: See TracChangeset for help on using the changeset viewer.