summaryrefslogtreecommitdiffstats
path: root/scripts/905_git_split
blob: 6d16c2d050ce2ed740d3f24a6f87979649a39984 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#--------------------------------------------------------------------------------------------------
# Standard modularization template
# --------------------------------
#
# The script will start execution from <QTDIR>.
#
# Available variables:
#     $qtdir    = <QTDIR> or where you started the modularize script from
#     $basepath = path for the modularize script, and basepath for the modularization repo
#     $OStype   = <n> where <n> is one of 0 = Windows, 1 = Unix, 2 = Mac
#
# To execute a command:
#     run("git mv foo bar")        # runs command, reports error possition and dies
#     runNotDie("git mv foo bar")  # runs command, reports error possition, returns error code
#                                    and continues. Use ($? >> 8) to get the real exit code.
#     ensureDir("qtbase")        # Ensures that qtbase exists and is a directory. Will create
#                                    it if it does not exist.
#--------------------------------------------------------------------------------------------------

# Ensure that nothing is left out
chdir("src");
fsRmdirWithParents("plugins/imageformats");
fsRmdir("tools");
fsRmdir("3rdparty");
chdir("..");
fsRmdir("src");
fsRmdir("tools");

# Ensure that the qt-bundle repo <QTDIR>/qt is created
# any by default use that as the repo base for the modules
my $qtbundledir = "qt";
my $repos_base = $qtdir . "/" . $qtbundledir;
ensureDir($qtbundledir);
my $cacheDir = $qtWebKitType;


# if we told it to move, ensure that the move to directory is created
# and point the module repo base to that
if ($move) {
    ensureDir($move_dest);
    $repos_base = $move_dest;
}

# Ensure that lns is compile before we can symlink/hardlink
if ($link_type != COPY) {
    if($OStype == WINDOWS) {
        my $lnsPath = "$basepath/src/lns";
        $lnsPath =~ s,/,\\,g;
        run("cd $lnsPath && nmake /f Makefile.win32");
    } else {
        run("cd $basepath/src/lns && make");
    }
}

# do a full copy/symlink/hardlink of each module into the repo base
# and initialize the module repo there
foreach my $module (@repos) {
    my $i = "$qtdir/$module";
    my $o = "$repos_base/$module";

    if ($link_type == SYMLINKS) {
        print "Creating symlink from '$i' to '$o'\n";
        run("$basepath/lns -v $o $i");
    } elsif ($link_type == HARDLINKS) {
        print "Creating hardlinks from '$i' to '$o'\n";
        run("$basepath/lns -h -v $o $i");
    } else {
        print "Copying files from '$i' to '$o'\n";
        fsCopy("-r", "$module", "$o");
    }

    # initiate the Git repo here in the copy
    chdir("$repos_base/$module");
    run("git init . -q");
    run("git add -f .");
    run("git commit -F $basepath/misc/import-commit-msg --author \"Qt by Nokia <qt-info\@nokia.com>\" -q");

    # push modules to the server
    if ($run_push) {
        print("Pushing modules repo to server: $module\n");
        run("git remote add origin git\@scm.dev.nokia.troll.no:qt/$module.git");
        run("GIT_FORCE=yes-please GIT_PUSH=size,generated,crlf,conflict,giant,alien git push origin +master");
        run("git branch --set-upstream master origin/master");
    }
    chdir($qtdir);
}

#-- generate qt-bundle repo
chdir($qtbundledir);
run ("git init . -q");
fsCopy("-r", "$basepath/qt-bundle/*", ".");
if ($link_type == COPY || $link_type == HARDLINKS) {
    foreach my $module (@repos) {
        # module repo will either be inside the qt-bundle repo already
        # or in the move destination directory
        if ($run_push) {
            run("git submodule -q add --reference $repos_base/$module git://scm.dev.nokia.troll.no/qt/$module.git $module");
        } else {
            run("git submodule -q add $repos_base/$module");
        }
    }
}
if (-d "$basepath/$cacheDir") {
    # Check for a stale version of WebKit, in case the URL has been updated.
    chdir("$basepath/$cacheDir");
    my $remoteUrl = `git config --get remote.origin.url`;
    chdir($repos_base);
    if ($remoteUrl !~ $qtWebKitCloneUrl) {
        print("Deleting cached qtwebkit clone because URLs don't match.\n");
        if ($OStype == WINDOWS) {
            my $webkitPath = "$basepath/$cacheDir";
            $webkitPath =~ s,/,\\,g;
            run("cmd /C rmdir /S /Q $webkitPath");
        } else {
            run("rm -rf $basepath/$cacheDir");
        }
    }
}
if (! -d "$basepath/$cacheDir") {
    print("Note: Creating a cached clone of WebKit in\n");
    print("      $basepath/$cacheDir.\n");
    print("      This will be reused next time unless you delete it yourself.\n");
    if (runNotDie("git clone --bare $qtWebKitCloneUrl $basepath/$cacheDir") != 0) {
        # Try one more time. The gitorious server often works on the second attempt,
        # when its caches are warm.
        print("Retrying qtwebkit clone one more time...\n");
        run("git clone --bare $qtWebKitCloneUrl $basepath/$cacheDir");
    }
} else {
    chdir("$basepath/$cacheDir");
    # Update with latest objects.
    if (runNotDie("git cat-file -e $qtWebKitCheckoutRef")) {
        run("git fetch");
    }
    chdir("$qtdir/$qtbundledir");
}
if ($run_push) {
    run("git submodule -q add --reference $basepath/$cacheDir $qtWebKitCloneUrl qtwebkit");
} else {
    run("git submodule -q add $basepath/$cacheDir qtwebkit");
}
chdir("qtwebkit");
run("git reset --hard $qtWebKitCheckoutRef");
chdir("..");
run("git submodule init");
run ("git add . "); #
run("git commit -m \"Long live the qt-bundle Qt repository\" --author \"Qt by Nokia <qt-info\@nokia.com>\"  -q");

# push qt-bundle to the server
if ($run_push) {
    print("Pushing qt-bundle repo to server:\n");
    run("git remote add origin git\@scm.dev.nokia.troll.no:qt/qt-bundle.git");
    run("GIT_FORCE=yes-please GIT_PUSH=size,generated,crlf,conflict,giant,alien git push origin +master");
    run("git branch --set-upstream master origin/master");
}

return 1;