config/createprecomplete.py
author B2G Bumper Bot <release+b2gbumper@mozilla.com>
Tue, 02 Sep 2014 05:25:44 -0700
changeset 226231 3c14c9b655b9f028f42f66cfbf380a285a1d0bf0
parent 189165 3b71d879000c73a5988d7010db70b9688d5204ea
child 225608 42dba12fb6014013fd29dec748d33d915b7a1c9a
child 231083 fbc1ceea4d6f3df07e6c243f21517ec3d78bc6e8
permissions -rw-r--r--
Bumping gaia.json for 4 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/b1285c7e5745 Author: Carsten Book <tomcat@mozilla.com> Desc: Merge pull request #23273 from tauzen/Bug1055446_debug_cleanup Bug 1055446 - NFC: log visibly errors in nfc relateded files, r=gweng ======== https://hg.mozilla.org/integration/gaia-central/rev/af9f1e0dc7dc Author: Krzysztof Mioduszewski <kmioduszewski@gmail.com> Desc: Bug 1055446 - NFC: log visibly errors in nfc related files, r=gweng ======== https://hg.mozilla.org/integration/gaia-central/rev/7fb735fb644e Author: Carsten Book <tomcat@mozilla.com> Desc: Merge pull request #23405 from oklang/bug_1055104_theme_switching_panel Bug 1055104 - Theme switching panel. r=ejchen ======== https://hg.mozilla.org/integration/gaia-central/rev/63f473233eba Author: Olle Klang <olle.klang@sonymobile.com> Desc: Bug 1055104 - Theme switching panel This patch adds a Theme switching panel in the Settings app.

# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/

# Creates the precomplete file containing the remove and rmdir application
# update instructions which is used to remove files and directories that are no
# longer present in a complete update. The current working directory is used for
# the location to enumerate and to create the precomplete file.

import sys
import os

def get_build_entries(root_path):
    """ Iterates through the root_path, creating a list for each file and
        directory. Excludes any file paths ending with channel-prefs.js.
    """
    rel_file_path_set = set()
    rel_dir_path_set = set()
    for root, dirs, files in os.walk(root_path):
        for file_name in files:
            parent_dir_rel_path = root[len(root_path)+1:]
            rel_path_file = os.path.join(parent_dir_rel_path, file_name)
            rel_path_file = rel_path_file.replace("\\", "/")
            if not (rel_path_file.endswith("channel-prefs.js") or
                    rel_path_file.endswith("update-settings.ini") or
                    rel_path_file.find("distribution/") != -1):
                rel_file_path_set.add(rel_path_file)

        for dir_name in dirs:
            parent_dir_rel_path = root[len(root_path)+1:]
            rel_path_dir = os.path.join(parent_dir_rel_path, dir_name)
            rel_path_dir = rel_path_dir.replace("\\", "/")+"/"
            if rel_path_dir.find("distribution/") == -1:
                rel_dir_path_set.add(rel_path_dir)

    rel_file_path_list = list(rel_file_path_set)
    rel_file_path_list.sort(reverse=True)
    rel_dir_path_list = list(rel_dir_path_set)
    rel_dir_path_list.sort(reverse=True)

    return rel_file_path_list, rel_dir_path_list

def generate_precomplete(root_path):
    """ Creates the precomplete file containing the remove and rmdir
        application update instructions. The given directory is used
        for the location to enumerate and to create the precomplete file.
    """
    # If inside a Mac bundle use the root of the bundle for the path.
    if os.path.basename(root_path) == "MacOS":
        root_path = os.path.abspath(os.path.join(root_path, '../../'))

    rel_file_path_list, rel_dir_path_list = get_build_entries(root_path)
    precomplete_file_path = os.path.join(root_path,"precomplete")
    # open in binary mode to prevent OS specific line endings.
    precomplete_file = open(precomplete_file_path, "wb")
    for rel_file_path in rel_file_path_list:
        precomplete_file.writelines("remove \""+rel_file_path+"\"\n")

    for rel_dir_path in rel_dir_path_list:
        precomplete_file.writelines("rmdir \""+rel_dir_path+"\"\n")

    precomplete_file.close()

if __name__ == "__main__":
    generate_precomplete(os.getcwd())