#-------------------------------------------------------------------------------------------------- # Standard modularization template # -------------------------------- # # The script will start execution from . # # Available variables: # $qtdir = or where you started the modularize script from # $basepath = path for the modularize script, and basepath for the modularization repo # $OStype = where 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 qt5 repo /qt is created # any by default use that as the repo base for the modules my $qt5dir = "qt"; $repos_base = $qtdir . "/" . $qt5dir; ensureDir($qt5dir); 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"); } } sub produceModule { my ($module, $i, $o) = @_; 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 \" -q"); my $GIT_COMMIT; open(GIT_COMMIT, "| git commit -q --author \"Qt by Nokia \" -F -") or die "Couldn't fork: $!\n";; print GIT_COMMIT fileContents("$basepath/misc/import-commit-msg") . $good_sha1; close(GIT_COMMIT) or die "Couldn't close: $!\n";; } sub produceZeroMoveModule { my ($module, $i, $o) = @_; print("Rewriting $module to have zero moves.\n"); run("git checkout master"); runNotDie("git branch -D zeroMoveGraft-temp") if (`git branch` =~ /zeroMoveGraft-temp/s); run("git checkout -b zeroMoveGraft-temp"); run("git filter-branch -f --parent-filter 'read parent; if [ \"\$parent\" != \"-p $good_sha1\" ]; then echo \$parent; fi' --prune-empty --subdirectory-filter '$module' $good_sha1..zeroMoveGraft-temp"); ensureDir($o); chdir($o); run("git init . -q"); run("git fetch $qtdir zeroMoveGraft-temp"); run("git reset --hard FETCH_HEAD"); chdir($qtdir); run("git checkout master"); runNotDie("git branch -D zeroMoveGraft-temp"); } # 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 ($zeroMoveGraft) { produceZeroMoveModule($module, $i, $o); } else { produceModule($module, $i, $o); } # set up graft file to old Qt history run("cd $o && perl $basepath/qt-bundle/git-qt-grafts $qtdir"); # push modules to the server if ($run_push) { chdir($o); 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,style git push origin +master"); run("git branch --set-upstream master origin/master"); } chdir($qtdir); } #-- generate qt5 repo chdir($qt5dir); run ("git init . -q"); fsCopy("-r", "$basepath/qt5/*", "."); if ($link_type == COPY || $link_type == HARDLINKS) { foreach my $module (@repos) { # module repo will either be inside the qt5 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"); run("git submodule -q add --reference $repos_base/$module git://gitorious.org/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 (0 && $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/$qt5dir"); } 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 checkout -b qt-modularization-base origin/qt-modularization-base"); run("git reset --hard $qtWebKitCheckoutRef"); chdir(".."); run("git submodule init"); run ("git add . "); # run("git commit -m \"Long live the qt5 Qt repository\" --author \"Qt by Nokia \" -q"); # push qt5 to the server if ($run_push) { print("Pushing qt5 repo to server:\n"); run("git remote add origin git\@scm.dev.nokia.troll.no:qt/qt5.git"); run("GIT_FORCE=yes-please GIT_PUSH=size,generated,crlf,conflict,giant,alien,style git push origin +master"); run("git branch --set-upstream master origin/master"); } return 1;