diff -Nru kdesrc-build-1.13/AUTHORS kdesrc-build-1.14.1/AUTHORS --- kdesrc-build-1.13/AUTHORS 2010-06-27 02:43:59.000000000 +0000 +++ kdesrc-build-1.14.1/AUTHORS 2011-09-22 02:33:13.000000000 +0000 @@ -2,14 +2,16 @@ Michael Pyne Contributors include: - David Faure - Thiago Macieira - Dirk Mueller - Stephen Kulow - Raphael Kubo da Costa + David Faure + Thiago Macieira + Dirk Mueller + Stephen Kulow + Raphael Kubo da Costa + Laurent Montel + Pino Toscano Suggestions / improvements have been sent in from too many people to list! :) Documentation Gurus: - Carlos Leonhard Woelz + Carlos Leonhard Woelz Michael Pyne diff -Nru kdesrc-build-1.13/CHANGES kdesrc-build-1.14.1/CHANGES --- kdesrc-build-1.13/CHANGES 2011-02-28 04:03:10.000000000 +0000 +++ kdesrc-build-1.14.1/CHANGES 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -### Changes in kdesrc-build-1.13 (Released 2011-Feb-27): - -* The change with perhaps the biggest difference has been the migration of - kdesrc-build to git.kde.org. kdesrc-build no longer tries to install itself, - but will still install documentation and the Kate XML syntax highlighting - file. The assistance of the KDE sysadmins, localization team, Nicolás - Alvarez, Pino Toscano, and Stas Verberkt were invaluable for successfully - setting up the new repository. - -* Many updates from David Faure and Montel Laurent to try and keep the - kdesrc-buildrc-sample in sync with the continuing changes to the KDE source - repository layout. *Please ensure* that you compare your current - ~/.kdesrc-buildrc with the provided sample as some modules have moved, or are - currently moving from Subversion to git. In addition, the Qt library with KDE - modifications has moved to git.kde.org as well, and is called qt-kde. **You - should still leave it as "module qt-copy" in your ~/.kdesrc-buildrc**, as - currently kdesrc-build uses that module name for the different logic needed - to build Qt. - -* kdesrc-build now supports using the database behind [KDE - Projects][kde-projects]. The idea is that the many git - repositories hosted on git.kde.org are arranged into categories (e.g. - kdegraphics, kdepim, calligra, etc.) at the KDE Projects site, and these - categories can be further grouped. kdesrc-build can use a category name to - find and build every git repository contained in that category to allow you - to easily specify many modules to be built, and track new applications added - to a category automatically. Allen Winter contributed the core database - parsing code needed for this feature. - - This feature uses the [module-set][section-module-set] concept added in - 1.12.1. In order to use the KDE module database, you must use `kde-project` - as the value to the [repository][conf-repository] option for a module-set. - You would then use the [use-modules][conf-use-modules] option as normal to - select what modules (or module groups) you want kdesrc-build to build. - -* module-sets can now be given names, and those names may be used from the - command line to quickly refer to the entire set. - -* The [--resume-from][cmdline-resume-from] and - [--resume-after][cmdline-resume-after] options no longer inhibit source - updating. If you really want to avoid source code updates when using either - option, simply pass [--no-src][cmdline-no-src] as well. - -* The last-built and last-installed revisions are now saved for git modules in - addition to svn modules. This should extend the "don't build if the source - didn't change" feature to git modules as well. - -* The kdesrc-buildrc-sample now contains a Phonon backend by default - (phonon-gstreamer). Phonon requires at least one backend to work -- it - doesn't have to be phonon-gstreamer, but if you don't want that one then be - sure to include a different one. Thanks to Ghislain MARY for the report. - ([Bug 263937][263937]). - -* Default CMake build type is changed to "Debug", which includes debug info, - but still provides most optimizations. Thanks to "guy-kde" for the report! - -* Improve the error message if kdesrc-build finds itself trying to build a - module that doesn't have either a CMake or configure-based build system. - -* Some documentation improvements, including for the new KDE module database - support. - -* git-diff is not run in pretend mode. (Doing so made the pretended output more - accurate, but ends up being fairly slow). - -* More exception error messages are actually output when they occur. - -* Consistency updates to [--pretend][cmdline-pretend] output. - -* To support the KDE Projects module database, kdesrc-build has changed a bit - the way modules are handled and read internally. I think I've caught all the - bugs by now, but if you have problems with what kdesrc-build is trying to do - with a given module, it may be related to this reworking and should be - reported as a bug. - -* kdesrc-build no longer tries to invent matching tag names for the kdesupport - module to match a given KDE branch, as kdesupport is mostly migrated to git, - and KDE is not generating any new tags to correspond to a given KDE Platform - release. - -* Updated internal list of default modules to be closer to matching what is - needed to build the KDE Platform and Plasma Desktop. - -* kdesrc-build will avoid using a source control tool for an existing source - directory that is different than the tool used to create the directory, even - if it is known that the module for that directory has moved to git. What - this means for you is that if kdesrc-build has errors updating or building a - module, you may want to check if that module has moved to git. Likewise, if a - module doesn't exist, kdesrc-build will guess what source control tool to use - based on if the [svn-server][conf-svn-server] or - [repository][conf-repository] options are set. - -* [set-env][conf-set-env] now works in module-sets. - -* Completely unknown module or module set names now result in an error instead - of the script exiting after making no output. - -* Added a test suite (kdesrc-build-test.pl), which you can run to test some - various assumptions used for kdesrc-build. *The test suite is not at all - comprehensive*. Some kdesrc-build changes were merely to make some of the - functions easier to test. - -[kde-projects]: http://projects.kde.org/ -[section-module-set]: http://kdesrc-build.kde.org/documentation/kde-modules-and-selection.html#module-sets -[conf-use-modules]: http://kdesrc-build.kde.org/documentation/conf-options-table.html#conf-use-modules -[conf-repository]: http://kdesrc-build.kde.org/documentation/conf-options-table.html#conf-repository -[conf-svn-server]: http://kdesrc-build.kde.org/documentation/conf-options-table.html#conf-svn-server -[conf-set-env]: http://kdesrc-build.kde.org/documentation/conf-options-table.html#conf-set-env -[conf-git-repository-base]: http://kdesrc-build.kde.org/documentation/conf-options-table.html#conf-git-repository-base -[cmdline-pretend]: http://kdesrc-build.kde.org/documentation/supported-cmdline-params.html#cmdline-pretend -[cmdline-resume-from]: http://kdesrc-build.kde.org/documentation/supported-cmdline-params.html#cmdline-resume-from -[cmdline-resume-after]: http://kdesrc-build.kde.org/documentation/supported-cmdline-params.html#cmdline-resume-after -[cmdline-no-src]: http://kdesrc-build.kde.org/documentation/supported-cmdline-params.html#cmdline-no-src -[263937]: https://bugs.kde.org/show_bug.cgi?id=263937 diff -Nru kdesrc-build-1.13/CMakeLists.txt kdesrc-build-1.14.1/CMakeLists.txt --- kdesrc-build-1.13/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ kdesrc-build-1.14.1/CMakeLists.txt 2011-09-22 02:33:13.000000000 +0000 @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 2.6) # Pretty much nothing works without this +project(kdesrc-build) + +find_package(KDE4) # Needed for the docs, but optional. + +if (KDE4_FOUND) + include(KDE4Defaults) + include(MacroLibrary) + macro_optional_add_subdirectory(doc) +else() + set(DATA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/apps" CACHE PATH "The parent directory where applications can install their data") + set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "The install dir for executables") +endif() + +install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/kdesrc-build DESTINATION ${BIN_INSTALL_DIR}) +install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/kdesrc-build-setup DESTINATION ${BIN_INSTALL_DIR}) +install(FILES kdesrc-buildrc.xml DESTINATION ${DATA_INSTALL_DIR}/katepart/syntax) + diff -Nru kdesrc-build-1.13/COPYING.LIB kdesrc-build-1.14.1/COPYING.LIB --- kdesrc-build-1.13/COPYING.LIB 1970-01-01 00:00:00.000000000 +0000 +++ kdesrc-build-1.14.1/COPYING.LIB 2011-09-22 02:33:13.000000000 +0000 @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff -Nru kdesrc-build-1.13/debian/changelog kdesrc-build-1.14.1/debian/changelog --- kdesrc-build-1.13/debian/changelog 2011-03-01 09:36:22.000000000 +0000 +++ kdesrc-build-1.14.1/debian/changelog 2011-09-22 07:54:24.000000000 +0000 @@ -1,3 +1,23 @@ +kdesrc-build (1.14.1-1) unstable; urgency=low + + * New upstream release. + * Switch copyright to DEP5, and make it a bit more precise on licenses + (thanks also to the work done by upstream!) + + -- Pino Toscano Thu, 22 Sep 2011 09:53:18 +0200 + +kdesrc-build (1.14-1) unstable; urgency=low + + * New upstream release. + * Drop patch build-system.diff, upstream now ships also the cmake build + system. + * Small copyright update. + * Switch to my @debian.org address, I'm a DD now. + * Remove "DM-Upload-Allowed: yes" from control, no more needed now. + * Bump Standards-Version to 3.9.2, no changes required. + + -- Pino Toscano Sun, 18 Sep 2011 12:22:22 +0200 + kdesrc-build (1.13-1) unstable; urgency=low * New upstream release. diff -Nru kdesrc-build-1.13/debian/control kdesrc-build-1.14.1/debian/control --- kdesrc-build-1.13/debian/control 2011-03-01 09:29:49.000000000 +0000 +++ kdesrc-build-1.14.1/debian/control 2011-09-18 10:20:28.000000000 +0000 @@ -2,15 +2,14 @@ Section: kde Priority: optional Maintainer: Debian Qt/KDE Maintainers -Uploaders: Pino Toscano +Uploaders: Pino Toscano Build-Depends: debhelper (>= 7.3.16), pkg-kde-tools (>= 0.5), cmake, kdelibs5-dev (>= 4:4.2.2), libxml-parser-perl, libwww-perl -Standards-Version: 3.9.1 +Standards-Version: 3.9.2 Homepage: http://kdesrc-build.kde.org/ Vcs-Git: git://git.debian.org/pkg-kde/kde-std/kdesrc-build.git Vcs-Browser: http://git.debian.org/?p=pkg-kde/kde-std/kdesrc-build.git -DM-Upload-Allowed: yes Package: kdesrc-build Architecture: all diff -Nru kdesrc-build-1.13/debian/copyright kdesrc-build-1.14.1/debian/copyright --- kdesrc-build-1.13/debian/copyright 2011-03-01 09:13:06.000000000 +0000 +++ kdesrc-build-1.14.1/debian/copyright 2011-09-22 07:39:55.000000000 +0000 @@ -1,30 +1,86 @@ -It was downloaded from http://kdesrc-build.kde.org/ - -Upstream authors are: - - Michael Pyne - -Contributors include: - David Faure - Thiago Macieira - Dirk Mueller - Stephen Kulow - Raphael Kubo da Costa - Carlos Leonhard Woelz - -Copyright: - - Copyright © 2003-2011 Michael Pyne - -License: - - | You may use, alter, and redistribute this software under the terms - | of the GNU General Public License, v2 (or any later version). - - You can find the complete text of the license GPL at - `/usr/share/common-licenses/GPL-2' and `/usr/share/common-licenses/GPL-3' - - -The Debian packaging is: - Copyright 2011, Pino Toscano -And it is licensed under the GPL v2+ license, see above. +Format: http://anonscm.debian.org/viewvc/dep/web/deps/dep5.mdwn?revision=174 +Upstream-Name: kdesrc-build +Upstream-Contact: Michael Pyne +Source: http://kdesrc-build.kde.org + +Files: * +Copyright: 2003-2011, Michael Pyne + 2005, 2006, 2008 - 2011, David Faure + 2005, Thiago Macieira + 2006, Stephan Kulow + 2006, 2008, Dirk Mueller +License: GPL-2+ + +Files: kdesrc-buildrc.xml +Copyright: 2005, 2009-2010, Michael Pyne +License: LGPL-3+ + +Files: doc/build-docs +Copyright: 2011, Michael Pyne +License: BSD-2-clause + +Files: doc/*.docbook +Copyright: 2005-2008, 2010-2011, Michael Pyne + 2005, Carlos Leonhard Woelz + 2009, Burkhard Lück + 2007, 2011, Federico Zenith + 2009-2011, Yuri Chornoivan +License: GFDL-NIV-1.2+ + +Files: debian/* +Copyright: 2011, Pino Toscano +License: GPL-2+ + +License: BSD-2-clause + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + . + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + . + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License: GFDL-NIV-1.2+ + Permission is granted to copy, distribute and/or modify this document under + the terms of the GNU Free Documentation License, Version 1.2 or any later + version published by the Free Software Foundation; with no Invariant + Sections, no Front-Cover Texts, and no Back-Cover Texts. + . + On Debian systems, the complete text of the GNU Free Documentation License + version 1.2 can be found in `/usr/share/common-licenses/GFDL-1.2'. + +License: GPL-2+ + 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 (at your option) any later + version. + . + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + details. + . + You should have received a copy of the GNU General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 51 + Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + . + On Debian systems, the complete texts of the GNU General Public Licenses + version 2 and 3 can be found in `/usr/share/common-licenses/GPL-2' and + `/usr/share/common-licenses/GPL-3'. + +License: LGPL-3+ + On Debian systems, the complete text of the GNU Lesser General Public License + version 3 can be found in `/usr/share/common-licenses/LGPL-3'. diff -Nru kdesrc-build-1.13/debian/patches/build-system.diff kdesrc-build-1.14.1/debian/patches/build-system.diff --- kdesrc-build-1.13/debian/patches/build-system.diff 2011-03-01 08:59:37.000000000 +0000 +++ kdesrc-build-1.14.1/debian/patches/build-system.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -Description: add a simple CMake build system for installing - The CMakeLists.txt is a simplified version of upstream's one. -Author: Pino Toscano -Forwarded: not-needed - ---- /dev/null -+++ b/CMakeLists.txt -@@ -0,0 +1,8 @@ -+project(kdesrc-build) -+ -+find_package(KDE4 REQUIRED) -+include(KDE4Defaults) -+ -+install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/kdesrc-build DESTINATION ${BIN_INSTALL_DIR}) -+install(FILES kdesrc-buildrc.xml DESTINATION ${DATA_INSTALL_DIR}/katepart/syntax) -+ diff -Nru kdesrc-build-1.13/debian/patches/series kdesrc-build-1.14.1/debian/patches/series --- kdesrc-build-1.13/debian/patches/series 2011-03-01 08:59:37.000000000 +0000 +++ kdesrc-build-1.14.1/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -build-system.diff diff -Nru kdesrc-build-1.13/doc/build-docs kdesrc-build-1.14.1/doc/build-docs --- kdesrc-build-1.13/doc/build-docs 1970-01-01 00:00:00.000000000 +0000 +++ kdesrc-build-1.14.1/doc/build-docs 2011-09-22 02:33:13.000000000 +0000 @@ -0,0 +1,46 @@ +#!/bin/sh + +# This is a very simple script to build the documentation used on the +# kdesrc-build.kde.org website. The /common files themselves came from +# kdelibs/doc/common IIRC +# +# By Michael Pyne +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +PATH_TO_DOCS="/kdesvn/src/kdesrc-build/doc/index.docbook" +COMMON_FILES="'common/'" # The single quotes are exceedingly important + +# The kdelibs install process installs support files for DocBook handling to +# the ksgmltools2 application data dir. A kdelibs checkout is not sufficient +# since some of the xsl files are input to a CMake script which converts them +# to final form. +DATA_DIR=$(kde4-config --install data) +DOC_SRCDIR="$DATA_DIR/ksgmltools2" +XSLT="$DOC_SRCDIR/customization/kde-chunk-online.xsl" + +# We need to run this from right directory, i.e. the directory we want generated +# output to go to (www/kdesrc-build/documentation) +meinproc4 --srcdir $DOC_SRCDIR \ + --param kde.common="$COMMON_FILES" \ + --stylesheet $XSLT \ + $PATH_TO_DOCS diff -Nru kdesrc-build-1.13/doc/CMakeLists.txt kdesrc-build-1.14.1/doc/CMakeLists.txt --- kdesrc-build-1.13/doc/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ kdesrc-build-1.14.1/doc/CMakeLists.txt 2011-09-22 02:33:13.000000000 +0000 @@ -0,0 +1,6 @@ +########### install files ############### +kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR kdesrc-build) +kde4_create_manpage(man-kdesrc-build.1.docbook 1 INSTALL_DESTINATION ${MAN_INSTALL_DIR}) +kde4_create_manpage(man-kdesrc-build-setup.1.docbook 1 INSTALL_DESTINATION ${MAN_INSTALL_DIR}) + +install(PROGRAMS kdesrc-build.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) diff -Nru kdesrc-build-1.13/doc/COPYING.DOC kdesrc-build-1.14.1/doc/COPYING.DOC --- kdesrc-build-1.13/doc/COPYING.DOC 1970-01-01 00:00:00.000000000 +0000 +++ kdesrc-build-1.14.1/doc/COPYING.DOC 2011-09-22 02:33:13.000000000 +0000 @@ -0,0 +1,397 @@ + GNU Free Documentation License + Version 1.2, November 2002 + + + Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + +0. PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +functional and useful document "free" in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. + +This License is a kind of "copyleft", which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + + +1. APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The "Document", below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as "you". You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. + +A "Modified Version" of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A "Secondary Section" is a named appendix or a front-matter section of +the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall subject +(or to related matters) and contains nothing that could fall directly +within that overall subject. (Thus, if the Document is in part a +textbook of mathematics, a Secondary Section may not explain any +mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The "Invariant Sections" are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The "Cover Texts" are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. + +A "Transparent" copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, that is suitable for revising the document +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not "Transparent" is called "Opaque". + +Examples of suitable formats for Transparent copies include plain +ASCII without markup, Texinfo input format, LaTeX input format, SGML +or XML using a publicly available DTD, and standard-conforming simple +HTML, PostScript or PDF designed for human modification. Examples of +transparent image formats include PNG, XCF and JPG. Opaque formats +include proprietary formats that can be read and edited only by +proprietary word processors, SGML or XML for which the DTD and/or +processing tools are not generally available, and the +machine-generated HTML, PostScript or PDF produced by some word +processors for output purposes only. + +The "Title Page" means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, "Title Page" means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +A section "Entitled XYZ" means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as "Acknowledgements", +"Dedications", "Endorsements", or "History".) To "Preserve the Title" +of such a section when you modify the Document means that it remains a +section "Entitled XYZ" according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + + +2. VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + + +3. COPYING IN QUANTITY + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + + +4. MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +A. Use in the Title Page (and on the covers, if any) a title distinct + from that of the Document, and from those of previous versions + (which should, if there were any, be listed in the History section + of the Document). You may use the same title as a previous version + if the original publisher of that version gives permission. +B. List on the Title Page, as authors, one or more persons or entities + responsible for authorship of the modifications in the Modified + Version, together with at least five of the principal authors of the + Document (all of its principal authors, if it has fewer than five), + unless they release you from this requirement. +C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. +D. Preserve all the copyright notices of the Document. +E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. +F. Include, immediately after the copyright notices, a license notice + giving the public permission to use the Modified Version under the + terms of this License, in the form shown in the Addendum below. +G. Preserve in that license notice the full lists of Invariant Sections + and required Cover Texts given in the Document's license notice. +H. Include an unaltered copy of this License. +I. Preserve the section Entitled "History", Preserve its Title, and add + to it an item stating at least the title, year, new authors, and + publisher of the Modified Version as given on the Title Page. If + there is no section Entitled "History" in the Document, create one + stating the title, year, authors, and publisher of the Document as + given on its Title Page, then add an item describing the Modified + Version as stated in the previous sentence. +J. Preserve the network location, if any, given in the Document for + public access to a Transparent copy of the Document, and likewise + the network locations given in the Document for previous versions + it was based on. These may be placed in the "History" section. + You may omit a network location for a work that was published at + least four years before the Document itself, or if the original + publisher of the version it refers to gives permission. +K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the section all + the substance and tone of each of the contributor acknowledgements + and/or dedications given therein. +L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section titles. +M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. +N. Do not retitle any existing section to be Entitled "Endorsements" + or to conflict in title with any Invariant Section. +O. Preserve any Warranty Disclaimers. + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section Entitled "Endorsements", provided it contains +nothing but endorsements of your Modified Version by various +parties--for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + + +5. COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled "History" +in the various original documents, forming one section Entitled +"History"; likewise combine any sections Entitled "Acknowledgements", +and any sections Entitled "Dedications". You must delete all sections +Entitled "Endorsements". + + +6. COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + + +7. AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, is called an "aggregate" if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + + +8. TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled "Acknowledgements", +"Dedications", or "History", the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. + + +9. TERMINATION + +You may not copy, modify, sublicense, or distribute the Document except +as expressly provided for under this License. Any other attempt to +copy, modify, sublicense or distribute the Document is void, and will +automatically terminate your rights under this License. However, +parties who have received copies, or rights, from you under this +License will not have their licenses terminated so long as such +parties remain in full compliance. + + +10. FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. See +http://www.gnu.org/copyleft/. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. + + +ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + + Copyright (c) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled "GNU + Free Documentation License". + +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with the + Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. diff -Nru kdesrc-build-1.13/doc/index.docbook kdesrc-build-1.14.1/doc/index.docbook --- kdesrc-build-1.13/doc/index.docbook 1970-01-01 00:00:00.000000000 +0000 +++ kdesrc-build-1.14.1/doc/index.docbook 2011-09-22 02:33:13.000000000 +0000 @@ -0,0 +1,3507 @@ + + + + Copyright (c) 2005 Carlos Leonhard Woelz + Copyright (c) 2009 Burkhard Lück + Copyright (c) 2007, 2011 Federico Zenith + Copyright (c) 2009-2011 Yuri Chornoivan + ... and possibly others. Check the git source repository for specifics. + + Permission is granted to copy, distribute and/or modify this document under + the terms of the GNU Free Documentation License, Version 1.2 or any later + version published by the Free Software Foundation; with no Invariant + Sections, no Front-Cover Texts, and no Back-Cover Texts. + + A copy of the license is included in COPYING.DOC. The license will be + included in the generated documentation as well. + --> + + + + + kdesrc-build"> + BSD'> + Git'> + CMake'> + Make'> + SSH'> + Cron'> + Subversion'> + Sudo'> + URL'> + + + + configure-flags'> + kdedir'> + qtdir'> + build-dir'> + module-base-path'> + override-url'> + source-dir'> + email-address'> + email-on-compile-error'> + colorful-output'> + tag'> + branch'> + do-not-compile'> + checkout-only'> + svn-server'> + make-install-prefix'> + niceness'> + set-env'> + libpath'> + binpath'> + + + --nice'> + --ignore-modules'> + --resume-from'> + --resume-after'> + --reconfigure'> + --refresh-build'> +]> + + + + +&kdesrc-build; Script Manual + + + +MichaelPyne +
mpyne@kde.org
+
+ +CarlosWoelz +
carloswoelz@imap-mail.com
+
+ + + + +
+ + +2006 +2007 +2008 +2009 +2010 +2011 +Michael Pyne + + + +2005 +Carlos Woelz + + +&FDLNotice; + +2011-09-07 +1.14 + + +&kdesrc-build; is a script which builds and installs &kde; software +directly from the &kde; project's source code repositories. + + + +KDE +kdesdk +SVN +Subversion +git +gitorious +KDE development + +kdesvn-build +kdecvs-build + + +
+ + +Introduction + + +&kdesrc-build; is a script to help users install &kde; software from its &subversion; and &git; source repositories. + + + +This software used to be called kdesvn-build, so you may still see +references to kdesvn-build on the Internet or in your installed documentation. + + +This guide is an overview to describe the following aspects of &kdesrc-build; +operation: + + + +An overview of the steps +required to get started. +Notable features. +The configuration file syntax +and options. +The command line options. + + +Also documented are the steps which you should perform using +other tools, (in other words, steps that are not automatically performed by +&kdesrc-build;). + + + + +Getting Started + + +In this chapter, we show how to use the &kdesrc-build; to checkout modules from +the &kde; repository and build them. We also provide a basic explanation of the +&kde; &subversion; structure and the steps you have to perform before running +the script. + + + +All topics present in this chapter are covered with even more detail in the + +Building &kde; 4 from Source article, at the +&kde; TechBase site. +If you are compiling &kde; for the first time, it is a good idea to read +it, or consult it as a reference source. You will find detailed information +about packaging tools and requirements, common compilation pitfalls and +strategies and information about running your new &kde; installation. + + + +Preparing the System to Build &kde; + + +Setup a new user account + + +It is recommended that you use a different user account to build, install, +and run your &kde; software from, since less permissions are required, and +to avoid interfering with your distribution's packages. +If you already have &kde; packages installed, the best choice +would be to create a different (dedicated) user to build and run the new &kde;. + + +Leaving your system &kde; untouched also allows you to have an +emergency fallback in case a compiled &kde; is unstable for whatever reason. + + + +Later, you can do a system installation if you wish. This document +does not cover a system installation. If you are performing a system +wide install, you should already know what you are doing. If not, then you +may want to consult the documentation, or help sites, for your distribution +in order to prepare and use the system installation correctly. + + + + +Ensure your system is ready to build &kde; source + +Before using the &kdesrc-build; script (or any other building +strategy) you must install the development tools and libraries needed for &kde;. +The complete list of required tools can be found from +the KDE TechBase. + + +Here is a list of some of the things you will need: + + +You will need &cmake;. The required version will vary +depending on what version of &kde; 4 you are building, see TechBase for +specifics. + +Also needed is the &subversion; client program. You can check +if you have it by running svn +. + +You will also need the Git +source control manager installed as well, for &kde;'s git-based projects. +. + +You will need a C++ development environment. GCC 4.2 or +later is recommended. + + + +Most operating system distributions include a method of easily +installing required development tools. Consult the TechBase Getting Started +page's Required Packages from your Distribution section to see +if these instructions are already available. + +One exception to the required libraries is the &Qt; library. +&kdesrc-build; will normally install a copy of &Qt; whether you have it +installed or not, so it is not necessary for you to have it. If you do not want +to use the &Qt; copy, you need to do these things: + + + + Make sure to remove the qt-copy module from your configuration file, as you will not need it, + and having it would add extra time to your build. + + + + Change the setting of the qtdir + option in your configuration file to + point to your system &Qt;. This is normally equal to the setting of + $QTDIR for your system. + + + + If you do not already have &Qt; installed, install it, including any + relevant -dev or -devel packages. You will need at least + &Qt; 4.7 if you are building &kde; 4. + + + + +Some of these packages are divided into libraries (or programs or utilities), and +development packages. You will need at least the program or library and +its development package. If in doubt, install all. The libraries you need +will change depending on the modules you intend to build, as each module +has its own requirements. The +&kde; +TechBase has more details +about the specific tools and techniques used to install and find the +required software. + + + + + +Setup &kdesrc-build; + + +Install &kdesrc-build; + +You probably already have a version of the &kdesrc-build; script installed +in your system. However, if you do not, you can download it from +&kdesrc-build; home page, +or you can find it from its home in the &kde; source repository. + +If you use a more recent &kdesrc-build; by downloading from its +website, you should remember to run the &kdesrc-build; script you downloaded. +You can use the option to &kdesrc-build; as a quick +way to verify this. + + +To download &kdesrc-build; from its home page, simply go to the +&kdesrc-build; home page and download the latest appropriate release. The release is +packaged as a compressed tarball archive, which you can extract using &ark; or +tar. The contents of the archive include the actual +&kdesrc-build; script, a sample configuration file +(kdesrc-buildrc-sample), and a quick-setup +program. + +Or, you can obtain &kdesrc-build; from its source repository, +located at: http://quickgit.kde.org/?p=kdesrc-build.git&a=tree&hb=refs/heads/master. +You can click on the kdesrc-build entry which will bring +you to a page where you can download the latest revision. Click on the +plain link for the file to download it directly, and save it to +a convenient spot on your hard disk. Do the same for +kdesrc-buildrc-sample if you need to. + + +No matter which technique you use, you need to make sure that the +kdesrc-build file is executable. For convenience you +should make sure it is in a directory contained in the PATH +environment variable, otherwise you may get messages saying that the command +was not found, or you may run a previously-installed version by mistake. + + + +Prepare the configuration file + +&kdesrc-build; uses a configuration +file (located at ~/.kdesrc-buildrc) to control +which modules are built, where they are installed to, etc. + +You can use a program included with &kdesrc-build;, called +kdesrc-build-setup in order to prepare a simple +kdesrc-build configuration. You can then edit the +~/.kdesrc-buildrc from there to make any changes you see +fit. + +kdesrc-build-setup itself runs from a terminal +(instead of using a graphical interface), just like &kdesrc-build;, so you can +use it even if you have no graphical interface available yet. + +You can use the included kdesrc-buildrc-sample +sample configuration to get explanations as to the various options available. + + +You can find more information about the syntax of the configuration file +in and in . + + + + + + + +Setting the Configuration Data + + +To use &kdesrc-build;, you should have a file in your home directory called +.kdesrc-buildrc, which sets the general options and sets the modules +you would like to download and build. + + +It is possible to use different configuration files for &kdesrc-build;, +which is described in . If you need to use +multiple configurations, please see that section. Here, we will assume the +configuration is stored in ~/.kdesrc-buildrc. + + +The easiest way to proceed is to use the +kdesrc-buildrc-sample file as a template, changing global +options to match your wants, and also change the list of modules you want to +build. + + + +The default settings should actually already be appropriate to perform a +&kde; build. Some settings that you may wish to alter include: + + +kdedir, which changes the +destination directory that &kde; is installed to. This defaults to +~/kde, which is a single-user installation. + +qtdir, which controls the +path to the installation of &Qt; to use. The default is to use a &Qt; compiled +by &kdesrc-build;, using the special qt-copy module and the latest available +source code. +(~/kdesrc/build/qt-copy). + +This also controls where to install qt-copy. + + +svn-server, which +selects what &url; to download the sources from. This is useful if you are a +developer with a &kde; +&subversion; account. + + + +Continue to to see how to +change how much of &kde; is built. + + + +Module Organization and selection + + +KDE Software Organization + + +&kde; software is split into different components, many of which can be built +by &kdesrc-build;. Understanding this organization will help you properly +select the software modules that you want built. + + + +At the lowest level comes Nokia's &Qt; library, which is a +very powerful, cross-platform toolkit library. &kde; is based on +&Qt;, and some of the non-&kde; libraries required by &kde; are also based on +&Qt;. &kdesrc-build; can build &Qt;, or use the one already installed on your +system if it is a recent enough version. + +On top of &Qt; are required libraries that are necessary for +&kde; software to work. Some of these libraries are not considered part of +&kde; itself due to their generic nature, but are still essential to the &kde; +Platform. These libraries tended to get combined into a single +kdesupport module. + +As of &kde; Platform 4.6, many of these kdesupport modules are being +migrated over to git.kde.org, +although they are still not considered part of the Platform. + + +On top of these essential libraries comes the &kde; Platform. +These are the libraries that are required for &kde; applications to work. A +full desktop environment is not provided by the Platform however. + + +For &kdesrc-build;, the Platform layer consists of the kdelibs, +kdepimlibs, and kdebase modules. + +Technically, only the /runtime directory of kdebase +is part of the &kde; Platform. This will be corrected when kdebase is converted +to use &git;. + + +On top of the Platform, come several different things: + + Third-party applications. These are + applications that use the &kde; Platform but are not authored by or in + association with the &kde; project. + + A full workspace desktop environment. + This is what users normally see when they log-in to + &kde;. This is provided by the &plasma; Desktop, mostly in + kdebase/workspace. + + The &kde; Software Compilation. This is a collection of + useful software included with the Platform and &plasma; Desktop, + grouped into individual modules. These are the modules that have names + starting with kde. For example, + kdepim is a component of the Software Compilation + that contains email, news-reading, calendar/organizational software, + &etc;, while kdegames contains a collection of + high-quality games to while away the time. + + Finally, there is a collection of software (also + collected in modules) whose development is supported by &kde; resources + (such as translation, source control, bug tracking, &etc;) but is not + released by &kde; or considered part of the Software Compilation. These + modules are known as Extragear, and have module names + such as extragear/network. As with + kdesupport, some of these Extragear applications are + migrating to git.kde.org. + + + + + + +Selecting modules to build + +Selecting which of the possible modules to build is controlled by +the configuration file. +After the global section is a list of modules to build, +bracketed by module ... end module lines. An example entry for a module is +shown in . + + +Example module entry in the configuration file + +module module-name + # Options for this module go here, example: + make-options -j4 # Run 4 compiles at a time +end module + + + +It is possible to declare a module with no options. In fact, most of +your modules will likely be declared this way. + +&kdesrc-build; only builds the modules you have listed in your configuration +file. In addition, the modules are built in the order specified in the configuration +file. For this reason you should ensure that the order of modules in your +configuration file is consistent with the organization given in +. + +There is a sample file that comes with &kdesrc-build; called +kdesrc-buildrc-sample. It is recommended to copy this file +to a file called ~/.kdesrc-buildrc (Note the +leading period in front of kdesrc-buildrc!). Afterwards, edit the +new file to adjust the default options to your liking. (Each option is described +in more detail in ). The default modules +should be enough to ensure a fairly complete &kde; installation, however you +can remove many of the modules that show up after kdebase +if you'd like to save disk space or build time. + + + + +Module Sets + +&kdesrc-build; is usually able to guess where to download the source code +for a given module quite easily, by using your setting for svn-server and the module name for each module +to create a single Subversion URL, which describes exactly where to download +the source code from. + +With the move to Git, many larger Subversion modules were further +sub-divided in the process, and there was no guarantee of where to find a +module based just on the module name. Because of this, a concept called +module sets was developed for &kdesrc-build; 1.12.1. + +By using a module set, you can quickly declare many Git modules to be +downloaded and built, as if you'd typed out a separate module declaration for +each one. The repository option is +handled specially to setup where each module is downloaded from, which every +other option contained in the module set is copied to every module generated +in this fashion. + + +Using module sets + +global + kde-git kde: +end global + +module qt-copy + # Options removed for brevity +end module + +module-set kde-support-libs + kde-git + automoc attica akonadi +end module-set + +# Other modules as necessary... +module kdesupport +end module + + + +In a brief module set is +shown. When &kdesrc-build; encounters this module set, it acts as if, for +every module given in , that an individual module +has been declared, with its equal to the +module-set's followed immediately by the given +module name. + +In addition, other options can be passed in a module set, which are +copied to every new module that is created this way. By using module-set it is +possible to quickly declare many Git modules that are all based on the same +repository URL. In addition, since &kdesrc-build; 1.13, it is possible to +give module-sets a name (as shown in the example), which allows you to quickly +refer to the entire group of modules from the command line. + +Module sets are used in supporting module downloads from +the &kde; projects.kde.org +module database. See also . + + +Module sets use the options git-repository-base +use-modules + + + +Automatically finding modules from the official &kde; module +database + +With the migration of &kde; source code to be hosted on git.kde.org, +there has been an explosive growth in the number of modules (for instance, +a single Subversion module called kdegraphics becomes +16 different Git modules). + +This was done mostly because each Git module contains the entire project +history (this is actually less wasteful of disk space than it sounds for the +vast majority of &kde; repositories as &git; is highly efficient at storing +repositories). + +&kde; allows for grouping Git repositories into collections +of related modules (e.g. kdegraphics). These modules can themselves be grouped +(e.g. &kde; Software Compilation). Git doesn't recognize these groupings, but +&kdesrc-build; can be configured to handle these groups. + +The way this is done is by using module +sets. Instead of using a specific git:// repository, +or a repository name created by git-repository-base, a special +repository name, kde-projects is used. + +&kdesrc-build; will recognize that the kde-projects +repository requires special handling, and adjust the build process +appropriately. Among other things, &kdesrc-build; will: + + + +Download the latest module database from projects.kde.org. + +Try to find a module with the name given in the module set's + setting. + +For every module that is found, &kdesrc-build; will see if a +repository setting exists for that module in the database. If there is a +repository, &kdesrc-build; will automatically use that to download or update +the source code. If there is no repository, &kdesrc-build; treats that module +like a group, and tries to include all &git; source repositories that it finds +in that group. + + + +In the current database, some module groups not only have a +collection of modules, but they also declare their own +&git; repository. In these situations &kdesrc-build; will currently prefer the +group's &git; repository instead of including the childrens' repositories. + + +The following example shows how to use the &kde; module database to +install the Phonon multimedia library. + + + +module-set media-support + # This option must be kde-projects to use the module database. + kde-projects + + # This option chooses what modules to look for in the database. + phonon/phonon phonon-gstreamer phonon-vlc +end module-set + + + +phonon/phonon is used since (with the current +project database) &kdesrc-build; would otherwise have to decide between the +group of projects called phonon or the individual project named +phonon. Currently &kdesrc-build; would pick the former, which +would build many more backends than needed. + +The following example is perhaps more realistic, and shows a feature only +available with the &kde; module database: Building all of the &kde; graphics +applications with only a single declaration. + + + +module-set kdegraphics + # This option must be kde-projects to use the module database. + kde-projects + + # This option chooses what modules to look for in the database. + kdegraphics/libs kdegraphics/* +end module-set + + + +There are two important abilities demonstrated here: + + + +&kdesrc-build; allows you to specify modules that are +descendents of a given module, without building the parent module, by using the +syntax module-name/*. It is +actually required in this case since the base module, kdegraphics, is marked as +inactive so that it is not accidentally built along with its children modules. +Specifying the descendent modules allows &kdesrc-build; to skip around the +disabled module. + + +&kdesrc-build; will also not add a given module to the build +list more than once. This allows us to manually set +kdegraphics/libs to build first, before the rest of +kdegraphics, without trying to build +kdegraphics/libs twice. This is required at this point +because &kdesrc-build; will not perform dependency handling. + + + + + + + + +Using the &kdesrc-build; script + + +Now you are ready to run the script. From a terminal window, +log in to the user you are using to compile &kde; and execute +the script: + +% kdesrc-build + + + +Afterwards, you should see output similar to that in : + + +Example output of building a single module + +% kdesrc-build +Script started processing at Wed Dec 22 13:21:45 2010 +<<< Build Process >>> +Building kdelibs (1/1) + Waiting for source code update. + Source update complete for kdelibs: 48 files affected. + Checking for source conflicts... + Compiling... + Build succeeded after 13 minutes, and 6 seconds. + Installing kdelibs. + Overall time for kdelibs was 13 minutes, and 53 seconds. + +<<< Build Done >>> + +<<< PACKAGES SUCCESSFULLY BUILT >>> +kdelibs + +Script finished processing at Wed Dec 22 13:35:38 2010 +Your logs are saved in /home/kde-src/log-kdesrc-build/2010-12-22-01 + + + + +At this point, &kdesrc-build; should start downloading the sources and +compiling them. Depending on how many modules you are downloading, it is +possible that &kdesrc-build; will not succeed the first time you compile &kde;. +Do not despair! + + +&kdesrc-build; logs the output of every command it runs. By default, +the log files are kept in ~/kdesrc/log. To see what +the caused an error for a module in the last &kdesrc-build; command, usually +it is sufficient to look at ~/kdesrc/log/latest/module-name/error.log. + +Perhaps the easiest way to find out what error caused a module to +fail to build is to search backward with a case-insensitive search, starting +from the end of the file looking for the word error. Once +that is found, scroll up to make sure there are no other error messages nearby. +The first error message in a group is usually the underlying +problem. + +In that file, you will see the error that caused the build to fail for +that module. If the file says (at the bottom) that you are missing some +packages, try installing the package (including any appropriate -dev packages) +before trying to build that module again. Make sure that when you run +&kdesrc-build; again to pass the --reconfigure option so that +&kdesrc-build; forces the module to check for the missing packages +again. + +Or, if the error appears to be a build error (such as a syntax error, +incorrect prototype, unknown type, or similar) +then it is probably an error with the &kde; source, which will hopefully be +resolved within a few days. If it is not resolved within that time, feel free +to mail the kde-devel@kde.org mailing list (subscription may be +required first) in order to report the build failure. + +You can find more common examples of things that can go wrong and their +solutions, as well as general tips and strategies to build &kde; in the + +Building &kde; 4 from Source. + + +On the other hand, assuming everything went well, you should have a new +&kde; install on your computer, and now it is simply a matter of running +it, described next in . + +For more information about &kdesrc-build;'s logging features, +please see . + + + + +Setting the Environment to Run Your Fresh &kde; + + +Assuming you are using a dedicated user to build &kde;, and you already have +an installed &kde; version, running your new &kde; may be a bit tricky, as the new &kde; +has to take precedence over the old. Change the environment variables to +make sure it does. + + + +Changing your startup profile settings + +The .bash_profile is the login settings +file for the popular bash shell used by many &Linux; +distributions. If you use a different shell, then you may need to adjust the +samples given in this section for your particular shell. + + +Open or create the .bash_profile file in the home directory with your favorite editor, +and add to the end of the file: + +If you are building the qt-copy module (you are by default), add instead: + + +QTDIR=(path to qtdir) # Such as ~/kdesrc/build/qt-copy by default. +KDEDIR=(path to kdedir) # Such as ~/kde by default. +KDEDIRS=$KDEDIR +PATH=$KDEDIR/bin:$QTDIR/bin:$PATH +MANPATH=$QTDIR/doc/man:$MANPATH + +# Act appropriately if LD_LIBRARY_PATH is not already set. +if [ -z $LD_LIBRARY_PATH ]; then + LD_LIBRARY_PATH=$KDEDIR/lib:$QTDIR/lib +else + LD_LIBRARY_PATH=$KDEDIR/lib:$QTDIR/lib:$LD_LIBRARY_PATH +fi + +export QTDIR KDEDIRS PATH MANPATH LD_LIBRARY_PATH + + +or, if you are not building qt-copy (and are using your system &Qt; instead), add +this instead: + + +KDEDIR=(path to kdedir) # Such as ~/kde by default. +KDEDIRS=$KDEDIR +PATH=$KDEDIR/bin:$QTDIR/bin:$PATH + +# Act appropriately if LD_LIBRARY_PATH is not already set. +if [ -z $LD_LIBRARY_PATH ]; then + LD_LIBRARY_PATH=$KDEDIR/lib +else + LD_LIBRARY_PATH=$KDEDIR/lib:$LD_LIBRARY_PATH +fi + +export KDEDIRS PATH LD_LIBRARY_PATH + + + + +If you are not using a dedicated user, set a different $KDEHOME +for your new environment in your .bash_profile: + + +export KDEHOME="${HOME}/.kde-svn" + +# Create it if needed +[ ! -e ~/.kde-svn ] && mkdir ~/.kde-svn + + + + + +If later your K Menu is empty or too crowded with applications from your +distribution, you may have to set the XDG environment +variables in your .bash_profile: + + +XDG_CONFIG_DIRS="/etc/xdg" +XDG_DATA_DIRS="${KDEDIR}/share:/usr/share" +export XDG_CONFIG_DIRS XDG_DATA_DIRS + + + + + + + +Starting &kde; + + +Now that you have adjusted your environment settings to use the correct &kde;, +it is important to ensure that the correct startkde script +is used as well. + + + +Open the .xinitrc text file from the home directory, or +create it if necessary. Add the line: + + +exec + + + +On some distributions, it may be necessary to perform the same +steps with the .xsession file, also in the home directory. +This is especially true when using graphical login managers such as +&kdm;, gdm, or xdm. + + + +Now start your fresh &kde;: in &BSD; and &Linux; systems with virtual terminal support, +&Ctrl;&Alt;F1 ... &Ctrl;&Alt;F12 keystroke combinations are used to switch to Virtual Console 1 through 12. +This allows you to run more than one desktop environment at the same time. The fist six are +text terminals and the following six are graphical displays. + + + +If when you start your computer you are presented to the graphical display +manager instead, you can use the new &kde; environment, even if it is not listed +as an option. Most display managers, including &kdm;, have an option to use +a Custom Session when you login. With this option, your session settings are +loaded from the .xsession file in your home directory. If +you have already modified this file as described above, this option should load +you into your new &kde; installation. + + +If it does not, there is something else you can try that should normally +work: Press &Ctrl;&Alt;F2, +and you will be presented to a text terminal. Log in using the dedicated user +and type: + + + +startx + + + + +You can run the &kde; from sources and the old &kde; at the same time! Log in +using your regular user, start the stable &kde; desktop. Press &Ctrl;&Alt;F2 (or +F1, F3, etc..), and you will be presented +with a text terminal. Log in using the dedicated &kde; &subversion; user and +type: + + +startx + + +You can go back to the &kde; desktop of your regular user by pressing the +shortcut key for the already running desktop. This is normally +&Ctrl;&Alt;F7, you may need +to use F6 or F8 instead. To return to your +&kdesrc-build;-compiled &kde;, you would use the same sequence, except with the +next function key. For example, if you needed to enter &Ctrl;&Alt;F7 +to switch to your regular &kde;, you would need to enter +&Ctrl;&Alt;F8 to go back +to your &kdesrc-build; &kde;. + + + + + + + + +Script Features + + +Feature Overview + + +&kdesrc-build; features include: + + + + + +You can pretend to do the operations. If you pass + or on the +command line, the script will give a verbose description of the commands +it is about to execute, without actually executing it. + +For an even more verbose description of what &kdesrc-build; is +doing, try using the option. + + + + + +&kdesrc-build; can (with the assistance of the &kde; FTP server) allow for +speedy checkouts of +some Subversion modules. If the module you are checking out has already been +packaged at the website, then &kdesrc-build; will download the snapshot and +prepare it for use on your computer. + + +There is generally no need for any special preparation to perform +the initial checkout of a Git module, as the entire Git repository must be +downloaded anyways, so it is easy for the server to determine what to +send. + +This is faster for you, and helps to ease the load on the kde.org +anonymous &subversion; servers. + + + +Another speedup is provided by starting the build process for a module as soon +as the source code for that module has been downloaded. (Available since +version 1.6) + + + +Excellent support for building the &Qt; library, +including optionally applying &kde;-recommended bugfix and optimization patches +to the module. + +For historical reasons, the &kdesrc-build; module used to build +&Qt; should be called qt-copy. See also . + + + + + +&kdesrc-build; does not require a GUI present to operate. So, +you can build &kde; without needing an alternate graphical environment. + + + +Supports setting default options for all modules (such as the compilation +settings or the configuration options). Such options can normally be changed +for specific modules as well. + +Also, &kdesrc-build; will add +standard flags as appropriate to save you the trouble and possible +errors from typing them yourself. + + + +&kdesrc-build; can checkout a specific branch +or tag of a module. You can also ensure that a specific revision is checked out of a module. + + + +&kdesrc-build; can automatically switch a source directory to checkout from +a different repository, branch, or tag. This happens automatically when you +change an option that changes what the repository &url; should be, but you must +use the --src-only option to let +&kdesrc-build; know that it is acceptable to perform the switch. + + + +&kdesrc-build; can checkout only portions of a +module, for those situations where you only need one program from a +large module. + + + +For developers: &kdesrc-build; will remind +you if you use svn+ssh:// but ssh-agent is +not running, as this will lead to repeated password requests from +&ssh;. + + + +Can delete the build directory of a +module after its installation to save space at the expense of future compilation +time. + + + +The locations for the directories used by &kdesrc-build; are configurable (even +per module). + + + +Can use &sudo;, or a different user-specified command +to install modules so that +&kdesrc-build; does not need to be run as the super user. + + + +&kdesrc-build; runs with reduced priority +by default to allow you to still use your computer while &kdesrc-build; is +working. + + + +Has support for using &kde;'s tags and +branches. + + + +There is support for resuming a build from a +given module. You can even ignore some +modules temporarily for a given build. + + + +&kdesrc-build; can quickly perform a partial +build of a module directly from the command line, when you only need +to update part of a module. + + + +&kdesrc-build; will show the progress of your +build when using &cmake;, and will always time the build +process so you know after the fact how long it took. + + + +Comes built-in with a sane set of default options appropriate for building +a base &kde; single-user installation from the anonymous source repositories. + + + +Tilde-expansion for your configuration options. For example, you can +specify: +qtdir ~/kdesrc/build/qt-copy + + + +Automatically sets up a build system, with the source directory not the +same as the build directory, in order to keep the source directory +pristine. + + + +You can specify global options to apply to every module to check out, and +you can specify options to apply to individual modules as well. + + + +Forced full rebuilds, by running +&kdesrc-build; with the option. + + + +You can specify various environment values to be used during the build, +including KDEDIR, QTDIR, DO_NOT_COMPILE, +and CXXFLAGS. + + + +Command logging. Logs are dated and numbered so that you always have a +log of a script run. Also, a special symlink called latest is created to +always point to the most recent log entry in the log directory. + + + +You can check out only a portion of a &kde; &subversion; module. For example, +you could check out only the taglib from +kdesupport. + + + + + + + +&kdesrc-build;'s build logging + + +Logging overview + +Logging is a &kdesrc-build; feature whereby the output from every command +that &kdesrc-build; runs is saved to a file for examination later, if +necessary. This is done because it is often necessary to have the output of +these programs when there is a build failure, because there are so many +reasons why a build can fail in the first place. + + +Logging directory layout + +The logs are always stored under the log directory. The destination of +the log directory is controlled by the log-dir +option, which defaults to ${source-dir}/log (where +${source-dir} is the value of the source-dir +option. The in rest of this section, this value will be referred to as +${log-dir}). + +Under ${log-dir}, is a set of directories, one for every +time that &kdesrc-build; was run. Each directory is named with the date, and +the run number. For instance, the second time that &kdesrc-build; is run on +May 26, 2004, it would create a directory called 2004-05-26-02, +where the 2004-05-26 is for the date, and the -02 is the run number. + +For your convenience, &kdesrc-build; will also create a link to the +logs for your latest run, called latest. So the logs for +the most recent &kdesrc-build; run should always be under ${log-dir}/latest. + + +Now, each directory for a &kdesrc-build; run will itself contain a set of +directories, one for every &kde; module that &kdesrc-build; tries to build. Also, +a file called build-status will be contained in the directory, +which will allow you to determine which modules built and which failed. + + +If a module itself has a submodule (such as extragear/multimedia, +playground/utils, or KDE/kdelibs), then there would actually be a matching +layout in the log directory. For example, the logs for KDE/kdelibs after the +last &kdesrc-build; run would be found in ${log-dir}/latest/KDE/kdelibs, +and not under ${log-dir}/latest/kdelibs. + + +In each module log directory, you will find a set of files for each +operation that &kdesrc-build; performs. If &kdesrc-build; updates a module, +you may see filenames such as svn-co.log (for a +module checkout) or svn-up.log (when updating a module +that has already been checked out). If the configure +command was run, then you would expect to see a configure.log +in that directory. + +If an error occurred, you should be able to see an explanation of why in +one of the files. To help you determine which file contains the error, +&kdesrc-build; will create a link from the file containing the error (such as +build-1.log to a file called error.log). + +The upshot to all of this is that to see why a module failed to build +after your last &kdesrc-build;, the file you should look at first is +${log-dir}/latest/module-name/error.log. + + +If the file error.log is empty (especially after +an installation), then perhaps there was no error. Some of the tools used by +the &kde; build system will sometimes mistakenly report an error when there was +none. + +Also, some commands will evade &kdesrc-build;'s output redirection and +bypass the log file in certain circumstances (normally when performing the +first &subversion; checkout), and the error output in that case is not in the log file +but is instead at the &konsole; or terminal where you ran &kdesrc-build;. + + + + + + + + + +Configuring &kdesrc-build; + + +Overview of &kdesrc-build; configuration + + +To use the script, you must have a file in your home directory called +.kdesrc-buildrc, which describes the modules you would +like to download and build. + + + +Layout of the configuration file + + +Global configuration + + +The configuration file starts with the global options, specified like the +following: + + + +global +option-name option-value +[...] +end global + + + + +Module configuration + + +It is then followed by one or more module sections, specified in one of the +following two forms: + + + + + +module module-name +option-name option-value +[...] +end module + + + + + +module-set module-set-name + repository kde-projects or git://host.org/path/to/repo.git + use-modules module-names + +# Other options may also be set +option-name option-value +[...] +end module-set + + + + +Note that the second form, module sets, only works +for Git-based modules. + + +For Subversion modules, module-name must be a module +from the &kde; &subversion; repository (for example, kdeartwork or +kde-wallpapers), although it is possible to get around this if you manually +specify the &subversion; URL. + + + +For Git modules, the module name can be essentially whatever you'd like, as +long as it does not duplicate any other module name in the configuration. Keep +in mind the source and build directory layout will be based on the module name +if you do not use the dest-dir option. + + +However, for Git module sets the +module-names must correspond with actual git modules +in the chosen . See git-repository-base or use-modules for more information. + + + + + + +Including other configuration files + + +Within the configuration file, you may reference other files by using the +include keyword with a file, which will act as if the file +referenced had been inserted into the configuration file at that point. + + +For example, you could have something like this: + +global + include ~/common-kdesrc-build-options + + # Insert specific options here. + +end global + + + + + + +Commonly used configuration options + + +The following is a list of commonly-used options. Click on the +option to find out more about it. To see the full list of options, see +. + + + +cmake-options to define what flags to configure a module with using &cmake;. +branch, to checkout from a branch instead of /trunk (for &subversion;) or master (for Git). +configure-flags to define what flags to configure &Qt; with. +kdedir, to set the directory to install &kde; to. +make-options, to pass options to the &make; program (such as number of CPUs to use). +qtdir, to set the path to &Qt;. +source-dir, to change where to download the source code to. + + + + + +Table of available configuration options + +Here is a table of the various options, containing the following +information: + + + +The option name + +A description of how &kdesrc-build; responds if the option is +set in both the global section, and the module section of the configuration file while building a +module. + +Special comments on the purpose and usage of the +option. + + + + +Table of Options + + + + +Option-name +Module -> Global Behavior +Notes + + + + + + +apidox + +This option was used to allow for building KDE module API documentation. +It was removed in &kdesrc-build; 1.6.3 due to it not being supported in KDE 4. Online +API documentation is available from kde.org. +In addition it is possible to build KDE 4's API documentation using a script included in +the kdesdk module (/scripts directory). See KDE +TechBase for more details. It is still possible to manually build API documentation +for older modules of course. + + + + +apply-qt-patches + +This option was removed in kdesrc-build 1.10. To get the same effect, +see and the repository option. + + + +async +Cannot be overridden +This option enables the asynchronous mode of operation, where the source +code update and the build process will be performed in parallel, instead of waiting for +all of the source code updates before starting the build process. This option defaults +to enabling asynchronous mode. To disable, set this option to false +This option is available since the 1.6 release. + + + +binpath +Module setting overrides global +Set this option to set the environment variable PATH while building. +You cannot override this setting in a module option. The default value is +the $PATH that is set when the script starts. This environment +variable should include the colon-separated paths of your development +toolchain. The paths $KDEDIR/bin and +$QTDIR/bin are automatically added. You +may use the tilde (~) for any paths you add using this option. + + + + +branch +Module setting overrides global +Set this option to checkout from a branch of &kde; instead of the +default of trunk, where &kde; development occurs. +For instance, to checkout &kde; 4.6 branch, you would set this option to +4.6. +If &kdesrc-build; fails to properly download a branch with this option, you +may have to manually specify the &url; to download from using the module-base-path or override-url options. +Note: This option also works with source modules that use +&git; instead of &subversion;. + + + + +build-dir +Module setting overrides global +Use this option to change the directory to contain the built sources. There +are three different ways to use it: + + + +Relative to the &kde; &subversion; source directory (see the source-dir option). This is the default, +and is selected if you type a directory name that does not start with a tilde +(~) or a slash (/). The default value is build. + +Absolute path. If you specify a path that begins with a /, then +that path is used directly. For example, /tmp/kde-obj-dir/. + +Relative to your home directory. If you specify a path that +begins with a ~, then the path is used relative to your home directory, +analogous to the shell's tilde-expansion. For example, ~/builddir would set the build directory to +/home/user-name/builddir. + + + +Perhaps surprisingly, this option can be changed per module. + + + + + +build-when-unchanged +Module setting overrides global +Use this option in order to control whether &kdesrc-build; always +tries to build a module that has not had any source code updates. + +By setting to +true, &kdesrc-build; always attempts the build phase +for a module, even if the module did not have any source code updates. This is +the default setting since it is more likely to lead to a correct +build. + +By setting to +false, &kdesrc-build; will only attempt to run the +build phase for a module if the module has a source code update, or in other +situations where it is likely that a rebuild is actually required. This can save +time, especially if you run &kdesrc-build; daily, or more frequently. + +This feature is provided as an optimization only. Like many +other optimizations, there are trade-offs for the correctness of your +installation. For instance, changes to the qt-copy or kdelibs modules may cause +a rebuild of other modules to be necessary, even if the source code doesn't +change at all. + + + + +checkout-only +Module setting overrides global +Set this option to checkout &subversion; sources piece by piece. The +value for this option should be a space-separated list of directories to +checkout. Although this option overrides the global option, be aware that +setting this as a global option makes no sense. + + +Note that this setting has no effect on &git; modules due to the +operation of the &git; source control system. + +See for an example. + + + +cmake-options +Appends to global options (not applicable to qt-copy) +Use this option to specify what flags to pass to &cmake; when +creating the build system for the module. When this is used as a global option, +it is applied to all modules that this script builds. When used as a module +option, it is added to the end of the global options. This allows you to +specify common &cmake; options in the global section. + +This option does not apply to qt-copy (which does not use &cmake;). Use +configure-flags instead. + +Since these options are passed directly to the &cmake; command line, they +should be given as they would be typed into &cmake;. For example: + + cmake-options -DCMAKE_BUILD_TYPE=RelWithDebInfo + + +Since this is a hassle, &kdesrc-build; takes pains to ensure that as long +as the rest of the options are set correctly, you should be able to leave this +option blank. (In other words, required &cmake; parameters +are set for you automatically) + + + +colorful-output +Cannot be overridden +Set this option to false to disable the colorful output of &kdesrc-build;. +This option defaults to true. Note that &kdesrc-build; will not output the +color codes to anything but a terminal (such as xterm, &konsole;, or the normal +&Linux; console). + + + + +configure-flags +Module setting overrides global +Use this option to specify what flags to pass to ./configure when +creating the build system for the module. When this is used as a global-option, +it is applied to all modules that this script builds. This option +only works for qt-copy. + +To change configuration settings for KDE 4 modules, see +cmake-options. + + + + + +cxxflags +Appends to global option +Use this option to specify what flags to use for building the +module. This option is +specified here instead of with configure-flags or cmake-options because this option will also +set the environment variable CXXFLAGS during the build process. + +Note that for &kde; 4 and any other modules that use &cmake;, it is necessary to set the +CMAKE_BUILD_TYPE option to "none" when configuring the module. This can be done using the +cmake-options option. + + + + +dest-dir +Module setting overrides global +Use this option to change the name a module is given on disk. For +example, if your module was extragear/network, you could rename it to +extragear-network using this option. Note that although this changes the +name of the module on disk, it is not a good idea to include directories +or directory separators in the name as this will interfere with any +build-dir or +source-dir options. + + + + +disable-agent-check +Cannot be overridden +Normally if you are using &ssh; to download the &subversion; sources +(such as if you are using the svn+ssh protocol), &kdesrc-build; will try and +make sure that if you are using ssh-agent, it is actually managing some &ssh; +identities. This is to try and prevent &ssh; from asking for your pass phrase +for every module. You can disable this check by setting + to true. + + + + +do-not-compile +Module setting overrides global +Use this option to select a specific set of directories not to be built in a +module (instead of all of them). The directories not to build should be space-separated. + +Note that the sources to the programs will still be downloaded. You can use +the checkout-only +directive to choose directories that you want to check out. + +For example, to hold &juk; and &kscd; in the kdemultimedia module from +compiling, you would add "do-not-compile juk kscd" to your kdemultimedia settings. + +See for an example. + + + + +email-address +Cannot be overridden + +This option was removed in kdesrc-build 2.0. + + + + + +email-on-compile-error +Cannot be overridden + +This option was removed in kdesrc-build 2.0. + + + + + +inst-apps + + +This option was removed in version 1.10 + + + + +git-repository-base +Cannot be overridden +This option, added in version 1.12.1, is used to create a short +name to reference a specific Git repository base URL in later module set declarations, which is useful for +quickly declaring many Git modules to build. + +You must specify two things (separated by a space): The name to assign +to the base URL, and the actual base URL itself. For example: + + + + +global + # other options + + # This is the common path to all anonymous Git server modules. + git-repository-base kde-git kde: +end global + +# Module declarations + +module-set + # Now you can use the alias you defined earlier, but only + # in a module-set. + repository kde-git + + use-modules module1.git module2.git +end module-set + + + + +The module-set's use-modules option created two modules +internally, with &kdesrc-build; behaving as if it had read: + + +module module1 + repository kde:module1.git +end module + +module module2 + repository kde:module2.git +end module + + +The kde: &git; repository prefix used above is a +shortcut which will be setup by &kdesrc-build; automatically. See the TechBase +URL +Renaming article for more information. Note that unlike most other +options, this option can be specified multiple times in order to create as +many aliases as necessary. + +It is not required to use this option to take advantage of module-set, +this option exists to make it easy to use the same repository across many +different module sets. + + + + +install-after-build +Module setting overrides global +This option is used to install the package after it successfully builds. +This option is enabled by default. If you want to disable this, you need to set +this option to false in the configuration file. You can also use the command line +flag. + + + + +kdedir +Module setting overrides global +This option sets the directory that &kde; will be installed to after it +is built. It defaults to ~/kde. If you +change this to a directory needing root access, you may want to read about the +make-install-prefix option as +well. + + + +kde-languages +Cannot be overridden +This option allows you to choose to download and install +localization packages along with &kde;. You might do this if you do not live in +the United States and would like to use &kde; translated into your native +language. + +To use this option, set it to a space-separated list of languages to +install. Each language has a language code associated with it, which you +can look up at this page: http://i18n.kde.org/teams/. + + +It is alright to choose only one language. By default, none are +downloaded, which means &kde; will display in American English. + +For instance, to choose to install French, you would set the option to +something like: +fr. You would still need to use +&systemsettings; in order to choose the French language, however. + + + + +libpath +Module setting overrides global +Set this option to set the environment variable +LD_LIBRARY_PATH while building. You cannot override this setting +in a module option. The default value is blank, but the paths $KDEDIR/lib and $QTDIR/lib are automatically added. +You may use the tilde (~) for any paths you add using this option. + + + + +log-dir +Module setting overrides global +Use this option to change the directory used to hold the log files +generated by the script. + + + + +make-install-prefix +Module setting overrides global +Set this variable to a space-separated list, which is interpreted as a +command and its options to precede the make command used to install +modules. This is useful for installing packages with &sudo; for example, but +please be careful while dealing with root privileges. + + + +make-options +Module setting overrides global +Set this variable in order to pass command line options to the +make command. This is useful for programs such as distcc or +systems with more than one processor core. + + + + +manual-build +Module setting overrides global +Set the option value to true to keep the +build process from attempting to build this module. It will still be kept +up-to-date when updating from &subversion;. This option is exactly equivalent +to the +command line option. + + + + +manual-update +Module setting overrides global +Set the option value to true to keep the +build process from attempting to update (and by extension, build or install) +this module. If you set this option for a module, then you have essentially +commented it out. + + + + +module-base-path +Module setting overrides global +Set this option to override &kdesrc-build;'s default directory path to the +module in question. This can be used, for example, to pull specific branches +or tagged versions of libraries. The &kde; +Source Viewer is invaluable in helping to pick the right path. + +Note that &kdesrc-build; constructs the final path according to the +following template: +$svn-server/home/kde/$module-base-path. + + +The default value is either trunk/$module or trunk/KDE/$module, depending on +the module name. + +Use the branch or tag options instead whenever they are applicable. + + + + + +niceness +Cannot be overridden +Set this option to a number between 20 and 0. The higher the number, the +lower a priority &kdesrc-build; will set for itself, i.e. the higher the +number, the "nicer" the program is. The default is 10. + + + + +no-svn +Module setting overrides global +If this option is set to true then &kdesrc-build; will not update the +source code for the module automatically. It will still try to build the +module if it normally would have tried anyways. + + + +no-rebuild-on-fail + +This option was removed in version 1.10, since this behavior no longer helps +due to fixes in the underlying build system. + + + +override-url +Module setting overrides global +If you set this option, &kdesrc-build; will use its value as the &url; +to pass to &subversion; completely unchanged. You should +generally use this if you want to download a specific release but &kdesrc-build; +cannot figure out what you mean using branch. + + + + +prefix +Module setting overrides global +This option controls where to install the module (normally the + setting is used). +Using this option allows you to install a module to a different directory than +where the KDE Platform libraries are installed, such as if you were using +&kdesrc-build; only to build applications. + + + + +purge-old-logs +Module setting overrides global +This option controls whether old log directories are automatically +deleted or not. The default value is true. + + + + +qtdir +Module setting overrides global +Set this option to set the environment variable QTDIR while building. +You cannot override this setting in a module option. If you do not specify +this option, it defaults to +${source-dir}/build/qt-copy, +which uses the qt-copy module included in the &kde; source repository. +You may use a tilde (~) to represent your home directory. + + + + +remove-after-install +Module setting overrides global +If you are low on hard disk space, you may want to use this option +in order to automatically delete the build directory (or both the source and +build directories for one-time installs) after the module is successfully +installed. + +Possible values for this option are: + +none - Do not delete anything (This is the default). +builddir - Delete the build directory, but not the source. +all - Delete both the source code and build directory. + + + +Note that using this option can have a significant detrimental impact on +both your bandwidth usage (if you use all) and the time taken to compile &kde;, +since &kdesrc-build; will be unable to perform incremental builds. + + + + +repository +Module setting overrides global +This option was introduced with version 1.10, and is used to +specify the &git; repository to download the source code for the module. +&Qt; (and therefore qt-copy) would need this option, as well as various +&kde; modules that are in the process of conversion to use &git;. + + + +revision +Module setting overrides global +If this option is set to a value other than 0 (zero), &kdesrc-build; +will force the &subversion; update to bring the module to the exact revision +given, even if options like branch are in +effect. If the module is already at the given revision then it will not be +updated further unless this option is changed or removed from the +configuration. + + + +run-tests +Module setting overrides global +If set to true, then the module will be +built with support for running its test suite, and the test suite will be +executed as part of the build process. &kdesrc-build; will show a simple +report of the test results. This is useful for developers or those who want +to ensure their system is setup correctly. + + + +set-env +Module setting overrides global +This option accepts a space-separated set of values, where the first value +is the environment variable to set, and the rest of the values is what you +want the variable set to. For example, to set the variable RONALD to +McDonald, you would put in the appropriate section this command: +set-env RONALD McDonald +This option is special in that it can be repeated without overriding +earlier set-env settings in the same section of the configuration file. This +way you can set more than one environment variable per module (or +globally). + + + + +source-dir +Module setting overrides global +This option is used to set the directory on your computer to store the &kde; +&subversion; sources at. If you do not specify this value, the default is +~/kdesrc. You may use the tilde (~) +to represent the home directory if using this option. + + + + +stop-on-failure +Module setting overrides global +Set this option value to true to cause the script to stop execution +after an error occurs during the build or install process. This option is off +by default. + + + + +svn-server +Module setting overrides global +This option is used to set the server used to check out from &subversion;. +The default is the anonymous &subversion; repository, svn://anonsvn.kde.org/ +If you are developing for KDE, use the &subversion; repository that +was provided to you when you received your developer account, instead of the +anonymous repository. + + + + +tag +Module setting overrides global +Use this option to download a specific release of a module. +Note: The odds are very good that you do not +want to use this option. &kde; releases are available in tarball form +from The &kde; FTP site or one of its mirrors. + + + + +use-cmake + +This option was removed in &kdesrc-build; 1.4 as all &kde; 4 modules +require &cmake;, and &cmake; use is not permitted on any other modules. + + + + +use-idle-io-priority +Cannot be overridden +This option, added in &kdesrc-build; 1.12, will cause a lower priority +to be used for disk and other I/O usage, which can significantly improve the +responsiveness of the rest of the system at the expense of slightly longer +running times for &kdesrc-build;. The default is to be disabled, to enable +the lower disk priority set this to true. + + + + +use-modules +Can only use in module-set +This option, added in &kdesrc-build; 1.12.1, allows you to easily +specify many different modules to build at the same point in the configuration file. + +This option must be used within a +module-set. Every identifier passed to this option is +internally converted to a &kdesrc-build; module, with a option set to the +module-set's repository combined with the identifier name in order to setup the +final repository to download from. All other options that are assigned in the +module-set are also copied to the generated modules unaltered. + +The order that modules are defined in this option is important, because +that is also the order that &kdesrc-build; will process the generated modules +when updating, building, and installing. All modules defined in the given +module-set will be handled before &kdesrc-build; moves to the next module after +the module-set. + +If you need to change the options for a generated module, simply declare +the module again after it is defined in the module-set, and set your options +as needed. Although you will change the options set for the module this way, +the module will still be updated and built in the order set by the module-set +(i.e. you can't reorder the build sequence doing this). + +The name to use for the module if you do this is simply the +name that you passed to , with the exception that +any .git is removed. + +See and git-repository-base for a description +of its use and an example. + + + + +use-qt-builddir-hack +Module setting overrides global +This option has been removed due to improvements in the &Qt; build +system. + + + + +use-stable-kde + + +This option was removed in version 1.10, which limits support to KDE 4, +removing the effect of this option. + + + + + + + +
+ +
+
+ + +Command Line Options and Environment Variables + + +Command Line Usage + +&kdesrc-build; is designed to be run as follows: + + +kdesrc-build +--options +modules to build + + +If no modules to build are specified on the command line, then +kdesrc-build will build all modules defined in its configuration file, in the +order listed in that file (although this can be modified by various +configuration file options). + + +Commonly used command line options + +The full list of command line options is given in . The most-commonly used options +include: + + + + (or ) + This option causes &kdesrc-build; to indicate what actions + it would take, without actually really implementing them. This can be + useful to make sure that the modules you think you are building will + actually get built. + + + + + This option forces &kdesrc-build; to build the given + modules from an absolutely fresh start point. Any existing build directory + for that module is removed and it is rebuilt. This option is useful if you + have errors building a module, and sometimes is required when &Qt; or &kde; + libraries change. + + + + + This option skips the source update process. You might use + it if you have very recently updated the source code (perhaps you did it + manually or recently ran &kdesrc-build;) but still want to rebuild some + modules. + + + + + This option is similar to above, + but this time the build process is skipped. + + + + + + +Specifying modules to build + +In general, specifying modules to build is as simple as passing their +module name as you defined it in the configuration file. You can also pass +modules that are part of a module set, either as named on use-modules, or the name of the entire module +set itself, if you have given it a name. + +In the specific case of module sets based against the KDE project database, &kdesrc-build; +will expand module name components to determine the exact module you +want. For example, &kdesrc-build;'s KDE project entry locates the project in +extragear/utils/kdesrc-build. You could specify any +of the following to build &kdesrc-build;: + + + +% kdesrc-build +% kdesrc-build +% kdesrc-build + + + +The commands in the previous example preceded the module-name with +a +. This forces the module name to be interpreted as a module +from the KDE project database, even if that module hasn't been defined in your +configuration file. + + +Be careful about specifying very generic projects (e.g. +extragear/utils by itself), as this can lead to a large +amount of modules being built. You should use the +option before building a new module set to ensure it is only building the +modules you want. + + + + + +Supported Environment Variables + + +&kdesrc-build; does not use environment variables. If you need to set environment +variables for the build or install process, please see the set-env option. + + + + + +Supported command-line parameters + + +The script accepts the following command-line options: + + + + + +--async + +Enables the asynchronous mode, which can +perform the source code updates and module builds at the same time. This is +the default, this option only needs specified if you have disabled it in the +configuration. + + + + +--help + +Only display simple help on this script. + + + + +--version + +Display the program version. + + + + +--author + +Display contact information for the +author. + + + + +--color + +Enable colorful output. (This is the default for interactive terminals). + + + + +--nice=value + +This value adjusts the computer CPU priority requested by &kdesrc-build;, and +should be in the range of 0-20. 0 is highest priority (because it is the +least nice), 20 is lowest priority. &kdesrc-build; defaults +to 10. + + + + +--no-async + +Disables the asynchronous mode of updating. +Instead the update will be performed in its entirety before the build starts. +This option will slow down the overall process, but if you encounter IPC errors +while running &kdesrc-build; try using this option, and submitting a +bug report. + + + + +--no-color + +Disable colorful output. + + + + +--pretend (or -p) + +&kdesrc-build; will run through the update and build process, but instead of +performing any actions to update or build, will instead output what the +script would have done (e.g. what commands to run, general steps being taken, +etc.). + +Note: Simple read-only commands (such as reading file information) may +still be run to make the output more relevant (such as correctly simulating +whether source code would be checked out or updated). + + + + +--quiet (or -q) + +Do not be as noisy with the output. With this switch only the basics are +output. + + + + +--really-quiet + +Only output warnings and errors. + + + + +--verbose (or -v) + +Be very descriptive about what is going on, and what &kdesrc-build; is doing. + + + + +--src-only (or --svn-only) + +Only perform the source update. (The --svn-only is +only supported for compatibility with older scripts). + + + + +--build-only + +Only perform the build process. + + + + +--ignore-modules + +Do not include the modules passed on the rest of the command line in the +update/build process (this is useful if you want to build most of the modules +in your configuration file and just skip +a few). + + + + +--no-src (or --no-svn) + +Skip contacting the &subversion; server. (The --no-svn +parameter is only supported for compatibility with older versions of the +script). + + + + +--no-build + +Skip the build process. + + + + +--no-install + +Do not automatically install packages after they are built. + + + + +--no-build-when-unchanged +--force-build + +This option explicitly disables skipping the build process (an optimization +controlled by the build-when-unchanged option). This is +useful for making &kdesrc-build; run the build when you have changed something +that &kdesrc-build; cannot check. + +--force-build performs the exact same function, and +is perhaps easier to remember. + + + + +--debug + +Enables debug mode for the script. Currently this means that all output will be +dumped to the standard output in addition to being logged in the log directory +like normal. Also, many functions are much more verbose about what they are +doing in debugging mode. + + + + +--no-rebuild-on-fail + +Do not try to +rebuild modules that have failed building from scratch. &kdesrc-build; will +never try to do this to a module that already was tried to be built from +scratch. + + + + +--refresh-build + +Recreate the build system and make from scratch. + + + + +--reconfigure + +Run cmake (for &kde; modules) or +configure (for &Qt;) again, without cleaning the build +directory. You should not normally have to specify this, as &kdesrc-build; will +detect when you change the relevant options and automatically re-run the build +setup. This option is implied if --refresh-build is used. + + + + +--resume-from + +This option is used to resume the build starting from the given module, which +should be the next option on the command line. You should not +specify other module names on the command line. + + +This option formerly added --no-src, but does +not any longer (since &kdesrc-build; 1.13). If you want to avoid source updates +when resuming, simply pass +in addition to the other options. + + +See also: and . You would prefer to use this command line option +if you have fixed the build error and want &kdesrc-build; to complete the +build. + + + +--resume-after + +This option is used to resume the build starting after the given module, which +should be the next option on the command line. You should not +specify other module names on the command line. + + +This option formerly added --no-src, but does +not any longer (since &kdesrc-build; 1.13). If you want to avoid source updates +when resuming, simply pass +in addition to the other options. + + +See also: and . You would prefer to use this command line option +if you have fixed the build error and have also built and installed the module +yourself, and want &kdesrc-build; to start again with the next +module. + + + +--rc-file + +This interprets the next command line parameter as the file to read the +configuration options from. The default value for this parameter is +kdesrc-buildrc (checked in the current directory) if +it is present, or ~/.kdesrc-buildrc otherwise. See +also . + + + + +--run + +This option interprets the next item on the command line as a program to run, +and &kdesrc-build; will then finish reading the configuration file, update the +environment as normal, and then execute the given program. + +This will not work to start a shell with the &kdesrc-build; environment +in most cases however, since interactive shells typically reset at least part +of the environment variables (such as PATH and +KDEDIRS) in the startup sequence. + + +If you want to see the environment used by &kdesrc-build;, you +can run the printenv command: + +$ kdesrc-build --run printenv +KDE_SESSION_VERSION=4 +SDL_AUDIODRIVER=alsa +LANGUAGE= +XCURSOR_THEME=Oxygen_Blue +LESS=-R -M --shift 5 +QMAIL_CONTROLDIR=/var/qmail/control +... etc. + + + + + + +--prefix=</path/to/kde> + +This allows you to change the directory that &kde; will be installed to from +the command line. This option implies --reconfigure, +but using --refresh-build +may still be required. + + + + +--revision + +This option causes &kdesrc-build; to checkout a specific numbered revision +for each &subversion; module, overriding any branch, +tag, or revision +options already set for these modules. + +This option is likely not a good idea, and is only supported for +compatibility with older scripts. + + + + +--build-system-only + +This option causes &kdesrc-build; to abort building a module just before +the make command would have been run. This is supported +for compatibility with older versions only, this effect is not helpful for +the current &kde; build system. + + + +--install + +If this is the only command-line option, it tries to install all of the modules +contained in log/latest/build-status. If command-line +options are specified after --install, they are all +assumed to be modules to install (even if they did not successfully build on +the last run). + + + +--no-snapshots + +Supplying this option causes &kdesrc-build; to always perform a normal initial +checkout of a module instead of using a quick-start snapshot (only available +for Git modules from the kde-projects repository). + +Note that this option should only be used if there is a failure using +snapshots, as the quick-start snapshot reduces load on the KDE source +repositories. + + +Module snapshots are real checkouts. You +should not need to specify this option, it is only a troubleshooting +aid. + + + + +--<option-name>= + +You can use this option to override an option in your configuration file for +every module. For instance, to override the log-dir option, you would do: +--log-dir=/path/to/dir. + + + + +--<module-name>,<option-name>= + +You can use this option to override an option in your configuration file for +a specific module. + + + + + + +Any other command-line options are assumed to be modules to update and build. +Please, do not mix building with installing. + + + + + + + +Using &kdesrc-build; + + +Preface + +Normally using &kdesrc-build; after you have gone through +is as easy as doing the following from a terminal prompt: + + +% kdesrc-build + + +&kdesrc-build; will then download the sources for &kde;, try to configure +and build them, and then install them. + +Read on to discover how &kdesrc-build; does this, and what else you can +do with this tool. + + + + +Basic &kdesrc-build; features + + +qt-copy support +&kdesrc-build; supports building the &Qt; toolkit used by &kde; software +as a convenience to users. This support is handled by a special module named +qt-copy. + +&Qt; is developed under a separate repository from &kde; software +located at http://qt.gitorious.org/qt. + +In order to build &Qt;, you should make sure that the +qtdir setting is set to the directory you'd +like to install &Qt; to, as described in . + +You should then ensure that the qt-copy module is added to +your .kdesrc-buildrc, before any other modules in the +file. If you are using the sample configuration file, you can simply +uncomment the existing qt-copy module entry. + +Now you should verify the repository option and branch options are set appropriately: + + +The first option is to build &Qt; using a mirror maintained +on the &kde; source repositories (no other changes are applied, it is simply +a clone of the official source). This is highly recommended due to occasional +issues with cloning the full &Qt; module from its official repository. + +You can set the option for the qt-copy +module to kde:qt to use this option. + + +Otherwise, to build the standard &Qt;, set your + option to +git://gitorious.org/qt/qt.git. Note that you may +experience problems performing the initial clone of &Qt; from this +repository. + + +In both cases, the branch option should be set to master (unless you'd +like to build a different branch). + + + + +Standard flags added by &kdesrc-build; +To save you time, &kdesrc-build; adds some standard paths to your +environment for you: + + + + +The path to the &kde; and &Qt; libraries is added to the +LD_LIBRARY_PATH variable automatically. This means that you +do not need to edit &libpath; to include them. + + + +The path to the &kde; and &Qt; development support programs are added to the +PATH variable automatically. This means that you do not need to +edit &binpath; to include them. + + + +The path to the &kde;-provided pkg-config is added +automatically to PKG_CONFIG_PATH. This means that you do not +need to use &set-env; to add these. + + + +The setting for &kdedir; is automatically propagated to the KDEDIR +environment variable while building. (KDEDIRS is not affected). + + + +The setting for &qtdir; is automatically propagated to the QTDIR +environment variable while building. + + + + + + + +Changing &kdesrc-build;'s build priority +Programs can run with different priority levels on Operating Systems, +including &Linux; and &BSD;. This allows the system to allocate time for the +different programs in accordance with how important they are. + + +&kdesrc-build; will normally allocate itself a low priority so that the +rest of the programs on your system are unaffected and can run normally. +Using this technique, &kdesrc-build; will use extra CPU when it is available. + + +&kdesrc-build; will still maintain a high enough priority level so that +it runs before routine batch processes and before CPU donation programs +such as Seti@Home. + + +To alter &kdesrc-build; so that it uses a higher (or lower) priority +level permanently, then you need to adjust the &niceness; setting in the configuration file. The &niceness; setting +controls how nice &kdesrc-build; is to other programs. In other +words, having a higher &niceness; gives &kdesrc-build; a lower priority. So to +give &kdesrc-build; a higher priority, reduce the &niceness; (and vice versa). +The &niceness; can go from 0 (not nice at all, highest priority) to 20 (super +nice, lowest priority). + +You can also temporarily change the priority for &kdesrc-build; by using +the &cmd-nice; command line option. The value to +the option is used exactly the same as for &niceness;. + +It is possible for some programs run by the super user to have a +negative nice value, with a correspondingly even higher priority for such +programs. Setting a negative (or even 0) &niceness; for &kdesrc-build; is not +a great idea, as it will not help run time significantly, but will make your +computer seem very sluggish should you still need to use it. + + + +To run &kdesrc-build; with a niceness of 15 (a lower priority than +normal): + + +% kdesrc-build + + +Or, you can edit the configuration file to make the change permanent: + + + &niceness; 15 + + + + +The niceness option only affects the +usage of the computer's processor(s). One other major affect on computer +performance relates to how much data input or output (I/O) a +program uses. In order to control how much I/O a program can +use, modern &Linux; operating systems support a similar tool called +ionice. &kdesrc-build; supports +ionice, (but only to enable or disable it +completely) using the use-idle-io-priority option, +since &kdesrc-build; version 1.12. + + + + + + +Installation as the superuser +You may wish to have &kdesrc-build; run the installation with super user +privileges. This may be for the unrecommended system-wide installation. +This is also useful when using a recommended single user &kde; build, however. +This is because some modules (especially kdebase) install programs that will +briefly need elevated permissions when run. They are not able to achieve these +permission levels unless they are installed with the elevated permissions. + + +You could simply run &kdesrc-build; as the super user directly, but this +is not recommended, since the program has not been audited for that kind of use. +Although it should be safe to run the program in this fashion, it is better to +avoid running as the super user when possible. + +To take care of this, &kdesrc-build; provides the &make-install-prefix; +option. You can use this option to specify a command to use to perform the +installation as another user. The recommended way to use this command is with +the &sudo; program, which will run the install command as the super user. + + + +For example, to install all modules using &sudo;, +you could do something like this: + + +global + &make-install-prefix; sudo + # Other options +end global + + +To use &make-install-prefix; for only a single module, this would work: + + + +module kdemultimedia + &make-install-prefix; sudo +end module + + + + + + +Showing the progress of a module build +This feature is always available, and is automatically enabled when +possible. What this does is display an estimated build progress while +building a module; that way you know about how much longer it will take to +build a module. + + + + + + + +Advanced features + + +Partially building a module +It is possible to build only pieces from a single &kde; module. For +example, you may want to compile only one program from a module. &kdesrc-build; +has features to make this easy. There are several complementing ways to +do this. + + + +Checking out portions of a module + +This is perhaps the best way to do this. When it works, it will save you +download time and disk space. What happens is that &kdesrc-build; will download +only the parts of a module that you specify. This is done using the &checkout-only; +option for a module, which will specify a list of directories to download. + + + +If you do not already know what to download from a module, it may be a good idea +to browse the &subversion; layout for a module first, using +WebSVN. + + + +To only grab &kuser; and KSystemLog from +kdeadmin, you could use &checkout-only; like this: + + +module kdeadmin + &checkout-only; kuser ksystemlog +end module + + + + +The directories will be built in the order they are listed +in the option. If one of the directories needs something else from the module +to compile, then you need to make sure they are both in the &checkout-only; +line, and that the required dependency goes before the directory that needs it. + +Also, sometimes an application may need other directories and it is hard +to figure out what they are, which may require some trial and error of constantly +adding directories to the option to figure out. This option depends on support +from the build system of the module, so it is only useful for modules that are +collections of individual applications. + + +One final note to make about this option: If you change the value of this +option, you should use kdesrc-build + +in order to ensure that the module is reconfigured properly. In addition, +&kdesrc-build; will never remove existing files if you take away the number of +directories from your &checkout-only; option, or add the option to a module that +has already been checked out. + + + + +Removing directories from a build +Instead of restricting what is downloaded, it is possible to download +everything but have the build system leave out a few directories when it does +the build. This may be useful if one directory always breaks and is +unnecessary to the rest of the module. + + +This is controlled with the &do-not-compile; option. It works similar +to the &checkout-only; option just described, in that it is simply a list of +directories that should not be compiled. + + +Also like &checkout-only;, this option requires at least that the +build system for the module is reconfigured after changing +it. This is done using the kdesrc-build + + command. + + + +To remove the python directory +from the kdebindings build process: + + +module kdebindings + &do-not-compile; python +end module + + + + +This function depends on some standard conventions used in most +&kde; modules. Therefore it may not work for all programs. + + + + + + +Branching and tagging support for &kdesrc-build; + + +What are branches and tags? + +&subversion; supports managing the history of the &kde; source code. &kde; +uses this support to create branches for development, and to tag the repository +every so often with a new version release. + + +For example, the &kmail; developers may be working on a new feature in +a different branch in order to avoid breaking the version being used by most +developers. This branch has development ongoing inside it, even while the +main branch (called /trunk) may have development going on inside of it. + + +A tag, on the other hand, is a snapshot of the source code repository +at a position in time. This is used by the &kde; administration team to mark +off a version of code suitable for release and still allow the developers to +work on the code. + + +In &subversion;, there is no difference between branches, tags, or trunk within +the code. It is only a convention used by the developers. This makes it +difficult to properly support branches and tags within &kdesrc-build;. However, +there are some things that can be done. + + + + + +How to use branches and tags + +Support for branches and tags is handled by a set of options, which +range from a generic request for a version, to a specific &url; to download +for advanced users. + + +The easiest method is to use the &branch; and &tag; options. You simply +use the option along with the name of the desired branch or tag for a module, +and &kdesrc-build; will try to determine the appropriate location within the +&kde; repository to download from. For most &kde; modules this works very +well. + + +To download kdelibs from &kde; 4.6 (which is simply known as the 4.6 branch): + + + +module kdelibs + branch 4.6 + # other options... +end module + + +Or, to download kdemultimedia as it was released with &kde; 4.6.1: + + +module kdemultimedia + tag 4.6.1 + # other options... +end module + + + + +You can specify a global branch value. But if you do so, do not forget +to specify a different branch for modules that should not use the global branch! + + + + +Advanced branch support options + +&kdesrc-build; supports two options for situations where &branch; and &tag; +guess the correct path improperly: &module-base-path; and &override-url;. + + + + +&module-base-path; is used to help &kdesrc-build; fill in the missing part of +a module's path. In the &kde; repository, all of the paths are of the form +svnRoot/module-base-path/module-name. Normally &kdesrc-build; +can figure out the appropriate middle part by itself. When it cannot, you can use +&module-base-path;, like this: + + + + +module kdesupport + # kdesupport supports various tags to easily organize the required + # software for a given KDE Platform release. + module-base-path tags/kdesupport-for-4.5 +end module + + +This would cause &kdesrc-build; to download kdesupport from (in this example), +svn://anonsvn.kde.org/home/kde/tags/kdesupport-for-4.5. + + +In previous versions of &kdesrc-build;, the &module-base-path; was +handled differently. If you encounter trouble using an old module-base-path +definition perhaps you should verify that the actual path is as &kdesrc-build; +expects by using the --pretend option. + + + +The &override-url; option, on the other hand, requires you to +specify the exact path to download from. However, this allows you to pull from +paths that previous versions of &kdesrc-build; would have no hope of downloading from. +Currently, the &module-base-path; option should be sufficient for any Subversion +source URL. + + + +&kdesrc-build; will not touch or correct the value you specify for &override-url; +at all, so if you change your &svn-server; setting, you may need to update this +as well. + + + + + + + + + + +How &kdesrc-build; tries to ensure a successful build + + +Automatic rebuilds + +&kdesrc-build; used to include features to automatically attempt to +rebuild the module after a failure (as sometimes this re-attempt would work, +due to bugs in the build system at that time). Thanks to switching to &cmake; +the build system no longer suffers from these bugs, and so &kdesrc-build; will +not try to build a module more than once. There are situations where +&kdesrc-build; will automatically take action though: + + + +If you change configure-flags +or cmake-options for a module, then +&kdesrc-build; will detect that and automatically re-run configure or cmake +for that module. + +If the buildsystem does not exist (even if &kdesrc-build; did +not delete it) then &kdesrc-build; will automatically re-create it. This is +useful to allow for performing a full --refresh-build for a specific module +without having that performed on other modules. + + + + + + +Manually rebuilding a module +If you make a change to a module's option settings, or the module's +source code changes in a way &kdesrc-build; does not recognize, you may need to +manually rebuild the module. + +You can do this by simply running kdesrc-build + . + + +If you would like to have &kdesrc-build; automatically rebuild the module +during the next normal build update instead, you can create a special file. +Every module has a build directory. If you create a file called .refresh-me +in the build directory for a module, &kdesrc-build; will rebuild the module +next time the build process occurs, even if it would normally perform the +faster incremental build. + + +By default, the build directory is ~/kdesrc/build/module/. +If you change the setting of the &build-dir; option, then use that instead of +~/kdesrc/build. + + + +Rebuild using .refresh-me for module kdelibs: + +% touch ~/kdesrc/build/kdelibs/.refresh-me +% kdesrc-build + + + + + + + +Changing environment variable settings +Normally &kdesrc-build; uses the environment that is present when +starting up when running programs to perform updates and builds. This is useful +for when you are running &kdesrc-build; from the command line. + +However, you may want to change the setting for environment variables +that &kdesrc-build; does not provide an option for directly. (For instance, +to setup any required environment variables when running &kdesrc-build; on +a timer such as &cron;) This is possible with the &set-env; option. + +Unlike most options, it can be set more than once, and it accepts two +entries, separated by a space. The first one is the name of the environment +variable to set, and the remainder of the line is the value. + + +Set DISTRO=BSD +for all modules: + +global + set-env DISTRO BSD +end global + + + + + + +Resuming builds + + +Resuming a failed or canceled build + +You can tell &kdesrc-build; to start building from a different module +than it normally would. This can be useful when a set of modules failed, or +if you canceled a build run in the middle. You can control this using the +&cmd-resume-from; option and the &cmd-resume-after; option. + +Older versions of &kdesrc-build; would skip the source update when +resuming a build. This is no longer done by default, but you can always use +the command line option +to skip the source update. + + +Resuming the build starting from kdebase: + + +% kdesrc-build + + + + +Resuming the build starting after kdebase (in case you manually fixed +the issue and installed the module yourself): + + +% kdesrc-build + + + + + + +Ignoring modules in a build + +Similar to the way you can resume the +build from a module, you can instead choose to update and build everything +normally, but ignore a set of modules. + +You can do this using the &cmd-ignore-modules; option. This option tells +&kdesrc-build; to ignore all the modules on the command line when +performing the update and build. + + +Ignoring extragear/multimedia and kdereview during a full run: + +% kdesrc-build extragear/multimedia kdereview + + + + + + + +Changing options from the command line + + +Changing global options +You can change the setting of options read from the configuration file directly +from the command line. This change will override the configuration file +setting, but is only temporary. It only takes effect as long as it is still +present on the command line. + +&kdesrc-build; allows you to change options named like option-name +by passing an argument on the command line in the form . +&kdesrc-build; will recognize whether it does not know what the option is, and search +for the name in its list of option names. If it does not recognize the name, it +will warn you, otherwise it will remember the value you set it to and override +any setting from the configuration file. + + +Setting the &source-dir; option to /dev/null for +testing: + + +% kdesrc-build + + + + + + + +Changing module options +It is also possible to change options only for a specific module. The +syntax is similar: --module,option-name=value. + + +This change overrides any duplicate setting for the module found in the +configuration file, and applies only while the option is passed on the command line. + + +Using a different build directory for the kdeedu module: + + +% kdesrc-build + + + + + + + + + + + +Features for &kde; developers + + +&ssh; Agent checks +&kdesrc-build; can ensure that &kde; developers that use &ssh; to +access the &kde; source repository do not accidentally forget to leave the +&ssh; Agent tool enabled. This can cause &kdesrc-build; to hang indefinitely +waiting for the developer to type in their &ssh; password, +so by default &kdesrc-build; will check if the Agent is running before +performing source updates. + + +This is only done for &kde; developers using &ssh;. This is because +no password is required for the default anonymous checkout. &subversion; will +handle passwords for the second possible protocol for &kde; developers, https. + + +You may wish to disable the &ssh; Agent check, in case of situations where +&kdesrc-build; is mis-detecting the presence of an agent. To disable the +agent check, set the option to +true. + + +Disabling the &ssh; agent check: + +global + disable-agent-check true +end global + + + + + + + + +Other &kdesrc-build; features + + +Changing the amount of output from &kdesrc-build; +&kdesrc-build; has several options to control the amount of output the +script generates. In any case, errors will always be output. + + +The option (short form is +) causes &kdesrc-build; to be mostly silent. Only important +messages, warnings, or errors will be shown. When available, build progress +information is still shown. + +The option (no short form) +causes &kdesrc-build; to only display important warnings or errors while it is +running. + +The option (short form is +) causes &kdesrc-build; to be very detailed in its +output. + +The option is for debugging purposes +only, it causes &kdesrc-build; to act as if was +turned on, causes commands to also output to the terminal, and will display +debugging information for many functions. + + + + + +Color output +When being run from &konsole; or a different terminal, &kdesrc-build; +will normally display with colorized text. + +You can disable this by using the on the +command line, or by setting the &colorful-output; option in the configuration file to +false. + + + +Disabling color output in the configuration file: + +global + colorful-output false +end global + + + + + + +Removing unneeded directories after a build +Are you short on disk space but still want to run a bleeding-edge +&kde; checkout? &kdesrc-build; can help reduce your disk usage when building +&kde; from &subversion;. + +Be aware that building &kde; does take a lot of space. There are +several major space-using pieces when using &kdesrc-build;: + + +The actual source checkout can take up a fair amount of space. +The default modules take up about 1.6 gigabytes of on-disk space. You can reduce +this amount by making sure that you are only building as many modules as you +actually want. &kdesrc-build; will not delete source code from disk even if you +delete the entry from the configuration file, so make sure that you go and delete unused +source checkouts from the source directory. Note that the source files are +downloaded from the Internet, you should not delete them +if you are actually using them, at least until you are done using +&kdesrc-build;. + +Also, if you already have a &Qt; installed by your distribution (and +the odds are good that you do), you probably do not need to install the +qt-copy module. That will shave about 200 megabytes off of the on-disk source +size. + +One thing to note is that due to the way &subversion; works: there are actually +two files on disk for every file checked-out from the repository. &kdesrc-build; +does not have code at this point to try and minimize the source size when the +source is not being used. + + + + +&kdesrc-build; will create a separate build directory to build the source +code in. Sometimes &kdesrc-build; will have to copy a source directory to +create a fake build directory. When this happens, space-saving symlinks are +used, so this should not be a hassle on disk space. The build directory will +typically be much larger than the source directory for a module. For example, +the build directory for kdebase is about 1050 megabytes, whereas kdebase's +source is only around 550 megabytes. + +Luckily, the build directory is not required after a module has +successfully been built and installed. &kdesrc-build; can automatically +remove the build directory after installing a module, see the examples below +for more information. Note that taking this step will make it impossible +for &kdesrc-build; to perform the time-saving incremental builds. + + + +Finally, there is disk space required for the actual installation of +&kde;, which does not run from the build directory. This typically takes less +space than the build directory. It is harder to get exact figures however. + + + +How do you reduce the space requirements of &kde;? One way is to +use the proper compiler flags, to optimize for space reduction instead of +for speed. Another way, which can have a large effect, is to remove debugging +information from your &kde; build. + + + +You should be very sure you know what you are doing before deciding to remove +debugging information. Running bleeding-edge software means you are running +software which is potentially much more likely to crash than a stable release. +If you are running software without debugging information, it can be very +hard to create a good bug report to get your bug resolved, and you will likely +have to re-enable debugging information for the affected application and +rebuild to help a developer fix the crash. So, remove debugging information +at your own risk! + + + +Removing the build directory after installation of a module. The source +directory is still kept, and debugging is enabled: + + +global + configure-flags --enable-debug + remove-after-install builddir # Remove build directory after install +end global + + +Removing the build directory after installation, without debugging +information, with size optimization. + + +global + cxxflags -Os # Optimize for size + configure-flags --disable-debug + remove-after-install builddir # Remove build directory after install +end global + + + + + + + + + +&cmake;, the &kde; 4 build system + + +Introduction to &cmake; + +In March 2006, the &cmake; program +beat out several competitors and was selected to be the build system for &kde; 4, replacing the +autotools-based system that &kde; has used from the beginning. + +A introduction to &cmake; page is available on the &kde; TechBase. +Basically, instead of running make +Makefile.cvs, then configure, +then &make;, we simply run &cmake; and then &make;. + + +&kdesrc-build; has support for &cmake;. A few features of &kdesrc-build; +were really features of the underlying buildsystem, including +configure-flags +and do-not-compile. When equivalent +features are available, they are provided. For instance, the equivalent to the +configure-flags option is cmake-options, and the +do-not-compile option is also supported for &cmake; +as of &kdesrc-build; version 1.6.3. + + + + + + +Credits And Licenses + + +&underFDL; + + + +
diff -Nru kdesrc-build-1.13/doc/kdesrc-build.desktop kdesrc-build-1.14.1/doc/kdesrc-build.desktop --- kdesrc-build-1.13/doc/kdesrc-build.desktop 1970-01-01 00:00:00.000000000 +0000 +++ kdesrc-build-1.14.1/doc/kdesrc-build.desktop 2011-09-22 02:33:13.000000000 +0000 @@ -0,0 +1,70 @@ +# KDE Config File +[Desktop Entry] +X-DocPath=kdesrc-build/index.html +Name=KDE Source Builder +Name[ca]=Compilació del codi font del KDE +Name[ca@valencia]=Compilació del codi font del KDE +Name[cs]=KDE Source Builder +Name[da]=KDE Source Builder +Name[de]=KDE-Source-Builder +Name[el]=Κατασκευαστής πηγής του KDE +Name[en_GB]=KDE Source Builder +Name[es]=Constructor del código fuente de KDE +Name[et]=KDE lähtekoodi ehitaja +Name[fr]=Compilateur de sources KDE +Name[it]=Generazione del sorgente di KDE +Name[km]=កម្មវិធី​ស្ថាបនា​ប្រភព​​របស់​ KDE​ +Name[lt]=KDE kodo kompiliuoklis +Name[nb]=KDE kildebygger +Name[nds]=KDE-Bornkode-Buumoduul +Name[nl]=KDE Source Builder +Name[pa]=KDE ਸਰੋਤ ਬਿਲਡਰ +Name[pl]=Budowanie KDE ze źródeł +Name[pt]=Compilação do Código do KDE +Name[pt_BR]=Compilação do código do KDE +Name[ru]=Сборка KDE из исходного кода +Name[sr]=Градња КДЕ‑а из извора +Name[sr@ijekavian]=Градња КДЕ‑а из извора +Name[sr@ijekavianlatin]=Gradnja KDE‑a iz izvora +Name[sr@latin]=Gradnja KDE‑a iz izvora +Name[sv]=KDE-källkodsbyggare +Name[tr]=KDE Kaynak Oluşturucu +Name[uk]=Програма для збирання KDE з початкових кодів +Name[x-test]=xxKDE Source Builderxx +Name[zh_CN]=KDE 源代码构建器 +Name[zh_TW]=KDE Source Builder +Comment=Builds the KDE Platform and associated software from its source code. A command-line only program. +Comment[bs]=Gradi platformu KDE‑a i pridruženi softver iz izvornog koda. Program komandne linije. +Comment[ca]=Construeix la plataforma del KDE i el programari associat des del seu codi font. Un programa que només és per la línia d'ordres. +Comment[ca@valencia]=Construeix la plataforma del KDE i el programari associat des del seu codi font. Un programa que només és per la línia d'ordes. +Comment[cs]=Sestaví ze zdrojových kódů platformu KDE a přidružený software. Nástroj pouze pro příkazovou řádku. +Comment[da]=Bygger KDE Platform og tilknyttet software fra kildekode. Et program kun til kommandolinjen. +Comment[de]=Erstellt KDE und dazugehörige Software aus den Quelltexten. Es ist ein reines Befehlszeilenprogramm. +Comment[el]=Δημιουργεί την πλατφόρμα του KDE και το αντίστοιχο λογισμικό από τον πηγαίο κώδικα. Ένα πρόγραμμα μόνο γραμμής εντολών. +Comment[en_GB]=Builds the KDE Platform and associated software from its source code. A command-line only program. +Comment[es]=Construye la Plataforma KDE y el software asociado desde su código fuente. Un programa sólo para la línea de órdenes. +Comment[et]=KDE platvormi ja sellega seotud tarkvara ehitamine lähtekoodist. Ainult käsureal kasutatav programm. +Comment[fr]=Construit la plate-forme KDE et les logiciels associés depuis son code source. Un programme en ligne de commande seule. +Comment[it]=Genera la piattaforma di KDE e il software ad essa associato dal codice sorgente. Un programma disponibile solo dalla riga di comando. +Comment[km]=ស្ថាបនា​កម្មវិធី​របស់​ KDE និង​កម្មវិធី​​ដែល​ភ្ជាប់​​ពី​កូដ​ប្រភព​របស់​វា​​ ។​ កម្មវិធី​បន្ទាត់​ពាក្យ​បញ្ជា​តែ​​​ប៉ុណ្ណោះ​ ។​ +Comment[lt]=Kompiliuoja KDE platformą ir susijusią programinę įrangą iš išeities kodo. Tik komandinės eilutės programa. +Comment[nb]=Bygger KDE-plattformen og tilordnede programmer fra kildekoden. Dette er et program med bare kommandolinje. +Comment[nds]=Buut de KDE-Systemümgeven un tohören Programmen ut den Bornkode. Bloots en Konsoolprogramm. +Comment[nl]=Bouwt het KDE-platform en geassocieerde software uit zijn broncode. Werkt alleen op de opdrachtregel. +Comment[pl]=Budowanie Środowiska KDE i związanego z nim oprogramowania z kodu źródłowego. Program działa tylko w linii poleceń. +Comment[pt]=Compila a Plataforma do KDE e os programas associados a partir do seu código-fonte. Um programa apenas para a linha de comandos. +Comment[pt_BR]=Compila a Plataforma do KDE e os programas associados a partir do seu código-fonte. Um programa apenas para a linha de comandos. +Comment[ru]=Собирает платформу KDE и основанное на ней программное обеспечение из исходного кода. Программа предназначена только для запуска из командной строки. +Comment[sr]=Гради платформу КДЕ‑а и придружени софтвер из изворног кода. Програм командне линије. +Comment[sr@ijekavian]=Гради платформу КДЕ‑а и придружени софтвер из изворног кода. Програм командне линије. +Comment[sr@ijekavianlatin]=Gradi platformu KDE‑a i pridruženi softver iz izvornog koda. Program komandne linije. +Comment[sr@latin]=Gradi platformu KDE‑a i pridruženi softver iz izvornog koda. Program komandne linije. +Comment[sv]=Bygger KDE-plattformen och tillhörande programvara från dess källkod. Ett program som bara använder kommandoraden. +Comment[uk]=Збирає Платформу KDE і пов’язане з нею програмне забезпечення з початкових кодів. Керується за допомогою командного рядка. +Comment[x-test]=xxBuilds the KDE Platform and associated software from its source code. A command-line only program.xx +Comment[zh_CN]=从源代码构建 KDE 平台和相关软件。纯命令行程序。 +Comment[zh_TW]=從源碼建立 KDE 平台與相關軟體。是一個只有命令列的程式。 +Categories=Qt;KDE;Development; +Exec=kdialog --sorry "kdesrc-build is a command-line only program. Please read the handbook at help:/kdesrc-build for more information." +Terminal=true +NoDisplay=true diff -Nru kdesrc-build-1.13/doc/man-kdesrc-build.1.docbook kdesrc-build-1.14.1/doc/man-kdesrc-build.1.docbook --- kdesrc-build-1.13/doc/man-kdesrc-build.1.docbook 1970-01-01 00:00:00.000000000 +0000 +++ kdesrc-build-1.14.1/doc/man-kdesrc-build.1.docbook 2011-09-22 02:33:13.000000000 +0000 @@ -0,0 +1,962 @@ + + +]> + + + + + +&kde; User's Manual + + MichaelPyne + mpyne@kde.org + +2011-09-21 + + + +kdesrc-build +1 +1.14.1 + + + + kdesrc-build + Downloads, builds and installs &kde; software. + + + + +kdesrc-build +OPTIONS +Module name | Module set name + + + + +DESCRIPTION + +The kdesrc-build command is used in order to build +&kde; software directly from its source repositories. It can download from +Subversion or Git repositories, interfaces with the &kde; project database, and +supports controlling which options are passed to make(1) and +cmake(1). The operation of kdesrc-build +is driven by a configuration file, typically +~/.kdesrc-buildrc. + +The module name or module set +name as given on the command line should be as those names were +defined in the configuration file (either in a module +definition or declaration, or in a + definition). In addition, it can be the name of a +&kde; module listed in the &kde; project database (and you can precede the +module name with + to force this). + +kdesrc-build is designed to be able to be completely +headless (however, see ENVIRONMENT), and so +typically ignores its input completely. Command output is logged instead of +being shown on the kdesrc-build output. + +Modules are built one after the other. If a module fails to update then +it is not built. kdesrc-build will not abort just because of +a module failure, instead it will keep trying to update and build subsequent +modules. By default, kdesrc-build will commence building a +module as soon as the source code update is complete for that module, even if +other updates are occurring concurrently. + +At the end kdesrc-build will show which modules failed +to build, and where the logs were kept for that build run. + + +OPTIONS + +NOTE: Some options have short forms, +but the kdesrc-build option parser does not support +combining short options into one at this point. (E.g. running + would not be the same as +). + + + + + + + + + + + Shows a brief synopsis and frequently-used command line options. + + + + + + + + + + + + Operate in a "dry run" mode. No network accesses are made, no log files are + created, no modules are built, and no other permanent changes to disk are + made. One important exception is that if you try to + build a module that comes from the &kde; project database, and the + database hasn't been downloaded yet, the database will be downloaded + since the pretend-mode output may change significantly based on the + database results. + + + + + + + + + + + + Skips the update and build phase and immediately attempts to install the + modules given. + + + + + + + + + + + + Skips the update and build phase and immediately attempts to uninstall the + modules given. NOTE: This is only + supported for buildsystems that supports the make + uninstall command (e.g. &kde; CMake-based). + + + + + + + + + + + + Skips the source update phase. Other phases are included as normal. + is a deprecated alias for this option and will be + removed in a future release. + + + + + + + + + + + + Skips the install phase from the build. Other phases are included as + normal. + + + + + + + + + + + + Skips the build phase for the build. Internally the install phase depends + on the build phase completing so this is effectively equivalent to + , but the semantics may change in the future + (e.g. when test suites are moved into their own phase). + + + + + + + + + + + + Disables running the test suite for CMake-based modules. To be fully + effective this requires re-running CMake, which can be forced by using the + or options. + + + + + + + + + + + + Only performs the source update phase, does not build or install. + is a deprecated alias for this option and will + be removed in a future release. + + + + + + + + + + + + Forces the build process to be performed without updating source code + first. In addition, installation is not performed. (Testing is still + performed if applicable, but this will change in a future release) + + + + + + + + + + + + Removes the build directory for a module before the build phase starts. + This has the desired side effect of forcing kdesrc-build to re-configure + the module and build it from a "pristine" state with no existing temporary + or intermediate output files. Use this option if you have problems getting + a module to build but realize it will take longer (possibly much longer) + for the build to complete as a result. When in doubt use this option for + the entire kdesrc-build run. + + + + + + + + + + + + Force CMake to be re-run, but without deleting the build directory. + Usually you actually want , but if you are + 100% sure your change to will not + invalidate your current intermediate output then this can save some time. + + + + + + + + + + + + Interrupts the build process for each module built: The build process + consists of normal setup up to and including running + cmake or configure (as appropriate), + but make is not run and no installation + is attempted. This is mostly only useful to get things like + configure --help and cmake-gui to + work. Normally you want or + . + + + + + + + + + + + + Use this option to skip module processing until the module + foo is encountered. + foo and all subsequent modules will be processed + normally as if they had been specified on the command line. If you use this + option because of a build failure you may want to consider using + in addition to skip the resultant source update + phase. + + + + + + + + + + + + This is just like , except that the module + foo is not included in the + list of modules to consider. You might use this if you've manually + built/installed foo after fixing the build and just want to resume from + there. + + + + + + + + + + + + Forces ALL modules that follow this + option to be excluded from consideration by + kdesrc-build. This might be useful if you know you want + to process all modules except for specific exceptions. + + + + + + + + + + + + Use the given file, foo, for the configuration + instead of ~/.kdesrc-buildrc or + ./kdesrc-buildrc. The file can be empty, but must + exist. + + + + + + + + + + + + Overrides the setting to be + foo for this run. In addition, implies + . It does not actually + perform the action you would think it does (overriding the + option to change where modules are installed), + although by default modules are installed to the + setting if is not set. + + + + + + + + + + + + Changes the CPU priority given to kdesrc-build (and all + processes used by kdesrc-build e.g. + make(1)). foo should be an + integer number between -20 and 19. Positive values are "nicer" to the rest + of the system (i.e. lower priority). + + + + Note that the possible priorities available on your system may be different + than listed here, see nice(2) for more information. Note + also that this only changes CPU priority, often you + want to change I/O priority on systems where that is + supported. There is no command-line option for I/O priority adjustment, but + there is a configuration file option: + (although like all options, there is a generic way to set this from the + command line). + + + + + + + + + + + + Runs the program named by foo using + kdesrc-build's normal build environment. All command + line arguments present after this option are passed to + foo as it is run. + + + + + + + + + + + + Enables "colorful output". (Enabled by default). + + + + + + + + + + + + Disables "colorful output". This can be made permanent by setting the + option to false (or 0) in your + configuration file. + + + + + + + + + + + + Have kdesrc-build start the build process for a module + as soon as the source code has finished downloading. Without this option + kdesrc-build performs all source updates at once and + only then starts with the build process. This option is enabled by default. + + + + + + + + + + + + Disables asynchronous building of modules. See for + a more detailed description. Note that kdesrc-build's + output will be slightly different in this mode. + + + + + + + + + + + + Increases the level of verbosity of kdesrc-build output + (which is already fairly verbose!) + + + + + + + + + + + + Makes kdesrc-build less noisy. Only important messages + are shown. + + + + + + + + + + + + Makes kdesrc-build even less noisy. Only warnings/errors + are shown. + + + + + + + + + + + + This will fill your terminal with descriptions and debugging output, + usually unintelligible, describing what kdesrc-build is + doing (and thinks it should be doing). The flag is included since the + output may sometimes prove useful for debugging. + + + + + + + + + + + + Normally when kdesrc-build notices that there is no + source update on a module which was previously successfully installed, it + does not attempt to build or install that module. You can pass this flag to + disable that behavior and always run make. + + + + + + + + + + + + Normally kdesrc-build supports using source repository + tarball snapshots to reduce load on &kde; infrastructure for git clones for + some &kde; modules. Passing this option disables this feature. + + + + + + + + + + + + This option must be passed to allow kdesrc-build to + remove conflicting source directories. Currently even this only happens + when trying to clone a git-based module if an existing source directory is + present. Never specify this option unless it is suggested by + kdesrc-build, and only if you don't mind the source + directories that are referenced being deleted and re-cloned. + + + + + + + + + + + + Any option not listed above is checked to see if it matches the list of + possible configuration file options. If so, the configuration file option + is temporarily set to for the + duration of this run. + + + + + + + + + + + + Like above, but option is only set to + for the module . This does not + work for module sets yet, you must repeat this for each module you want to + be affected. (Of course, you could simply edit your configuration file...) + + + + + + + + +EXIT STATUS + + + + + +0 + + + + + Success + + + + + + +1 + + + + + Normally this means some part of the update, build or install process + failed, but is also used for any abnormal program end not otherwise covered + below. + + + + + + +5 + + + + + A signal was received that killed kdesrc-build, but it + attempted to perform normal closedown. + + + + + + +8 + + + + + Unknown option was passed on the command line. + + + + + + +99 + + + + + An exception was raised that forced kdesrc-build to + abort early. + + + + + + + + +ENVIRONMENT + + + + + +HOME + + + + + Used for tilde-expansion of file names, and is the default base for the + source, build, and installation directories. + + + + + + +PATH + + + + + This environment variable controls the default search path for executables. + You can use the configuration file option to add + to this variable (e.g. for running from cron(8)). + + + + + + +LC_* + + + + + Environment variables starting with LC_ control the locale used by + kdesrc-build. Although kdesrc-build + is still not localizable at this point, many of the commands it uses are. + kdesrc-build normally sets LC_ALL=C for + commands that its must examine the output of but you can manually do this + as well. If setting LC_ALL=C fixes a + kdesrc-build problem please submit a bug report. + + + + + + +SSH_AGENT_PID + + + + + This environment variable is checked to see if + ssh-agent(1) is running, but only if + kdesrc-build determines that you are checking out a + module that requires an SSH login (but you should know this as no module + requires this by default). + + + + + + +KDESRC_BUILD_USE_TTY + + + + + If set, this variable forces kdesrc-build not to close + its input while executing system processes. Normally + kdesrc-build closes stdin since the + stdout and stderr for its child processes + are redirected and therefore the user would never see an input prompt + anyways. + + + + + + +KDESRC_BUILD_DUMP_CONTEXT + + + + + If set, this variable prints out a description of its "build context" just + after reading options and command line arguments and determining which + modules to build. You pretty much never want to set this. + + + + + + +others + + + + + Many programs are used by kdesrc-build in the course of + its execution, including svn(1), + git(1), make(1), and + cmake(1). Each of these programs may have their own + response to environment variables being set. + kdesrc-build will pass environment variables that are + set when it is run onto these processes. You can ensure certain environment + variables (e.g. CC or CXX) are set by using + the configuration file option. + + + + + + + + +FILES + +~/.kdesrc-buildrc - Default global configuration +file. + +./kdesrc-buildrc - If this file (note there is no +leading period (.) this time) is found in the current +directory when kdesrc-build is run, this file will be used for the +configuration instead of ~/.kdesrc-buildrc. + +~/.kdesrc-build-data - +kdesrc-build uses this file to store persistent data (such +as last CMake options used, last revision successfully installed, etc.). It can +be safely deleted. + + + + +BUGS + +See http://bugs.kde.org/. Be +sure to search against the kdesrc-build product. + + + + +EXAMPLE + + + + + +$ kdesrc-build + + + + + Downloads, builds and installs all modules listed in the configuration + file, in the order defined therein. + + + + + + +$ kdesrc-build + + + + + Same as above, except no permanent actions are taken (specifically no log + files are created, downloads performed, build processes run, etc.). + EXCEPTION: If you are trying to build a + module defined in the &kde; project database, and the database has not been + downloaded yet, kdesrc-build will download the database + since this can significantly affect the final build order. + + + + + + +$ kdesrc-build kdebase + + + + + Deletes the build directory for the kdebase module set + () and then starts the build process again + without updating the source code in-between. + + + + + + +$ kdesrc-build /dev/null + + + + + Forces kdesrc-build to read an empty configuration file + and simulate the resultant build process. This shows what would happen by + default with no configuration file, without an error message about a + missing configuration file. + + + + + + +$ kdesrc-build +kdebase/kde-baseapps + + + + + Downloads, builds and installs the kde-baseapps module + from the &kde; project database. Since the module name is preceded by a + + it is assumed to defined in the &kde; project + database even if this hasn't been specifically configured in the + configuration file. + + + The kdebase/ portion forces + kdesrc-build to ignore any kde-baseapps + modules that are not children of the kdebase supermodule + in the project database (although it is contrived for this example). + + + + + + +$ kdesrc-build + + + + + Downloads, builds and installs all modules defined in the configuration + file but overrides the cmake-options option to have + the value given on the command line for this run only. Any further + kdesrc-build runs will use the + cmake-options given in the configuration file. + + + + + + + + +SEE ALSO + +build-tool - A program by Michael Jansen which can build &kde; software +based on included recipes. + + + + +RESOURCES + +Main web site: http://kdesrc-build.kde.org/ + +Documentation: http://kdesrc-build.kde.org/documentation/ + +Setup script: kdesrc-build-setup + + + + +COPYING + +Copyright (C) 2003-2011 Michael Pyne. + +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 (at your option) any +later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., 51 +Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + + + diff -Nru kdesrc-build-1.13/doc/man-kdesrc-build-setup.1.docbook kdesrc-build-1.14.1/doc/man-kdesrc-build-setup.1.docbook --- kdesrc-build-1.13/doc/man-kdesrc-build-setup.1.docbook 1970-01-01 00:00:00.000000000 +0000 +++ kdesrc-build-1.14.1/doc/man-kdesrc-build-setup.1.docbook 2011-09-22 02:33:13.000000000 +0000 @@ -0,0 +1,199 @@ + + +]> + + + + + +&kde; User's Manual + + MichaelPyne + mpyne@kde.org + +2011-09-10 + + + +kdesrc-build-setup +1 +0.01 + + + + kdesrc-build-setup + Creates a ~/.kdesrc-buildrc configuration + file for kdesrc-build(1). + + + + +kdesrc-build-setup + + + + +DESCRIPTION + +The kdesrc-build-setup command is used to generate +a simple configuration file for kdesrc-build(1). + +It requires the dialog(1) script be available, and +Perl (just like kdesrc-build). + +No command line options are accepted. The operation of the program is +instead driven through dialog-style prompts to gather the data required to +generate the configuration file. The configuration file can be saved to a +location other than ~/.kdesrc-buildrc. + + + + +OPTIONS + +No command line options are supported for this command. + + + + +EXIT STATUS + + + + + +0 + + + + + Success + + + + + + +Anything else + + + + + Either there was an I/O failure of some type (invalid permissions, disk + full, etc.), or the user canceled the program by pressing + ESC during a dialog. + + + + + + + + +ENVIRONMENT + + + + + +HOME + + + + + Used for tilde-expansion of file names, and is the default base for the + source, build, and installation directories. + + + + + + + dialog(1) + + + + + The dialog(1) program is required for the operation of + this script and may obey environment variables of its own. + + + + + + + + +FILES + +~/.kdesrc-buildrc - Default global configuration +file, generated by default by this script. If the file already exists, the +existing file is moved to ~/.kdesrc-buildrc~ as a backup +before generating the configuration. + +The file generated by this script can be saved to a different name +instead. + + + + +BUGS + +See http://bugs.kde.org/. Be +sure to search against the kdesrc-build product. + + + + +SEE ALSO + +kdesrc-build(1) + +kdesrc-buildrc-sample file (if included with your +kdesrc-build distribution). + + + + +RESOURCES + +Main web site: http://kdesrc-build.kde.org/ + +Documentation: http://kdesrc-build.kde.org/documentation/ + + + + +COPYING + +Copyright (C) 2011 Michael Pyne. + +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 (at your option) any +later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., 51 +Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + + + diff -Nru kdesrc-build-1.13/kdesrc-build kdesrc-build-1.14.1/kdesrc-build --- kdesrc-build-1.13/kdesrc-build 2011-02-28 03:05:38.000000000 +0000 +++ kdesrc-build-1.14.1/kdesrc-build 2011-09-22 02:33:13.000000000 +0000 @@ -4,16 +4,34 @@ # stored in the file ~/.kdesrc-buildrc. # # Please also see the documentation that should be included with this program, -# from the kdesdk/doc/scripts/kdesrc-build directory. +# in the doc/ directory. # # Copyright © 2003 - 2011 Michael Pyne. # Home page: http://kdesrc-build.kde.org/ # -# You may use, alter, and redistribute this software under the terms -# of the GNU General Public License, v2 (or any later version). - -# Pod documentation: Removed in favor of --help and the index.docbook in the -# kdesdk/doc/scripts/kdesrc-build directory. +# Copyright © 2005, 2006, 2008 - 2011 David Faure +# Copyright © 2005 Thiago Macieira +# Copyright © 2006 Stephan Kulow +# Copyright © 2006, 2008 Dirk Mueller +# ... and possibly others. Check the git source repository for specifics. +# +# 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 (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +# Force all symbols to be in this package. We can tell if we're being called +# through require/eval/etc. by using the "caller" function. +package main; use strict; use warnings; @@ -21,35 +39,51 @@ use Carp; use POSIX qw(strftime :sys_wait_h); use File::Find; # For our lndir reimplementation. -use File::Basename; -use File::Spec; +use File::Path qw(make_path remove_tree); use File::Glob ':glob'; +use File::Basename; # fileparse +use LWP::UserAgent; +use URI; # For git-clone snapshot support use Sys::Hostname; use Storable 'dclone'; use IO::Handle; -use IO::File; use IPC::Open3; use Errno qw(:POSIX); use Data::Dumper; -use 5.008_000; # Require Perl 5.8.0 +use 5.010_000; # Require Perl 5.10.0 -# Debugging level constants. -use constant { - DEBUG => 0, - WHISPER => 1, - INFO => 2, - NOTE => 3, - WARNING => 4, - ERROR => 5, -}; +# global variables {{{1 use constant { # We use a named remote to make some git commands work that don't accept the # full path. - GIT_REMOTE_ALIAS => '__kdesvn-build-remote', # Historical name + GIT_REMOTE_ALIAS => 'origin', KDE_PROJECT_ID => 'kde-projects', # git-repository-base for kde_projects.xml }; +my $versionNum = '1.14.1'; + +# This hash is used to store environment variables to be used on the next +# execution of log_command(). This is done so that we don't have to fork new +# processes just to change values in the environment. +# +# Previously we simply saved %ENV in a temp hash, but that broke on some systems. +# Then we used 'local %ENV' to push/pop the environment from a stack but it only +# really worked on the developer's system. :( +# +# Now we save environment variables to set right after forking... +# +# Don't use this except via setenv(), resetenv(), and log_command(). +our %ENV_VARS; + +# This is a hash since Perl doesn't have a "in" keyword. +my %ignore_list; # List of packages to refuse to include in the build list. + +my $run_mode = 'build'; # Determines if updating, building, installing, etc. + +# }}} + +# package IPC {{{ { # Separate package for namespacing. package IPC; @@ -69,83 +103,303 @@ MODULE_CONFLICT => 8, }; } +# }}} -my $versionNum = '1.13'; +# package ksb::Debug {{{ +{ + package ksb::Debug; -# Some global variables -# Remember kids, global variables are evil! I only get to do this -# because I'm an adult and you're not! :-P -# Options that start with a # will replace values with the same name, -# if the option is actually set. -our %package_opts = ( - 'global' => { - "async" => 1, - "binpath" => '', - "build-when-unchanged"=> 1, # Safe default - "branch" => "", - "build-dir" => "build", - "build-system-only" => "", - "checkout-only" => "", - "cmake-options" => "", - "configure-flags" => "", - "colorful-output" => 1, # Use color by default. - "cxxflags" => "-pipe", - "debug" => "", - "debug-level" => INFO, - "dest-dir" => '${MODULE}', # single quotes used on purpose! - "disable-agent-check" => 0, # If true we don't check on ssh-agent - "disable-snapshot" => 0, # If true, don't check for module snapshots. - "do-not-compile" => "", - "email-address" => "", - "email-on-compile-error" => "", - "git-repository-base" => {}, # Base path template for use multiple times. - "use-modules" => "", - "install-after-build" => 1, # Default to true - "kdedir" => "$ENV{HOME}/kde", - "kde-languages" => "", - "libpath" => "", - "log-dir" => "log", - "make-install-prefix" => "", # Some people need sudo - "make-options" => "-j2", - "manual-build" => "", - "manual-update" => "", - "module-base-path" => "", # Used for tags and branches - "niceness" => "10", - "no-svn" => "", - "override-url" => "", - "prefix" => "", # Override installation prefix. - "pretend" => "", - "purge-old-logs" => 0, - "qtdir" => "$ENV{HOME}/kdesrc/build/qt-copy", - "reconfigure" => "", - "refresh-build" => "", - "remove-after-install"=> "none", # { none, builddir, all } - "repository" => '', # module's git repo - "revision" => 0, - "run-tests" => 0, # 1 = make test, upload = make Experimental - "set-env" => { }, # Hash of environment vars to set - "source-dir" => "$ENV{HOME}/kdesrc", - "stop-on-failure" => "", - "svn-server" => "svn://anonsvn.kde.org/home/kde", - "tag" => "", - "use-clean-install" => 0, - "use-idle-io-priority"=> 0, - } -); + # Debugging level constants. + use constant { + DEBUG => 0, + WHISPER => 1, + INFO => 2, + NOTE => 3, + WARNING => 4, + ERROR => 5, + }; -# This hash is used to store environment variables to be used on the next -# execution of log_command(). This is done so that we don't have to fork new -# processes just to change values in the environment. -# -# Previously we simply saved %ENV in a temp hash, but that broke on some systems. -# Then we used 'local %ENV' to push/pop the environment from a stack but it only -# really worked on the developer's system. :( -# -# Now we save environment variables to set right after forking... -# -# Don't use this except via setenv(), resetenv(), and log_command(). -our %ENV_VARS; + my $screenLog; # Filehandle pointing to the "build log". + my $isPretending = 0; + my $debugLevel = INFO; + + # Colors + my ($RED, $GREEN, $YELLOW, $NORMAL, $BOLD) = ("") x 5; + + # Subroutine definitions + + sub import + { + my $pkg = shift; + my $caller = caller; + my @exports = qw(debug pretending debugging whisper + note info warning error pretend clr); + + # This loop is only slightly "magical". Basically to import functions + # into a different package in Perl, we can use something like: + # *PACKAGE::FUNCTION = \&SOURCE_PACKAGE::FUNCTION; + # where the *PACKAGE modifies the symbol table for that package. + # + # The extra part, which requires using eval, is to predeclare the + # subroutine with a prototype first. + # "sub foo($old_prototype);" + + for my $fn (@exports) { + my $prototype = prototype($fn); + eval "sub ${caller}::${fn}(${prototype});\n" . + "*${caller}::${fn} = \\&${pkg}::${fn};"; + } + } + + # I'm lazy and would rather write in shorthand for the colors. This sub + # allows me to do so. + sub clr($) + { + my $str = shift; + + $str =~ s/g\[/$GREEN/g; + $str =~ s/]/$NORMAL/g; + $str =~ s/y\[/$YELLOW/g; + $str =~ s/r\[/$RED/g; + $str =~ s/b\[/$BOLD/g; + + return $str; + } + + # Subroutine which returns true if pretend mode is on. Uses the prototype + # feature so you don't need the parentheses to use it. + sub pretending() + { + return $isPretending; + } + + sub setPretending + { + $isPretending = shift; + } + + sub setColorfulOutput + { + # No colors unless output to a tty. + return unless -t STDOUT; + + my $useColor = shift; + + if ($useColor) { + $RED = "\e[31m"; + $GREEN = "\e[32m"; + $YELLOW = "\e[33m"; + $NORMAL = "\e[0m"; + $BOLD = "\e[1m"; + } + else { + ($RED, $GREEN, $YELLOW, $NORMAL, $BOLD) = ("") x 5; + } + } + + # Subroutine which returns true if debug mode is on. Uses the prototype + # feature so you don't need the parentheses to use it. + sub debugging() + { + return $debugLevel <= DEBUG; + } + + sub setDebugLevel + { + $debugLevel = shift; + } + + sub setLogFile + { + my $fileName = shift; + + return if pretending(); + open ($screenLog, '>', $fileName) or error ("Unable to open log file $fileName!"); + } + + # The next few subroutines are used to print output at different importance + # levels to allow for e.g. quiet switches, or verbose switches. The levels are, + # from least to most important: + # debug, whisper, info (default), note (quiet), warning (very-quiet), and error. + # + # You can also use the pretend output subroutine, which is emitted if, and only + # if pretend mode is enabled. + # + # clr is automatically run on the input for all of those functions. + # Also, the terminal color is automatically reset to normal as well so you don't + # need to manually add the ] to reset. + + # Subroutine used to actually display the data, calls clr on each entry first. + sub print_clr(@) + { + print clr($_) foreach (@_); + print clr("]\n"); + + if (defined $screenLog) { + my @savedColors = ($RED, $GREEN, $YELLOW, $NORMAL, $BOLD); + # Remove color but still extract codes + ($RED, $GREEN, $YELLOW, $NORMAL, $BOLD) = ("") x 5; + + print ($screenLog clr($_)) foreach (@_); + print ($screenLog "\n"); + + ($RED, $GREEN, $YELLOW, $NORMAL, $BOLD) = @savedColors; + } + } + + sub debug(@) + { + print_clr(@_) if debugging; + } + + sub whisper(@) + { + print_clr(@_) if $debugLevel <= WHISPER; + } + + sub info(@) + { + print_clr(@_) if $debugLevel <= INFO; + } + + sub note(@) + { + print_clr(@_) if $debugLevel <= NOTE; + } + + sub warning(@) + { + print_clr(@_) if $debugLevel <= WARNING; + } + + sub error(@) + { + print STDERR (clr $_) foreach (@_); + print STDERR (clr "]\n"); + } + + sub pretend(@) + { + print_clr(@_) if pretending; + } + + 1; +} + +# }}} + +# package ksb::Util {{{ +{ + package ksb::Util; + + use Carp; + use Scalar::Util qw(blessed); + + sub import + { + my $pkg = shift; + my $caller = caller; + my @exports = qw(list_has make_exception assert_isa assert_in); + + # This loop is only slightly "magical". Basically to import functions + # into a different package in Perl, we can use something like: + # *PACKAGE::FUNCTION = \&SOURCE_PACKAGE::FUNCTION; + # where the *PACKAGE modifies the symbol table for that package. + # + # The extra part, which requires using eval, is to predeclare the + # subroutine with a prototype first. + # "sub foo($old_prototype);" + + for my $fn (@exports) { + my $prototype = prototype($fn); + if ($prototype) { + eval "sub ${caller}::${fn}(${prototype});\n" . + "*${caller}::${fn} = \\&${pkg}::${fn};"; + } + else { + eval "*${caller}::${fn} = \\&${pkg}::${fn};"; + } + } + } + + # Function to work around a Perl language limitation. + # First parameter is the list to search. + # Second parameter is the value to search for. + # Returns true if the value is in the list + sub list_has(\@$) + { + my $value = pop; + # Expand list references if present, otherwise use all params. + my @list = scalar @_ == 1 ? @{$_[0]} : @_; + return scalar grep { "$_" eq "$value" } (@list); + } + + # Returns a Perl object worth "die"ing for. (i.e. can be given to the die + # function and handled appropriately later with an eval). The returned + # reference will be an instance of BuildException. The actual exception + # type is passed in as the first parameter (as a string), and can be + # retrieved from the object later using the 'exception_type' key, and the + # message is returned as 'message' + # + # First parameter: Exception type. Recommended are one of: Config, Internal + # (for logic errors), Runtime (other runtime errors which are not logic + # bugs in kdesrc-build), or just leave blank for 'Exception'. + # Second parameter: Message to show to user + # Return: Reference to the exception object suitable for giving to "die" + sub make_exception + { + my $exception_type = shift // 'Exception'; + my $message = shift; + + return bless({ + 'exception_type' => $exception_type, + 'message' => $message + }, 'BuildException'); + } + # Used in the assert methods + sub fail_assertion + { + # Carp doesn't support exception objects, so raise the error + # message and grab the string for the stack trace, then re-raise + # inside the object. + local $Carp::CarpLevel = 2; # Skip this upcoming eval and this method. + eval { confess ($_[0]) }; + die(make_exception('Internal', $@)); + } + + # Throws an exception if the first parameter is not an object at all, or if + # it is not an object of the type given by the second parameter (which + # should be a string of the class name. There is no return value; + sub assert_isa + { + my ($obj, $class) = @_; + + if (!blessed($obj) || !$obj->isa($class)) { + fail_assertion("$obj is not of type $class"); + } + + return $obj; + } + + # Throws an exception if the first parameter is not included in the + # provided list of possible alternatives. + sub assert_in($@) + { + my ($val, $listRef) = @_; + + if (!list_has(@{$listRef}, $val)) { + fail_assertion("$val is not a permissible value for its argument"); + } + + return $val; + } + + 1; +} +# }}} + +# package BaseIPC {{{ # Base class for IPC interaction. Should have most of the functionality, with # the actual bits of reading and writing left to subclasses. { @@ -268,7 +522,9 @@ return 0; } } +# }}} +# package PipeIPC {{{ # IPC class that uses pipes for communication. Basically requires # forking two children in order to communicate with. Assumes that the two # children are the update process and a monitor process which keeps the update @@ -400,7 +656,9 @@ return $self->receiveMessage('fromSvn'); } } +# }}} +# package NullIPC {{{ # Dummy IPC module in case SysVIPC doesn't work. { package NullIPC; @@ -434,7 +692,9 @@ return shift @{$self->{'msgList'}}; } } +# }}} +# package KDEXMLReader {{{ # kde_projects.xml module-handling code. # The core of this was graciously contributed by Allen Winter, and then # touched-up and kdesrc-build'ed by myself -mpyne. @@ -462,7 +722,7 @@ # extragear/utils/kdesrc-build @xmlGroupingIds{qw/component module project/} = 1; - my ($class, $proj) = @_; + my ($class, $proj, $srcdir) = @_; $searchProject = $proj; @modules = (); @@ -480,7 +740,6 @@ }, ); - my $srcdir = main::get_source_dir(); my $result = $parser->parsefile("$srcdir/kde_projects.xml"); return @modules; } @@ -513,7 +772,12 @@ $trackingReposFlag = 1; for (my $i = 0; $i < scalar @searchParts; ++$i) { - $trackingReposFlag &&= $searchParts[$i] eq $candidateArray[$i]; + if (($searchParts[$i] ne $candidateArray[$i]) && + ($searchParts[$i] ne '*')) + { + $trackingReposFlag = 0; + last; + } } # Reset our found flag if we're looking for another repo @@ -539,7 +803,8 @@ 'repo' => '', 'name' => $nameStack[-1], 'active' => 'false', - }; # Repo/Active to be added by char handler. + 'tarball' => '', + }; # Repo/Active/tarball to be added by char handler. } # Character data is integrated by the char handler. To avoid having it dump @@ -552,6 +817,10 @@ if ($element eq 'url' && $inRepo && $attrs{'protocol'} eq 'git') { $curRepository->{'needs'} = 'repo'; } + + if ($element eq 'url' && $inRepo && $attrs{'protocol'} eq 'tarball') { + $curRepository->{'needs'} = 'tarball'; + } } sub xmlTagEnd @@ -584,1421 +853,1500 @@ 1; } +# }}} +# package ksb::Phases {{{ { - package Module; - - use Scalar::Util qw(blessed); - - my $ModulePhases = [qw/update build test install/]; - my $ModuleSource = 'config'; - my @ModuleList; # List of modules + # Handles the "phases" for kdesrc-build, e.g. a simple list of phases, + # and methods to add, clear, or filter out phases. + package ksb::Phases; - # Alias the main package's debug to our package. - *debug = \&main::debug; + ksb::Util->import(); + # Constructor. Passed in values are the initial phases in this set. sub new { - my ($class, $name, $type) = @_; - die "Empty Module constructed" unless $name; + my ($class, @args) = @_; + return bless [@args], $class; + } - my $module = { - name => $name, - type => $type || 'null', - # Weird [@$foo] forces a copy of underlying list. - phases => [@$ModulePhases], - 'module-set' => '', - }; + # Filters out the given phase from the current list of phases. + sub filterOutPhase + { + my ($self, $phase) = @_; + @{$self} = grep { $_ ne $phase } @{$self}; + } - return bless $module, $class; + # Adds the requested phase to the list of phases to build. + sub addPhase + { + my ($self, $phase) = @_; + push @{$self}, $phase unless list_has([@{$self}], $phase); } - sub push + # Get/sets number of phases depending on whether any are passed in. + sub phases { - my ($self, $module) = @_; - Carp::confess("No module to push") unless $module; + my ($self, @args) = @_; + @$self = @args if scalar @args; + return @$self; + } - if (grep ($_->{name} eq $module->{name}, @ModuleList)) { - debug( "Skipping duplicate module $module->{name}"); - } - else { - debug("Adding $module->{name} to module list"); - push @ModuleList, $module; - } + sub clear + { + my $self = shift; + splice @$self; } - sub phases + 1; +} +# }}} + +# package ksb::BuildContext {{{ +{ + # This contains the information needed about the build context, e.g. + # list of modules, what phases each module is in, the various options, + # etc. + package ksb::BuildContext; + + use Carp 'confess'; + use File::Basename; # dirname + use IO::File; + use POSIX qw(strftime); + + # We derive from Module so that BuildContext acts like the 'global' + # Module, with some extra functionality. + our @ISA = qw(Module); + + # This is the second-half of "use Foo". The first-half is "require Foo" but + # we already have ksb::Debug loaded above. + ksb::Debug->import(); + + ksb::Util->import(); + + my @DefaultPhases = qw/update build install/; + my @rcfiles = ("./kdesrc-buildrc", "$ENV{HOME}/.kdesrc-buildrc"); + + # defaultGlobalOptions {{{2 + my %defaultGlobalOptions = ( + "async" => 1, + "binpath" => '', + "build-when-unchanged" => 1, # Safe default + "branch" => "", + "build-dir" => "build", + "build-system-only" => "", + "checkout-only" => "", + "cmake-options" => "", + "configure-flags" => "", + "colorful-output" => 1, # Use color by default. + "cxxflags" => "-pipe", + "debug" => "", + "debug-level" => ksb::Debug::INFO, + "delete-my-patches" => 0, # Should only be set from cmdline + "dest-dir" => '${MODULE}', # single quotes used on purpose! + "disable-agent-check" => 0, # If true we don't check on ssh-agent + "do-not-compile" => "", + "git-repository-base" => {}, # Base path template for use multiple times. + "use-modules" => "", + "install-after-build" => 1, # Default to true + "kdedir" => "$ENV{HOME}/kde", + "kde-languages" => "", + "libpath" => "", + "log-dir" => "log", + "make-install-prefix" => "", # Some people need sudo + "make-options" => "-j2", + "manual-build" => "", + "manual-update" => "", + "module-base-path" => "", # Used for tags and branches + "niceness" => "10", + "no-svn" => "", + "override-url" => "", + "prefix" => "", # Override installation prefix. + "pretend" => "", + "purge-old-logs" => 1, + "qtdir" => "$ENV{HOME}/kdesrc/build/qt-copy", + "reconfigure" => "", + "refresh-build" => "", + "remove-after-install" => "none", # { none, builddir, all } + "repository" => '', # module's git repo + "revision" => 0, + "run-tests" => 0, # 1 = make test, upload = make Experimental + "set-env" => { }, # Hash of environment vars to set + "source-dir" => "$ENV{HOME}/kdesrc", + "stop-on-failure" => "", + "svn-server" => "svn://anonsvn.kde.org/home/kde", + "tag" => "", + "use-clean-install" => 0, + "use-idle-io-priority" => 0, + ); + # }}} 1 + + sub new { - my ($self) = shift; - return @$ModulePhases; + my ($class, @args) = @_; + + # It is very important to use the Module:: syntax instead of Module->, + # otherwise you can't pass $class and have it used as the classname. + my $self = Module::new($class, undef, 'global'); + my %newOpts = ( + modules => [], + context => $self, # Fix link to buildContext (i.e. $self) + build_options => { + global => \%defaultGlobalOptions, + # Module options are stored under here as well, keyed by module->name() + }, + # This one replaces Module::{phases} + phases => ksb::Phases->new(@DefaultPhases), + errors => { + # Phase names from phases map to a references to a list of failed Modules + # from that phase. + }, + logPaths=> { + # Holds a hash table of log path bases as expanded by + # get_subdir_path (e.g. [source-dir]/log) to the actual log dir + # *this run*, with the date and unique id added. You must still + # add the module name to use. + }, + rcFiles => [@rcfiles], + rcFile => undef, + ); + + # Merge all new options into our self-hash. + @{$self}{keys %newOpts} = values %newOpts; + $self->{options} = $self->{build_options}{global}; + + assert_isa($self, 'Module'); + assert_isa($self, 'ksb::BuildContext'); + + return $self; } - sub setPhases + # Gets the ksb::Phases for this context, and optionally sets it first to + # the ksb::Phases passed in. + sub phases { - my ($self, @phases) = @_; + my ($self, $phases) = @_; - if (blessed($self)) { - $self->{phases} = [@phases]; - } - else { - $ModulePhases = [@phases]; # Doesn't affect already created modules. + if ($phases) { + confess("Invalid type, expected Phases") + unless $phases->isa('ksb::Phases'); + $self->{phases} = $phases; } + return $self->{phases}; } - sub filterOutPhase + sub addModule { - my ($self, $deadPhase) = @_; + my ($self, $module) = @_; + Carp::confess("No module to push") unless $module; - # If already blessed, act like method, otherwise act like static - # class function. - if (blessed($self)) { - @{$self->{'phases'}} = grep($_ ne $deadPhase, @{$self->{'phases'}}); + if (list_has($self->{modules}, $module)) { + debug("Skipping duplicate module ", $module->name()); } else { - @$ModulePhases = grep($_ ne $deadPhase, @$ModulePhases); + debug("Adding ", $module->name(), " to module list"); + push @{$self->{modules}}, $module; } } - sub moduleSet + sub moduleList { - my ($self) = @_; - return $self->{'module-set'} if exists $self->{'module-set'}; - return ''; + my $self = shift; + return $self->{modules}; } - sub setModuleSet + sub setupOperatingEnvironment { - my ($self, $moduleSetName) = @_; - $self->{'module-set'} = $moduleSetName; - } + my $self = shift; + # Set the process priority + POSIX::nice(int $self->getOption('niceness')); - sub setModuleSource - { - my ($class, $source) = @_; - $ModuleSource = $source; - } + # Set the IO priority if available. + if ($self->getOption('use-idle-io-priority')) { + # -p $$ is our PID, -c3 is idle priority + # 0 return value means success + if (safe_system('ionice', '-c3', '-p', $$) != 0) { + warning (" b[y[*] Unable to lower I/O priority, continuing..."); + } + } - sub moduleSource - { - my $class = shift; - # Should be 'config' or 'cmdline'; - return $ModuleSource; + # Get ready for logged output. + ksb::Debug::setLogFile($self->getLogDirFor($self) . '/build-log'); } - sub moduleList + # This subroutine accepts a Module parameter, and returns the log directory + # for it. You can also pass a BuildContext (including this one) to get the + # default log directory. + # + # As part of setting up what path to use for the log directory, the + # 'latest' symlink will also be setup to point to the returned log + # directory. + sub getLogDirFor { - my ($self) = @_; - return @ModuleList; - } - - 1; -} + my ($self, $module) = @_; -# This is a hash since Perl doesn't have a "in" keyword. -my %ignore_list; # List of packages to refuse to include in the build list. + my $baseLogPath = main::get_subdir_path($module, 'log-dir'); + my $logDir; -# update and build are lists since they support an ordering, which can't be -# guaranteed using a hash unless I want a custom sort function (which isn't -# necessarily a horrible way to go, I just chose to do it this way. -my @update_list; # List of modules to update/checkout. -my @build_list; # List of modules to build. + if (!exists $self->{logPaths}{$baseLogPath}) { + # No log dir made for this base, do so now. + my $id = '01'; + my $date = strftime "%F", localtime; # ISO 8601 date + $id++ while -e "$baseLogPath/$date-$id"; + $self->{logPaths}{$baseLogPath} = "$baseLogPath/$date-$id"; + } -# Each module in the above list is of the form: -# { -# name => 'user-set-name', -# phases => [ qw/update build test install/ ], -# type => qw/svn git proj null/ # Only one of these -# } -# -# Where 'phases' can have at most one of each entry in the list above. Each -# phase has the obvious meaning, except purge is run at the end to possibly -# free up disk space. -# -# 'type' is the module type (as determined by heuristics, or directly by the -# user via svn-server or repository). If 'proj', the module can be converted to -# an equivalent 'git' module type by doing some processing of the -# kde_projects.xml file. 'null' is only used at e.g. the command line where the -# module type may not be known yet. - -# Dictionary of lists of failed modules, keyed by the name of the operation -# that caused the failure (e.g. build). Note that output_failed_module_lists -# uses the key name to display text to the user so it should describe the -# actual category of failure. You should also add the key name to -# output_failed_module_lists since it uses its own sorted list. -my @fail_display_order = qw/build update install uninstall/; -my %fail_lists = ( - 'build' => [ ], - 'install' => [ ], - 'uninstall'=>[ ], - 'update' => [ ], -); + $logDir = $self->{logPaths}{$baseLogPath}; + return $logDir if pretending(); -my $run_mode = 'build'; # Determines if updating, building, installing, etc. -my $BUILD_ID; # Used by logging subsystem to create a unique log dir. -my $LOG_DATE; # Used by logging subsystem to create logs in same dir. -my @rcfiles = ("./kdesrc-buildrc", "$ENV{HOME}/.kdesrc-buildrc", - "./kdesvn-buildrc", "$ENV{HOME}/.kdesvn-buildrc"); -my $rcfile; # the file that was used; set by read_options -my @screen_log; - -# Colors -my ($RED, $GREEN, $YELLOW, $NORMAL, $BOLD) = ("") x 5; - -# Subroutine definitions - -# I swear Perl must be the only language where the docs tell you to use a -# constant that you'll never find exported without some module from CPAN. -use constant PRIO_PROCESS => 0; - -# I'm lazy and would rather write in shorthand for the colors. This sub -# allows me to do so. Put it right up top to stifle Perl warnings. -sub clr($) -{ - my $str = shift; + main::super_mkdir($logDir) unless -e $logDir; - $str =~ s/g\[/$GREEN/g; - $str =~ s/]/$NORMAL/g; - $str =~ s/y\[/$YELLOW/g; - $str =~ s/r\[/$RED/g; - $str =~ s/b\[/$BOLD/g; + # No symlink munging or module-name-adding is needed for the default + # log dir. + return $logDir if $module->isa('ksb::BuildContext'); - return $str; -} + # Add a symlink to the latest run for this module. 'latest' itself is + # a directory under the default log directory that holds module + # symlinks, pointing to the last log directory run for that module. We + # do need to be careful of modules that have multiple directory names + # though (like extragear/foo). -# Subroutine which returns true if pretend mode is on. Uses the prototype -# feature so you don't need the parentheses to use it. -sub pretending() -{ - return get_option('global', 'pretend'); -} + my $latestPath = "$baseLogPath/latest"; -# Subroutine which returns true if debug mode is on. Uses the prototype -# feature so you don't need the parentheses to use it. -sub debugging() -{ - return get_option('global', 'debug-level') <= DEBUG; -} + # Handle stuff like playground/utils or KDE/kdelibs + my ($moduleName, $modulePath) = fileparse($module->name()); + $latestPath .= "/$modulePath" if $module->name() =~ m(/); -# The next few subroutines are used to print output at different importance -# levels to allow for e.g. quiet switches, or verbose switches. The levels are, -# from least to most important: -# debug, whisper, info (default), note (quiet), warning (very-quiet), and error. -# -# You can also use the pretend output subroutine, which is emitted if, and only -# if pretend mode is enabled. -# -# clr is automatically run on the input for all of those functions. -# Also, the terminal color is automatically reset to normal as well so you don't -# need to manually add the ] to reset. + main::super_mkdir($latestPath); -# Subroutine used to actually display the data, calls clr on each entry first. -sub print_clr(@) -{ - print clr $_ foreach (@_); - print clr "]\n"; + my $symlinkTarget = "$logDir/$moduleName"; + my $symlink = "$latestPath/$moduleName"; - push(@screen_log, join("\n", @_)); -} + if (-l $symlink and readlink($symlink) ne $symlinkTarget) + { + unlink($symlink); + symlink($symlinkTarget, $symlink); + } + elsif(not -e $symlink) + { + # Create symlink initially if we've never done it before. + symlink($symlinkTarget, $symlink); + } -sub debug(@) -{ - print_clr @_ if debugging; -} + main::super_mkdir($symlinkTarget); + return $symlinkTarget; + } -sub whisper(@) -{ - print_clr @_ if get_option('global', 'debug-level') <= WHISPER; -} + # Returns rc file in use. Call loadRcFile first. + sub rcFile + { + my $self = shift; + return $self->{rcFile}; + } -sub info(@) -{ - print_clr @_ if get_option('global', 'debug-level') <= INFO; -} + # Forces the rc file to be read from to be that given by the first + # parameter. + sub setRcFile + { + my ($self, $file) = @_; + $self->{rcFiles} = [$file]; + $self->{rcFile} = undef; + } -sub note(@) -{ - print_clr @_ if get_option('global', 'debug-level') <= NOTE; -} + # Returns an open filehandle to the user's chosen rc file. Use setRcFile + # to choose a file to load before calling this function, otherwise + # loadRcFile will search the default search path. After this function is + # called, rcFile() can be used to determine which file was loaded. + # + # If unable to find or open the rc file an exception is raised. Empty rc + # files are supported however. + # + # TODO: Support a fallback default rc file. + sub loadRcFile + { + my $self = shift; + my @rcFiles = @{$self->{rcFiles}}; + my $fh; -sub warning(@) -{ - print_clr @_ if get_option('global', 'debug-level') <= WARNING; -} + for my $file (@rcFiles) + { + if (open ($fh, '<', "$file")) + { + $self->{rcFile} = $file; + return $fh; + } + } -sub error(@) -{ - print STDERR (clr $_) foreach (@_); - print STDERR (clr "]\n"); -} + # If still here, no luck. + if (scalar @rcFiles == 1) + { + # This can only happen if the user uses --rc-file, so if we fail to + # load the file, we need to fail to load at all. + my $failedFile = $rcFiles[0]; -sub pretend(@) -{ - print_clr @_ if pretending; -} + error (<{rcFile} = '~/.kdesrc-buildrc'; + $self->whineForMissingConfig(); + $self->setup_default_modules(); + + my $data = ''; # TODO: Point to sane default. + open ($fh, '<', \$data); + return $fh; + } - if ($mode eq 'existing') + sub whineForMissingConfig { - # There's two ways of finding the old file. Searching backwards with - # valid combinations of the date and build id, or just reading in the - # name from a known file or location. Since the latter option is much - # easier, that's what I'm going with. Note that this depends on the - # latest symlink being in place. - $logdir = get_subdir_path ('global', 'log-dir'); - $fname = "$logdir/latest/build-status"; + my $self = shift; + my $searched = join ("\n ", @{$self->{rcFiles}}); + my $homepage = "http://kdesrc-build.kde.org/"; - debug "Old build status file is $fname"; + note (<<"HOME"); +Unable to open configuration file! +We looked for: + $searched - # The _ at the end returns the cached file stats to avoid multiple - # stat() calls. - return "" if not -e $fname or not -r _; +You should create a configuration file. The file kdesrc-buildrc-sample should +be included with your kdesrc-build package, which you can copy to +~/.kdesrc-buildrc and edit from there. - return $fname; +If the b[kdesrc-build-setup] program is installed, you can run that program +to quickly generate a simple configuration to get started. +HOME } - # This call must follow the test above, because it changes the 'latest' - # symlink leading to failures later. - $logdir = get_log_dir('global'); - - $fname = "$logdir/build-status"; - debug "Build status file is $fname"; + sub modulesInPhase + { + my ($self, $phase) = @_; + my @list = grep { list_has([$_->phases()->phases()], $phase) } (@{$self->moduleList()}); + return @list; + } - return $fname; -} + # Searches for a module with a name that matches the provided parameter, + # and returns its Module object. Returns undef if no match was found. + # As a special-case, returns the BuildContext itself if the name passed is + # 'global', since the BuildContext also is a (in the "is-a" OOP sense) + # Module, specifically the 'global' one. + sub lookupModule + { + my ($self, $moduleName) = @_; -# This subroutine acts like split(' ', $_) except that double-quoted strings are not split in -# the process. Patch provided by Alain Boyer (alainboyer@gmail.com) based on a posting at -# http://www.perlmonks.org/?node_id=212174. Converted to an extended RE for readability by -# mpyne. -# -# Note: This only works if the quotes completely surround the parameter in question. -# i.e. "a=-DFOO -DBAR" works, a="-DFOO -DBAR" does not. -# -# First parameter: String to split on whitespace. -# Return value: A list of the individual words and quoted values in the string. -sub split_quoted_on_whitespace($) -{ - my $str = shift; - my @words = $str =~ - /\s* # Eat up whitespace - "? # Match 0-1 quotes - ( # Open grouping expression - (?name() eq $moduleName } (@{$self->moduleList()}); + return undef unless @options; -# Subroutine to retrieve a subdirectory path for the given module. -# First parameter is the name of the module, and the second -# parameter is the option key (e.g. build-dir or log-dir). -sub get_subdir_path -{ - my $module = shift; - my $option = shift; - my $dir = get_option($module, $option); + if (scalar @options > 1) { + die make_exception('Internal', 'Detected 2 or more kdelibs Module objects'); + } - # If build-dir starts with a slash, it is an absolute path. - return $dir if $dir =~ /^\//; + return $options[0]; + } - # If it starts with a tilde, expand it out. - if ($dir =~ /^~/) + # This subroutine setups a default set of modules to be updated and built, + # and handles setting up their initial options (also just chosen by + # default). + # + # Note: Call this and you stand the risk of losing the options you're + # already set, do this only if you need to setup options for the entire + # list of default modules. + sub setup_default_modules() { - $dir =~ s/^~/$ENV{'HOME'}/; + my $self = shift; + + # TODO: Move this to the build-support git repo. + my @defaultModuleList = qw( + qt-copy automoc cagibi attica soprano polkit-qt-1 phonon + strigi kdesupport dbusmenu-qt + kdelibs akonadi kdepimlibs + kde-runtime kde-workspace kde-baseapps + konsole kate kdeplasma-addons + phonon-gstreamer phonon-vlc + kdemultimedia kdeartwork kdepim kdeutils kdegraphics kdegames + kdetoys kdeedu kdenetwork + ); + + whisper("Setting up to build ", join(', ', @defaultModuleList), " by default."); + + my $allOptsRef = $self->{build_options}; + for my $i (@defaultModuleList) { + my $options_ref = main::default_module_options($i); + + # Apply default option only if option not already set. If the option + # is here at this point it's probably user defined on the command line + # or setup by kdesrc-build based on an option. + for my $key (keys %{$options_ref}) { + if (not exists $allOptsRef->{$i}{$key}) { + $allOptsRef->{$i}{$key} = $options_ref->{$key}; + } + } + + $self->addModule(Module->new($self, $i)); + } } - else + + sub markModulePhaseFailed { - # Relative directory, tack it on to the end of $kdesrcdir. - my $kdesrcdir = get_option($module, 'source-dir'); - $dir = "$kdesrcdir/$dir"; - } + my ($self, $phase, $module) = @_; + assert_isa($module, 'Module'); - return $dir; -} + # Make a default empty list if we haven't already marked a module in this phase as + # failed. + $self->{errors}{$phase} //= [ ]; + push @{$self->{errors}{$phase}}, $module; + } -# Subroutine to return the name of the destination directory for the checkout -# and build routines. Based on the dest-dir option. The return value will be -# relative to the src/build dir. The user may use the '$MODULE' or '${MODULE}' -# sequences, which will be replaced by the name of the module in question. -# -# The first parameter should be the module name. -sub get_dest_dir -{ - my $module = shift; - my $dest_dir = get_option($module, 'dest-dir'); + # Returns a list (i.e. not a reference to, but a real list) of Modules that failed to + # complete the given phase. + sub failedModulesInPhase + { + my ($self, $phase) = @_; - $dest_dir =~ s/(\${MODULE})|(\$MODULE\b)/$module/g; + # The || [] expands an empty array if we had no failures in the given phase. + return @{$self->{errors}{$phase} || []}; + } - return $dest_dir; -} + # Returns true if the build context has overridden the value of the given module + # option key. Use getOption (on this object!) to get what the value actually is. + sub hasStickyOption + { + my ($self, $key) = @_; + $key =~ s/^#//; # Remove sticky marker. -# This function returns true if the give module uses CMake. If the user has -# specified a choice, we use the user's choice regardless for now. If no user -# choice is given, auto-detect based on searching for filenames. -# -# First parameter: Module to check. -# Return: True (non-zero) if user has chosen cmake or CMake support is detected, -# False (0, undef) if user does not want cmake or no CMake support is detected. -sub module_uses_cmake -{ - my $module = shift; + return 1 if list_has([qw/pretend disable-agent-check/], $key); + return $self->hasOption("#$key"); + } - my $srcdir = get_fullpath($module, 'source'); - return 1 if -e "$srcdir/CMakeLists.txt"; + # OVERRIDE: Returns one of the following: + # 1. The sticky option overriding the option name given. + # 2. The value of the option name given. + # 3. The empty string (this function never returns undef). + # + # The first matching option is returned. See Module::getOption, which is + # typically what you should be using. + sub getOption + { + my ($self, $key) = @_; - # Kind of a hack but it beats inventing a sequence of checks that happens - # to get it right: just hardcode in the module that is the exception to the - # rule. + foreach ("#$key", $key) { + return $self->{options}{$_} if exists $self->{options}{$_}; + } - return 1 if $module =~ /^l10n-kde4\/?/; + return ''; + } - # No CMakeLists? Expected for qt-copy - return 0 if $module eq 'qt-copy'; + # OVERRIDE: Overrides Module::setOption to handle some global-only options. + sub setOption + { + my ($self, %options) = @_; - # No CMakeLists.txt found, if the directory existed don't use CMake, - # otherwise assume we are using CMake for now. + # Actually set options. + $self->SUPER::setOption(%options); - return not -e $srcdir; -} + # Automatically respond to various global option changes. + while (my ($key, $value) = each %options) { + my $normalizedKey = $key; + $normalizedKey =~ s/^#//; # Remove sticky key modifier. + given ($normalizedKey) { + when ('colorful-output') { ksb::Debug::setColorfulOutput($value); } + when ('debug-level') { ksb::Debug::setDebugLevel($value); } + when ('pretend') { ksb::Debug::setPretending($value); } + } + } + } -# Convenience subroutine to get the source root dir. -sub get_source_dir -{ - my $module = shift; - $module = 'global' unless defined $module; + # + # Persistent option handling + # - return get_subdir_path ($module, 'source-dir'); -} + # Reads in all persistent options from the file where they are kept + # (.kdesrc-build-data) for use in the program. + # + # The directory used is the same directory that contains the rc file in use. + sub loadPersistentOptions + { + my $self = assert_isa(shift, 'ksb::BuildContext'); + my $rcfile = $self->rcFile(); + my $dir = dirname($rcfile ? $rcfile : ""); + my $fh = IO::File->new("<$dir/.kdesrc-build-data"); -# Function to work around a Perl language limitation. -# First parameter is the list to search. -# Second parameter is the value to search for. -# Returns true if the value is in the list -sub list_has(\@$) -{ - my ($list_ref, $value) = @_; - return scalar grep ($_ eq $value, @{$list_ref}); -} + return unless $fh; -# Subroutine to return the branch prefix. i.e. the part before the branch name -# and module name. -# -# The first parameter is the module in question. -# The second parameter should be 'branches' if we're dealing with a branch or -# 'tags' if we're dealing with a tag. -# -# Ex: 'kdelibs' => 'branches/KDE' -# 'kdevelop' => 'branches/kdevelop' -sub branch_prefix -{ - my $module = shift; - my $type = shift; + my $persistent_data; + { + local $/ = undef; # Read in whole file with <> operator. + $persistent_data = <$fh>; + } - # These modules seem to have their own subdir in /tags. - my @tag_components = qw/arts koffice amarok kst qt taglib/; + # $persistent_data should be Perl code which, when evaluated will give us + # a hash called persistent_options which we can then merge into our + # persistent options. - # The map call adds the kde prefix to the module names because I don't feel - # like typing them all in. - my @kde_module_list = ((map {'kde' . $_} qw/accessibility - addons admin artwork base bindings edu games graphics libs - multimedia network pim pimlibs plasma-addons sdk toys utils webdev/)); + my $persistent_options; - # If the user already has the module in the form KDE/foo, it's already - # done. - return "$type/KDE" if $module =~ /^KDE\//; + # eval must appear after declaration of $persistent_options + eval $persistent_data; + if ($@) + { + # Failed. + error ("Failed to read persistent module data: r[b[$@]"); + return; + } - # KDE proper modules seem to use this pattern. - return "$type/KDE" if list_has(@kde_module_list, $module); + # We need to keep persistent data with the context instead of with the + # applicable modules since otherwise we might forget to write out + # persistent data for modules we didn't build in this run. So, we just + # store it all. + # Layout of this data: + # $self->persistent_options = { + # 'module-name' => { + # option => value, + # # foreach option/value pair + # }, + # # foreach module + # } + $self->{persistent_options} = $persistent_options; + } - # KDE extragear / playground modules use this pattern - return "$type" if has_base_module($module); + # Writes out the persistent options to the file .kdesrc-build-data. + # + # The directory used is the same directory that contains the rc file in use. + sub storePersistentOptions + { + my $self = assert_isa(shift, 'ksb::BuildContext'); + return if pretending(); - # If we doing a tag just return 'tags' because the next part is the actual - # tag name, which is added by the caller, unless the module has its own - # subdirectory in /tags. - return "$type" if $type eq 'tags' and not list_has(@tag_components, $module); + my $rcfile = $self->rcFile() // ""; + my $dir = dirname($rcfile); + my $fh = IO::File->new("> $dir/.kdesrc-build-data"); - # Everything else. - return "$type/$module"; -} + if (!$fh) + { + error ("Unable to save persistent module data: b[r[$!]"); + return; + } -# Subroutine to return a module URL for a module using the 'branch' option. -# First parameter is the module in question. -# Second parameter is the type ('tags' or 'branches') -sub handle_branch_tag_option -{ - my ($module, $type) = @_; - my $svn_server = get_option($module, 'svn-server'); - my $branch = branch_prefix($module, $type); - my $branchname = get_option($module, 'tag'); + print $fh "# AUTOGENERATED BY kdesrc-build $versionNum\n"; - if($type eq 'branches') - { - $branchname = get_option($module, 'branch'); + $Data::Dumper::Indent = 1; + print $fh Data::Dumper->Dump([$self->{persistent_options}], ["persistent_options"]); + undef $fh; # Closes the file } - # qt-copy is referred to as qt in svn when dealing with branches and tags. - $branch = branch_prefix('qt', $type) if $module eq 'qt-copy'; + # Returns the value of a "persistent" option (normally read in as part of + # startup), or undef if there is no value stored. + # + # First parameter is the module name to get the option for, or 'global' if + # not for a module. + # Note that unlike setOption/getOption, no inheritance is done at this + # point so if an option is present globally but not for a module you + # must check both if that's what you want. + # Second parameter is the name of the value to retrieve (i.e. the key) + sub getPersistentOption + { + my ($self, $moduleName, $key) = @_; + my $persistent_opts = $self->{persistent_options}; + + # We must check at each level of indirection to avoid + # "autovivification" + return unless exists $persistent_opts->{$moduleName}; + return unless exists $persistent_opts->{$moduleName}{$key}; - # Remove trailing slashes. - $svn_server =~ s/\/*$//; + return $persistent_opts->{$moduleName}{$key}; + } - # Remove KDE/ prefix for module name. - $module = moduleBaseName($module); + # Sets a "persistent" option which will be read in for a module when + # kdesrc-build starts up and written back out at (normal) program exit. + # + # First parameter is the module name to set the option for, or 'global'. + # Second parameter is the name of the value to set (i.e. key) + # Third parameter is the value to store, which must be a scalar. + sub setPersistentOption + { + my ($self, $moduleName, $key, $value) = @_; + my $persistent_opts = $self->{persistent_options}; - # KDE modules have a different module naming scheme than the rest it seems. - return "$svn_server/$branch/$branchname/$module" if $branch =~ /\/KDE\/?$/; + # Initialize empty hash ref if nothing defined for this module. + $persistent_opts->{$moduleName} //= { }; - # Non-trunk translations happen in a single branch. Assume all non-trunk global - # branches are intended for the stable translations. - return "$svn_server/branches/stable/$module" if ($module =~ /^l10n-kde4\/?/ && $branch ne 'trunk'); + $persistent_opts->{$moduleName}{$key} = $value; + } - # Otherwise don't append the module name by default since it makes more - # sense to branch this way in many situations (i.e. kdesupport tags, phonon) - return "$svn_server/$branch/$branchname"; + 1; } +# }}} -# Subroutine to return the appropriate SVN URL for a given module, based on -# the user settings. For example, 'kdelibs' -> https://svn.kde.org/home/kde/trunk/KDE/kdelibs -# -# This operates under a double hierarchy: -# 1. If any module-specific option is present, it wins. -# 2. If only global options are present, the order override-url, tag, branch, module-base-path, -# is preferred. -sub svn_module_url +# package Module {{{ { - my $module = shift; - my $svn_server = get_option($module, 'svn-server'); - my $modulePath; + package Module; - foreach my $levelLimit ('module', 'allow-inherit') { - $modulePath = get_option($module, 'module-base-path', $levelLimit); + use Storable 'dclone'; + use Carp 'confess'; + use Scalar::Util 'blessed'; + use overload + '""' => 'toString', # Add stringify operator. + '<=>' => 'compare', + ; - # Allow user to override normal processing of the module in a few ways, - # to make it easier to still be able to use kdesrc-build even when I - # can't be there to manually update every little special case. - if(get_option($module, 'override-url', $levelLimit)) - { - return get_option($module, 'override-url', $levelLimit); - } + ksb::Debug->import(); + ksb::Util->import(); - if(get_option($module, 'tag', $levelLimit)) - { - return handle_branch_tag_option($module, 'tags'); - } + my $ModuleSource = 'config'; - # Note we check for 'trunk', not default_module_branch(). We handle 'trunk' in the - # rest of the code path, any branch (even if default) should be handled in - # handle_branch_tag_option(). - my $branch = get_option($module, 'branch', $levelLimit); - if($branch and $branch ne 'trunk') - { - return handle_branch_tag_option($module, 'branches'); - } + sub new + { + my ($class, $ctx, $name, $type) = @_; - # This isn't true nowadays, but *is* true for older versions of phonon which - # were developed in subversion. - if($module eq 'phonon') + confess "Empty Module constructed" unless $name; + + # If building a BuildContext instead of a Module, then the context + # can't have been setup yet... + my $contextClass = 'ksb::BuildContext'; + if ($class ne $contextClass && + (!blessed($ctx) || !$ctx->isa($contextClass))) { - $module = 'kdesupport/phonon'; + confess "Invalid context $ctx"; } - # We can't use get_option($module) after this if we have to trim the module - # name. - $module = moduleBaseName($module); + # Clone the passed-in phases so we can be different. + my $phases = dclone($ctx->phases()) if $class eq 'Module'; - # The following modules are in /trunk, not /trunk/KDE. There are others, - # but these are the important ones. - my @non_trunk_modules = qw(extragear kdesupport koffice icecream kde-common - playground qt-copy KDE kdereview www l10n-kde4); + # Use a sub-hash of the context's build options so that all + # global/module options are still in the same spot. The options might + # already be set by read_options, but in case they're not we assign { } + # if not already defined. + $ctx->{build_options}{$name} //= { }; - my $module_root = $module; - $module_root =~ s/\/.*//; # Remove everything after the first slash + my $module = { + name => $name, + type => $type, + phases => $phases, + context => $ctx, + options => $ctx->{build_options}{$name}, + 'module-set' => '', + }; - if (not $modulePath and $levelLimit eq 'allow-inherit') - { - $modulePath = "trunk/KDE/$module"; - $modulePath = "trunk/$module" if list_has(@non_trunk_modules, $module_root); - $modulePath =~ s/^\/*//; # Eliminate / at beginning of string. - $modulePath =~ s/\/*$//; # Likewise at the end. - } + return bless $module, $class; + } - last if $modulePath; + sub phases + { + my $self = shift; + return $self->{phases}; } - # Remove trailing slashes. - $svn_server =~ s/\/*$//; - - # Note that the module name is no longer appended if module-base-path is used (i.e. - # $branch variable was set. This is a change as of version 1.8. - return "$svn_server/$modulePath"; -} + sub moduleSet + { + my ($self) = @_; + return $self->{'module-set'} if exists $self->{'module-set'}; + return ''; + } -# Returns true if the Net::HTTP module is available. -BEGIN { - my $Net_HTTP_available = undef; + sub setModuleSet + { + my ($self, $moduleSetName) = @_; + $self->{'module-set'} = $moduleSetName; + } - sub has_Net_HTTP + sub setModuleSource { - return $Net_HTTP_available if defined $Net_HTTP_available; + my ($class, $source) = @_; + $ModuleSource = $source; + } - eval { - require Net::HTTP; - $Net_HTTP_available = 1; - } or do { - error " y[*] Can't open y[b[Net::HTTP] module, skipping check for module snapshot."; - debug "Error was $@"; - $Net_HTTP_available = 0; - }; + sub moduleSource + { + my $class = shift; + # Should be 'config' or 'cmdline'; + return $ModuleSource; + } - return $Net_HTTP_available; + sub name + { + my $self = shift; + return $self->{name}; } -} -# Convenience subroutine to return the build directory for a module. Use -# this instead of get_subdir_path because this special-cases modules for you, -# (if necessary). -# -# The returned value does not include the module name at the end (as the build -# path on disk doesn't always use the module name given in the .kdesrc-buildrc), -# so be sure to add on the module name if needed. -sub get_build_dir -{ - my $module = shift; + # Returns a string describing the scm platform of the given module. + # Return value: 'git' or 'svn' at this point, as appropriate. + sub type + { + my $self = shift; - return get_subdir_path($module, 'build-dir'); -} + return $self->{type} if $self->{type}; -# Subroutine to return a list of the different log directories that are used -# by the different modules in the script. -sub get_all_log_directories -{ - my @module_list = keys %package_opts; - my %log_dict; + # Look for specific setting of repository and svn-server. If both is + # set it's a bug, if one is set, that's the type (because the user says + # so...). Don't use getOption($key) as it will try to fallback to + # global options. + + my $svn_status = $self->getOption('svn-server', 'module'); + my $git_status = $self->getOption('repository', 'module'); + my $rcfile = $self->buildContext()->rcFile(); - # A hash is used to track directories to avoid duplicate entries. - unshift @module_list, "global"; - $log_dict{get_subdir_path($_, 'log-dir')} = 1 foreach @module_list; + if ($svn_status && $git_status) { + error (<{type} = $git_status ? 'git' : 'svn'; + return $self->{type}; + } - for (@log_dirs) + sub buildContext { - my $id = "01"; - $id++ while -e "$_/$date-$id"; + my $self = shift; + return $self->{context}; + } - # We need to use a string comparison operator to keep - # the magic in the ++ operator. - $min_build_id = $id if $id gt $min_build_id; + # Returns the path to the log directory used during this run for this + # Module. + # + # In addition it handles the 'latest' symlink to allow for ease of access + # to the log directory afterwards. + sub getLogDir + { + my ($self) = @_; + return $self->buildContext()->getLogDirFor($self); } - $LOG_DATE = $date; - $BUILD_ID = $min_build_id; -} + sub toString + { + my $self = shift; + return $self->name(); + } -# Convienience subroutine to return the log directory for a module. -# It also creates the directory and manages the 'latest' symlink. -# -# Returns undef on an error, or the name of the directory otherwise. -sub get_log_dir -{ - my $module = shift; - my $logbase = get_subdir_path($module, 'log-dir'); - my $logpath = "$logbase/$LOG_DATE-$BUILD_ID/$module"; + sub compare + { + my ($self, $other) = @_; + return $self->name() cmp $other->name(); + } - $logpath = "$logbase/$LOG_DATE-$BUILD_ID" if $module eq 'global'; + # This subroutine returns an option value for a given module. Some globals + # can't be overridden by a module's choice (but see 2nd parameter below). + # If so, the module's choice will be ignored, and a warning will be issued. + # + # Option names are case-sensitive! + # + # Some options (e.g. cmake-options, configure-flags) have the global value + # and then the module's own value appended together. To get the actual + # module setting you must use the level limit parameter set to 'module'. + # + # Likewise, some qt-copy options do not obey the previous proviso since Qt + # options are not likely to agree nicely with generic KDE buildsystem + # options. + # + # 1st parameter: Name of option + # 2nd parameter: Level limit (optional). If not present, then the value + # 'allow-inherit' is used. Options: + # - allow-inherit: Module is used if present (with exceptions), otherwise + # global is used. + # - module: Only module is used (if you want only global then use the + # buildContext) NOTE: This overrides global "sticky" options as well! + sub getOption + { + my ($self, $key, $levelLimit) = @_; + my $ctx = $self->buildContext(); + assert_isa($ctx, 'ksb::BuildContext'); + $levelLimit //= 'allow-inherit'; - return $logpath if pretending; + # Some global options would probably make no sense applied to qt-copy. + my @qtCopyOverrides = qw(branch configure-flags tag cxxflags); + if ($self->name() eq 'qt-copy' && list_has(@qtCopyOverrides, $key)) { + $levelLimit = 'module'; + } - debug "Log directory for $module is $logpath"; + assert_in($levelLimit, [qw(allow-inherit module)]); - if (not -e $logpath and not super_mkdir($logpath)) - { - error "Unable to create log directory r[$logpath]"; - return undef; - } + # If module-only, check that first. + return $self->{options}{$key} if $levelLimit eq 'module'; - # Don't mess with Texas^H^H^H^H^Hsymlinks for 'global' - return $logpath if $module eq 'global'; + # Some global options always override module options. + return $ctx->getOption($key) if $ctx->hasStickyOption($key); - # Add a symlink to the latest run for this module. Previous kdesrc-build - # releases would use /latest as a symlink, but this made it hard to find - # the last run on e.g. kdebindings if you built kdebase alone last time. - # So now latest is a directory that holds module symlinks. We do need to - # be careful of modules that have multiple directory names though (like - # extragear/foo). + # Some options append to the global (e.g. conf flags) + my @confFlags = qw(cmake-options configure-flags cxxflags); + if (list_has(@confFlags, $key) && $ctx->hasOption($key)) { + return $ctx->getOption($key) . " " . ($self->{options}{$key} || ''); + } - # This operation should be atomic in async mode since the update thread - # should create the log dir before it is needed by the build thread (which - # will not have to unlink/symlink). - if (-l "$logbase/latest") - { - # Remove old-style symlink - unlink("$logbase/latest"); + # Everything else overrides the global option, unless it's simply not + # set at all. + return $self->{options}{$key} // $ctx->getOption($key); } - if (not -e "$logbase/latest") + # Returns true if (and only if) the given option key value is set as an + # option for this module, even if the corresponding value is empty or + # undefined. In other words it is a way to see if the name of the key is + # recognized in some fashion. + # + # First parameter: Key to lookup. + # Returns: True if the option is set, false otherwise. + sub hasOption { - mkdir("$logbase/latest"); + my ($self, $key) = @_; + my $name = $self->name(); + + return exists $self->{options}{$key}; } - # Handle stuff like playground/utils or KDE/kdelibs - my ($moduleName, $modulePath) = fileparse($module); + # Sets the option refered to by the first parameter (a string) to the + # scalar (e.g. references are OK too) value given as the second paramter. + sub setOption + { + my ($self, %options) = @_; + while (my ($key, $value) = each %options) { + # ref($value) checks if value is already a reference (i.e. a hashref) + # which means we should just copy it over, as all handle_set_env does + # is convert the string to the right hashref. + if (!ref($value) && main::handle_set_env($self->{options}, $key, $value)) + { + return + } - # Setup directory path we need to create. - my $latestPath = "$logbase/latest"; + debug (" Setting $self,$key = $value"); + $self->{options}{$key} = $value; + } + } - # If we have a path separator we need to adjust and create dirs and stuff - if ($module =~ /\//) + # Simply removes the given option and its value, if present + sub deleteOption { - $latestPath .= "/$modulePath"; - super_mkdir($latestPath); + my ($self, $key) = @_; + delete $self->{options}{$key} if exists $self->{options}{$key}; } - else + + # Gets persistent options set for this module. First parameter is the name + # of the option to lookup. Undef is returned if the option is not set, + # although even if the option is set, the value returned might be empty. + # Note that ksb::BuildContext also has this function, with a slightly + # different signature, which OVERRIDEs this function since Perl does not + # have parameter-based method overloading. + sub getPersistentOption { - $moduleName = $module; # This just makes later stuff easier + my ($self, $key) = @_; + return $self->buildContext()->getPersistentOption($self->name(), $key); } - my $symlinkTarget = "$logbase/$LOG_DATE-$BUILD_ID/$module"; - my $symlink = "$latestPath/$moduleName"; + # Sets a persistent option (i.e. survives between processes) for this module. + # First parameter is the name of the persistent option. + # Second parameter is its actual value. + # See the warning for getPersistentOption above, it also applies for this + # method vs. ksb::BuildContext::setPersistentOption + sub setPersistentOption + { + my ($self, $key, $value) = @_; + return $self->buildContext()->setPersistentOption($self->name(), $key, $value); + } - if (-l $symlink and readlink($symlink) ne $symlinkTarget) + # Clones the options from the given Module (as handled by + # hasOption/setOption/getOption). Options on this module will then be able + # to be set independently from the other module. + sub cloneOptionsFrom { - unlink($symlink); - symlink($symlinkTarget, $symlink); + my $self = shift; + my $other = assert_isa(shift, 'Module'); + + $self->{options} = dclone($other->{options}); } - elsif(not -e $symlink) + + # Returns the path to the desired directory type (source or build), + # including the module destination directory itself. + sub fullpath { - # Create symlink initially if we've never done it before. - symlink($symlinkTarget, $symlink); + my ($self, $type) = @_; + assert_in($type, [qw/build source/]); + + my %pathinfo = main::get_module_path_dir($self, $type); + return $pathinfo{'fullpath'}; + } + + # Returns true if the module should have make install run in order to be + # used, or false if installation is not required or possible. + sub needsInstalled + { + my $self = shift; + + return 0 if $self->name() eq 'kde-common'; # Vestigial but possible. + + # Don't install Qt if QTDIR == builddir + if ($self->name() eq 'qt-copy') { + return $self->getOption('qtdir') ne $self->fullpath('build'); + } + + return 1; } - return $logpath; + 1; } +# }}} -# This subroutine returns an option value for a given module. Some -# globals can't be overridden by a module's choice. If so, the -# module's choice will be ignored, and a warning will be issued. -# -# Option names are case-sensitive! -# -# First parameter: Name of module -# Second paramenter: Name of option -# Third parameter: Level limit (optional). If not present, then the value -# 'allow-inherit' is used. Options: -# - allow-inherit: Module is used if present (with exceptions), otherwise -# global is used. -# - module: Only module is used (if you want only global then use a module of 'global') -sub get_option +# package RecursiveFH {{{ { - my $module = shift; - my $option = shift; - my $levelLimit = shift; - my $globalOpts = $package_opts{'global'}; - my @lockedOpts = qw(pretend disable-agent-check); + package RecursiveFH; - # Default value - $levelLimit = 'allow-inherit' unless defined $levelLimit; + # Alias the global make_exception into this package. + *make_exception = *main::make_exception; - # These options can't override globals - if (list_has(@lockedOpts, $option) or $module eq 'global') + sub new { - return ${$globalOpts}{"#$option"} if exists ${$globalOpts}{"#$option"}; - return ${$globalOpts}{$option}; + my ($class) = @_; + my $data = { + 'filehandles' => [], # Stack of filehandles to read + 'current' => undef, # Current filehandle to read + }; + + return bless($data, $class); } - # Some global options would probably make no sense applied to qt-copy. - my @qtCopyOverrides = qw(branch configure-flags tag); - $levelLimit = 'module' if ($module eq 'qt-copy' && list_has(@qtCopyOverrides, $option)); + sub addFilehandle + { + my ($self, $fh) = @_; + push @{$self->{filehandles}}, $fh; + $self->setCurrentFilehandle($fh); + } - # Ensure levelLimit is not broken - my @validLevelLimits = qw(allow-inherit module); - if (not list_has(@validLevelLimits, $levelLimit)) + sub popFilehandle { - die "Invalid level limit $levelLimit passed to get_option"; + my $self = shift; + my $result = pop @{$self->{filehandles}}; + my $newFh = scalar @{$self->{filehandles}} ? ${$self->{filehandles}}[-1] + : undef; + $self->setCurrentFilehandle($newFh); + return $result; } - my $ref = $package_opts{$module}; + sub currentFilehandle + { + my $self = shift; + return $self->{current}; + } + + sub setCurrentFilehandle + { + my $self = shift; + $self->{current} = shift; + } + + # Reads the next line of input and returns it. + # If a line of the form "include foo" is read, this function automatically + # opens the given file and starts reading from it instead. The original + # file is not read again until the entire included file has been read. This + # works recursively as necessary. + # + # No further modification is performed to returned lines. + # + # undef is returned on end-of-file (but only of the initial filehandle, not + # included files from there) + sub readLine + { + my $self = shift; - # Check for a sticky option - return $$ref{"#$option"} if exists $$ref{"#$option"}; + # Starts a loop so we can use evil things like "redo" + READLINE: { + my $line; + my $fh = $self->currentFilehandle(); - # If we are limited to module options then find it and return it - return $$ref{$option} if $levelLimit eq 'module'; + # Sanity check since different methods might try to read same file reader + return undef unless defined $fh; - # Otherwise, keep going in order of precedence - return ${$globalOpts}{"#$option"} if defined ${$globalOpts}{"#$option"}; + if (eof($fh) || !defined($line = <$fh>)) { + my $oldFh = $self->popFilehandle(); + close $oldFh; - # No sticky options left. - # cmake options and CXXFLAGS are appended to the global option - if ($module ne 'qt-copy' && ($option eq 'cxxflags' || $option eq 'cmake-options')) - { - my $value = ${$globalOpts}{$option}; + my $fh = $self->currentFilehandle(); - if(defined $$ref{$option}) - { - my $modvalue = $$ref{$option}; - $value .= " $modvalue"; - } + return undef if !defined($fh); - return $value; - } + redo READLINE; + } + elsif ($line =~ /^\s*include\s+\S/) { + # Include found, extract file name and open file. + chomp $line; + my ($filename) = ($line =~ /^\s*include\s+(.+)$/); - # qt-copy should already have default options set, no need to check - # specifically for it. We still may need to prevent returning a set global - # option when the default is unset. + if (!$filename) { + die make_exception('Config', + "Unable to handle file include on line $., '$line'"); + } - # Everything else overrides the global, unless of course it's not set. - # If we're reading for global options, we're pretty much done. - return $$ref{$option} if defined $$ref{$option}; + my $newFh; + $filename =~ s/^~\//$ENV{HOME}\//; # Tilde-expand - return ${$globalOpts}{$option}; -} + open ($newFh, '<', $filename) or + die make_exception('Config', + "Unable to open file $filename which was included from line $."); -# Like get_option, but returns the requested option for a given module with no -# fallbacks to global options, no overrides, etc. Basically goes directly into -# package_opts. -sub get_module_option -{ - my ($module, $option) = @_; + $self->addFilehandle($newFh); - if (not exists $package_opts{$module} || not exists $package_opts{$module}->{$option}) - { - return undef; + redo READLINE; + } + else { + return $line; + } + } } - return $package_opts{$module}->{$option}; + 1; } +# }}} -# Returns a Perl object worth "die"ing for. (i.e. can be given to the die -# function and handled appropriately later with an eval). The returned -# reference will be an instance of BuildException. The actual exception type is -# passed in as the first parameter (as a string), and can be retrieved from the -# object later using the 'exception_type' key, and the message is returned as -# 'message' -# -# First parameter: Exception type -# Second parameter: Message to show to user -# Return: Reference to the exception object suitable for giving to "die" -sub make_exception -{ - my $exception_type = shift; - my $message = shift; - - $exception_type = 'Exception' unless defined $exception_type; - - my $obj = eval { - package BuildException; - my $new_obj = {'exception_type' => $exception_type, - 'message' => $message }; - bless($new_obj); - return $new_obj; - }; - - return $obj; +# Global import for debugging routines. This must be a BEGIN block only because +# for a long time I abused the Perl subroutine prototype feature to allow not +# putting parentheses around subs like pretending or info, which would not even +# parse correctly if the customized import routine were not allowed to run +# first and insert prototypes in addition to the method names. +BEGIN { + ksb::Debug->import(); + ksb::Util->import(); } -# Returns a string describing the scm platform of the given module. +# This subroutine acts like split(' ', $_) except that double-quoted strings are not split in +# the process. Patch provided by Alain Boyer (alainboyer@gmail.com) based on a posting at +# http://www.perlmonks.org/?node_id=212174. Converted to an extended RE for readability by +# mpyne. +# +# Note: This only works if the quotes completely surround the parameter in question. +# i.e. "a=-DFOO -DBAR" works, a="-DFOO -DBAR" does not. # -# First parameter: Module to get scm type of. -# Returns: 'git' or 'svn' at this point. -sub module_scm_type +# First parameter: String to split on whitespace. +# Return value: A list of the individual words and quoted values in the string. +sub split_quoted_on_whitespace($) { - my $module = shift; + my $str = shift; + my @words = $str =~ + /\s* # Eat up whitespace + "? # Match 0-1 quotes + ( # Open grouping expression + (?getOption($option); - if ($svn_status && $git_status) { - error <getOption('source-dir'); + $dir = "$kdesrcdir/$dir"; } - return 'svn' if $svn_status; - - # If it needs a repo it's git. Everything else is svn for now. - return 'git' if $git_status; - - return 'svn'; + return $dir; } -# Subroutine used to handle the checkout-only option. It handles -# updating subdirectories of an already-checked-out module. -# -# This function can throw an exception in the event of a update failure. -# -# First parameter is the module. -# All remaining parameters are subdirectories to check out. +# Subroutine to return the name of the destination directory for the checkout +# and build routines. Based on the dest-dir option. The return value will be +# relative to the src/build dir. The user may use the '$MODULE' or '${MODULE}' +# sequences, which will be replaced by the name of the module in question. # -# Returns the number of files changed by the update, or undef if unable to -# be determined. -sub update_module_subdirectories +# The first parameter should be the Module. +# The second parameter is optional, but if provided will be used as the base +# path to replace $MODULE entries in dest-dir. +sub get_dest_dir { - my $module = shift; - my $numChanged = 0; + my $module = assert_isa(shift, 'Module'); + my $dest_dir = $module->getOption('dest-dir'); + my $basePath = shift // $module->getOption('#xml-full-path'); + $basePath ||= $module->name(); # Default if not provided in XML - # If we have elements in @path, download them now - for my $dir (@_) - { - info "\tUpdating g[$dir]"; + $dest_dir =~ s/(\${MODULE})|(\$MODULE\b)/$basePath/g; - my $logname = $dir; - $logname =~ tr{/}{-}; - - my $count = run_svn($module, "svn-up-$logname", [ 'svn', 'up', $dir ]); - $numChanged = undef unless defined $count; - $numChanged += $count if defined $numChanged; - } - - return $numChanged; + return $dest_dir; } -# Returns true if a module has a base component to their name (e.g. KDE/, -# extragear/, or playground). Note that modules that aren't in trunk/KDE -# don't necessary meet this criteria (e.g. kdereview is a module itself). -sub has_base_module +# This function returns true if the give module uses CMake. If the user has +# specified a choice, we use the user's choice regardless for now. If no user +# choice is given, auto-detect based on searching for filenames. +# +# First parameter: Module to check. +# Return: True (non-zero) if user has chosen cmake or CMake support is detected, +# False (0, undef) if user does not want cmake or no CMake support is detected. +sub module_uses_cmake { - my $module = shift; + my $module = assert_isa(shift, 'Module'); - return $module =~ /^(extragear|playground|KDE)(\/[^\/]+)?$/; -} + my $srcdir = $module->fullpath('source'); + return 1 if -e "$srcdir/CMakeLists.txt"; -# Subroutine to return the directory that a module will be stored in. -# NOTE: The return value is a hash. The key 'module' will return the final -# module name, the key 'path' will return the full path to the module. The -# key 'fullpath' will return their concatenation. -# For example, with $module == 'KDE/kdelibs', and no change in the dest-dir -# option, you'd get something like: -# { -# 'path' => '/home/user/kdesrc/KDE', -# 'module' => 'kdelibs', -# 'fullpath' => '/home/user/kdesrc/KDE/kdelibs' -# } -# If dest-dir were changed to e.g. extragear-multimedia, you'd get: -# { -# 'path' => '/home/user/kdesrc', -# 'module' => 'extragear-multimedia', -# 'fullpath' => '/home/user/kdesrc/extragear-multimedia' -# } -# First parameter is the module. -# Second parameter is either source or build. -sub get_module_path_dir -{ - my $module = shift; - my $type = shift; - my $destdir = get_dest_dir($module); - my $srcbase = get_source_dir($module); - $srcbase = get_build_dir($module) if $type eq 'build'; + # Kind of a hack but it beats inventing a sequence of checks that happens + # to get it right: just hardcode in the module that is the exception to the + # rule. - my $combined = "$srcbase/$destdir"; + return 1 if $module->name() =~ /^l10n-kde4\/?/; - # Remove dup // - $combined =~ s/\/+/\//; + # No CMakeLists? Expected for qt-copy + return 0 if $module->name() eq 'qt-copy'; - my @parts = split(/\//, $combined); - my %result = (); - $result{'module'} = pop @parts; - $result{'path'} = join('/', @parts); - $result{'fullpath'} = "$result{path}/$result{module}"; + # No CMakeLists.txt found, if the directory existed don't use CMake, + # otherwise assume we are using CMake for now. - return %result; + return not -e $srcdir; } -sub get_fullpath +# Convenience subroutine to get the source root dir. +sub get_source_dir { - my ($module, $type) = @_; - my %pathinfo = get_module_path_dir($module, $type); - - return $pathinfo{'fullpath'}; + my $module = assert_isa(shift, 'Module'); + return get_subdir_path ($module, 'source-dir'); } -# This subroutine downloads the specified file from a host, and saves it to the -# given filename. +# Subroutine to return the branch prefix. i.e. the part before the branch name +# and module name. # -# First parameter: Hostname of the server (i.e. kdesrc-build.kde.org) -# Second parameter: Path of the file on the host (i.e. /files/blah.tbz2) -# Third parameter: Filename to save as (i.e. $ENV{HOME}/blah.tbz2) -# Fourth parameter: Reference to hash used to record if a redirection occurred, -# and how many redirections have already been attempted. -# See download_file() -# Return value is 0 for failure, non-zero for success. -sub download_http_file +# The first parameter is the module name in question. +# The second parameter should be 'branches' if we're dealing with a branch or +# 'tags' if we're dealing with a tag. +# +# Ex: 'kdelibs' => 'branches/KDE' +# 'kdevelop' => 'branches/kdevelop' +sub branch_prefix { - my ($host, $path, $filename, $info) = @_; - - return 0 unless has_Net_HTTP(); - my $conn = Net::HTTP->new (Host => $host); - - if (not defined $conn) - { - error "Unable to connect to snapshot host: r[$@]"; - - return 0; - } - - debug "Checking for $path"; - - # Send connection request - $conn->write_request('GET' => "$path", - 'User-Agent' => "Mozilla/5.0 (compatible; kdesrc-build $versionNum)", - ); - - my ($code, $msg, %h) = $conn->read_response_headers(); - - # Try to handle redirections. We handle them all pretty much the same, - # i.e. if the Location response is present use that, otherwise error out. - while (int $code / 100 == 3) - { - $info->{'redir_count'}++; - $conn->close(); # Error or not, we're done with this connection. - - if (not $h{'Location'}) - { - error "Unable to download file r[$path], ambiguous redirection."; - return 0; - } - - my $destination = $h{'Location'}; - $destination =~ s/^Location:\s*//; - $info->{'redirection'} = $destination; - return 0; - } - - if (200 != $code) - { - error "Unable to download file r[$path]:\n\tr[b[$msg]"; - - $conn->close(); - return 0; - } - - open OUTPUT, ">$filename" or do { - error "Unable to open output file for r[$path] download."; - error "\tMessage: b[r[$@]"; + my $moduleName = shift; + my $type = shift; - $conn->close(); - return 0; - }; + # These modules seem to have their own subdir in /tags. + my @tag_components = qw/arts koffice amarok kst qt taglib/; - my ($buf, $result); - while (1) - { - $result = $conn->read_entity_body($buf, 2048); - if (not defined $result) - { - error "Error downloading from host: r[$!]"; + # The map call adds the kde prefix to the module names because I don't feel + # like typing them all in. + my @kde_module_list = ((map {'kde' . $_} qw/accessibility + addons admin artwork base bindings edu games graphics libs + multimedia network pim pimlibs plasma-addons sdk toys utils webdev/)); - $conn->close(); - close OUTPUT; - safe_unlink($filename); + # If the user already has the module in the form KDE/foo, it's already + # done. + return "$type/KDE" if $moduleName =~ /^KDE\//; - return 0; - } + # KDE proper modules seem to use this pattern. + return "$type/KDE" if list_has(@kde_module_list, $moduleName); - last unless $result; # Break loop if end-of-data - print OUTPUT $buf; # Print downloaded data to file. - } + # KDE extragear / playground modules use this pattern + return "$type" if has_base_module($moduleName); - close OUTPUT; - $conn->close(); + # If we doing a tag just return 'tags' because the next part is the actual + # tag name, which is added by the caller, unless the module has its own + # subdirectory in /tags. + return "$type" if $type eq 'tags' and not list_has(@tag_components, $moduleName); - return 1; + # Everything else. + return "$type/$moduleName"; } -# This subroutine downloads the file pointed to by the URL given in the first -# parameter, saving to the given filename. (FILENAME, not directory). -# -# First parameter: FTP Host. (i.e. ftp.kde.org) -# Second parameter: Path to file, including file name (i.e. /pub/unstable/foo.tbz2) -# Third parameter: Filename to save as (i.e. $ENV{HOME}/blah.tbz2) -# Return value is 0 for failure, non-zero for success. -sub download_ftp_file +# Subroutine to return a module URL for a module using the 'branch' option. +# First parameter is the module in question. +# Second parameter is the type ('tags' or 'branches') +sub handle_branch_tag_option { - my ($host, $path, $filename) = @_; - - # Detect Net::FTP. - my $ftp; - eval { - require Net::FTP; - } or do { - error " y[*] Can't open y[b[Net::FTP] module, skipping check of g[ftp.kde.org]."; - debug "Error was $@"; - return 0; - }; - - $ftp = new Net::FTP($host, Timeout => 30); + my $module = assert_isa(shift, 'Module'); + my $type = shift; + my $branch = branch_prefix($module->name(), $type); + my $svn_server = $module->getOption('svn-server'); + my $branchname = $module->getOption($type eq 'branches' ? 'branch' : 'tag'); - if (not $ftp) - { - error "Unable to connect to snapshot host $host: r[$@]"; - return 0; - } + # qt-copy is referred to as qt in svn when dealing with branches and tags. + $branch = branch_prefix('qt', $type) if $module->name() eq 'qt-copy'; - if (not $ftp->login()) - { - error "Connection refused to FTP host r[$host], skipping snapshot."; - error "FTP response: $ftp->message"; - return 0; - } + # Remove trailing slashes. + $svn_server =~ s/\/*$//; - $ftp->binary(); # Switch to binary mode. + # Remove KDE/ prefix for module name. + my $moduleName = moduleBaseName($module->name()); - # Check if file exists. - my $size = $ftp->size($path); - if (not $size or $size <= 0) - { - $ftp->quit(); - return 0; - } + # KDE modules have a different module naming scheme than the rest it seems. + return "$svn_server/$branch/$branchname/$moduleName" if $branch =~ /\/KDE\/?$/; - if (not defined $ftp->get($path, $filename)) - { - # Download failed. - error "Unable to download snapshot from r[$host]."; - return 0; + # Non-trunk translations happen in a single branch. Assume all non-trunk + # global branches are intended for the stable translations. + if ($moduleName =~ /^l10n-kde4\/?/ && $branch ne 'trunk') { + return "$svn_server/branches/stable/$moduleName"; } - $ftp->quit(); - return 1; + # Otherwise don't append the module name by default since it makes more + # sense to branch this way in many situations (i.e. kdesupport tags, phonon) + return "$svn_server/$branch/$branchname"; } -# This subroutine downloads the file pointed to by the URL given in the first -# parameter, saving to the given filename. (FILENAME, not directory). HTTP -# and FTP are supported, depending on if the required Net::HTTP and Net::FTP -# modules are available. +# Subroutine to return the appropriate SVN URL for a given module, based on +# the user settings. For example, 'kdelibs' -> https://svn.kde.org/home/kde/trunk/KDE/kdelibs # -# First parameter: URL of link to download (i.e. http://kdesrc-build.kde.org/foo.tbz2) -# Second parameter: Filename to save as (i.e. $ENV{HOME}/blah.tbz2) -# Return value is 0 for failure, non-zero for success. -sub download_file +# This operates under a double hierarchy: +# 1. If any module-specific option is present, it wins. +# 2. If only global options are present, the order override-url, tag, branch, module-base-path, +# is preferred. +sub svn_module_url { - my $url = shift; - my $filename = shift; - - if (pretending) - { - pretend "Would have downloaded g[$url]\n\tto g[$filename]"; - return 1; - } + my $module = assert_isa(shift, 'Module'); + my $svn_server = $module->getOption('svn-server'); + my $modulePath; - my ($protocol, $host, $path); - my $info = { 'redir_count' => 0, 'redirection' => '' }; + foreach my $levelLimit ('module', 'allow-inherit') { + $modulePath = $module->getOption('module-base-path', $levelLimit); - while ($info->{'redir_count'} < 5) - { - ($protocol, $host, $path) = ($url =~ m{^([^:]+)://([^/]+)(/.*)$}); - if (not defined $url or not defined $host or not defined $path) + # Allow user to override normal processing of the module in a few ways, + # to make it easier to still be able to use kdesrc-build even when I + # can't be there to manually update every little special case. + if($module->getOption('override-url', $levelLimit)) { - error "Trying to download file from invalid URL: r[$url]"; - return 0; + return $module->getOption('override-url', $levelLimit); } - $info->{'redirection'} = ''; - - # Not sure if https works but no harm in letting it try. - if ($protocol =~ /^https?$/) + if($module->getOption('tag', $levelLimit)) { - whisper "Downloading g[$path] from g[$url]"; - my $result = download_http_file($host, $path, $filename, $info); - - if (not $result and $info->{'redirection'}) - { - # Try again at new URL. - $url = $info->{'redirection'}; - whisper "Redirecting to y[$url]"; - next; - } - else - { - return $result; - } - } - elsif ($protocol eq 'ftp') - { - whisper "Downloading g[$path] from g[$url]"; - return download_ftp_file($host, $path, $filename); + return handle_branch_tag_option($module, 'tags'); } - else + + my $branch = $module->getOption('branch', $levelLimit); + if($branch and $branch ne 'trunk') { - error "Trying to download file ($url), but"; - error "\tthe r[$protocol] protocol is unsupported."; - return 0; + return handle_branch_tag_option($module, 'branches'); } - } - return 0; -} + my $moduleName = moduleBaseName($module->name()); -# This subroutine is used to try and download a Subversion checkout snapshot -# for a given module. Modules that have branches or tags associated with them -# are not attempted. -# -# If available the snapshot is downloaded and installed into the normal -# location for a kdesrc-build source checkout and already switched into the -# correct svn-server setting. -# -# The first parameter is the module to download. -# Return value is boolean true if successful, false otherwise. -sub install_module_snapshot -{ - my $module = shift; - - whisper "Finding snapshot for g[$module]"; - - # Don't bother with snapshot if the user has their own URL picked out. - if (get_option($module, 'override-url') or - get_option($module, 'module-base-path') or - module_scm_type($module) eq 'git') - { - return 0; - } - - my $moduleName = moduleBaseName($module); # KDE/kdelibs -> kdelibs - - # The branch for the module is the tag option if specified, otherwise the - # branch option if specified. Otherwise the default branch for the - # module is selected (usually trunk, perhaps 4.3) - my $branch = get_option($module, 'tag'); - - # FIXME: This is broken for kdesupport (since it is default tags) but should magically - # work since there will be no snapshot available. - $branch = get_svn_branch($module) if not $branch; - - my ($filename, $url, $dirName); + # The following modules are in /trunk, not /trunk/KDE. There are others, + # but these are the important ones. + my @non_trunk_modules = qw(extragear kdesupport koffice icecream kde-common + playground qt-copy KDE kdereview www l10n-kde4); - # If a trunk module, try to obtain from KDE FTP first. - return 0 if ($branch ne 'trunk'); + my $module_root = $moduleName; + $module_root =~ s/\/.*//; # Remove everything after the first slash - $filename = "$moduleName-svn.tar.bz2"; - $filename =~ tr{/}{-}; # Substitute - for / - $dirName = $moduleName; + if (not $modulePath and $levelLimit eq 'allow-inherit') + { + $modulePath = "trunk/KDE/$moduleName"; + $modulePath = "trunk/$moduleName" if list_has(@non_trunk_modules, $module_root); + $modulePath =~ s/^\/*//; # Eliminate / at beginning of string. + $modulePath =~ s/\/*$//; # Likewise at the end. + } - if ($filename =~ /^(playground|extragear)-/) - { - $filename = "kde$filename"; # Conform to snapshot naming convention - $dirName = "kde$moduleName"; - $dirName =~ s{/}{-}; # Substitute here too. + last if $modulePath; } - $url = "http://download.kde.org/download.php?url=unstable/snapshots/$filename"; + # Remove trailing slashes. + $svn_server =~ s/\/*$//; - return download_module_snapshot($module, $filename, $url, $dirName); + # Note that the module name is no longer appended if module-base-path is used (i.e. + # $branch variable was set. This is a change as of version 1.8. + return "$svn_server/$modulePath"; } -# This subroutine tries to download a Subversion checkout snapshot of a given -# module (and it actually handles the downloading). If the download succeeds, -# this function will automatically arrange the extracted module to fit the -# normal kdesrc-build source layout, and take the necessary steps to restore -# the snapshot to a state as if it had just been checked out from Subversion. +# Convenience subroutine to return the build directory for a module. Use +# this instead of get_subdir_path because this special-cases modules for you, +# (if necessary). # -# The finalized Subversion checked will then have svn up run in order to -# complete the checkout. +# The returned value does not include the module name at the end (as the build +# path on disk doesn't always use the module name given in the .kdesrc-buildrc), +# so be sure to add on the module name if needed. +sub get_build_dir +{ + my $module = assert_isa(shift, 'Module'); + + return get_subdir_path($module, 'build-dir'); +} + +# Subroutine used to handle the checkout-only option. It handles +# updating subdirectories of an already-checked-out module. # -# If a failure occurs, the function will try to clean up after itself. So, -# no snapshot tarball or module directory should be present if 0 is returned. +# This function can throw an exception in the event of a update failure. # -# The first parameter is the module to download. -# The second parameter is the filename to use. -# The third parameter is the URL to download. -# The fourth parameter is the final directory name from the extracted tarball. +# First parameter is the module. +# All remaining parameters are subdirectories to check out. # -# Return value is boolean true if successful, false otherwise. -sub download_module_snapshot +# Returns the number of files changed by the update, or undef if unable to +# be determined. +sub update_module_subdirectories { - my ($module, $filename, $url, $dirName) = @_; - my %pathinfo = get_module_path_dir($module, 'source'); - - # We are in either the source directory or $srcdir/KDE so moduleBaseName - # is always the right directory name. - - if (pretending) - { - pretend "Would have tried downloaded snapshot for g[$module], from"; - pretend "\tb[g[$url]"; - return 0; # Assume failure since pretending. - } - - info "Downloading snapshot for g[$module]"; + my $module = assert_isa(shift, 'Module'); + my $numChanged = 0; - if (not download_file($url, $filename)) + # If we have elements in @path, download them now + for my $dir (@_) { - error "Unable to download snapshot for module r[$module]"; - return 0; - } - - info "\tDownload complete for g[$module], completing snapshot."; - - # Now extract the newly downloaded file. First decompress it. (Don't - # use the j flag as it doesn't appear to be portable. - my $result = safe_system('bunzip2', $filename); - if($result) { # failure - error "Unable to decompress snapshot for r[$module]: $!"; - - # Clean up the probably defective snapshot. - safe_unlink($filename); - - return 0; - } - - # The file doesn't end in .bz2 anymore. - $filename =~ s/\.bz2$//; - - # Extract the file. - $result = safe_system("tar", "xf", $filename); - my $savedError = $!; # Make sure safe_unlink doesn't overwrite. - - # Snapshot file is no longer necessary. - safe_unlink($filename); - - if($result) { # failure - error "Unable to extract snapshot for r[$module]: $savedError"; - - # Remove any created portions of the module tree. - safe_rmtree($dirName); - - return 0; - } - - whisper "\tExtracted directory for g[$module]"; + info "\tUpdating g[$dir]"; - # The extracted directory is possibly of a weird form, move it to the - # correct name (just $pathinfo{'module'}); - if($dirName ne $pathinfo{'module'} and not safe_rename($dirName, $pathinfo{'module'})) { - error "Unable to move directory for r[$module] into place: r[$!]"; - - # Remove any created portions of the module tree. - safe_rmtree($dirName); - safe_rmtree($pathinfo{'module'}); + my $logname = $dir; + $logname =~ tr{/}{-}; - return 0; + my $count = run_svn($module, "svn-up-$logname", [ 'svn', 'up', $dir ]); + $numChanged = undef unless defined $count; + $numChanged += $count if defined $numChanged; } - whisper "\tg[$module] snapshot is in place."; + return $numChanged; +} - # Module in place, now prepare it for checkout. - p_chdir($pathinfo{'module'}); +# Returns true if a module has a base component to their name (e.g. KDE/, +# extragear/, or playground). Note that modules that aren't in trunk/KDE +# don't necessary meet this criteria (e.g. kdereview is a module itself). +sub has_base_module +{ + my $moduleName = shift; - # Switch svn host to proper host. - my $svnHost = get_option($module, 'svn-server'); - my $curSvnHost = get_repo_url($module); - $curSvnHost =~ s/\/home\/kde.*$/\/home\/kde/; # Remove stuff after /home/kde + return $moduleName =~ /^(extragear|playground|KDE)(\/[^\/]+)?$/; +} - info "\tFinalizing Subversion information for g[$module]"; +# Moves the directory given by the first parameter to be at the directory given +# by the second parameter, but only if the first exists and the second doesn't. +# The use case is to automatically migrate source and build directories from +# the change in dest-dir handling for XML-based modules. +sub moveOldDirectories +{ + my ($oldDir, $newDir) = @_; + state $pretendedMoves = { }; - # Set svn snapshot to update from the correct svn host instead of the default - # anonsvn (if different). - if($svnHost ne $curSvnHost) - { - $result = log_command($module, 'svn-snapshot-switch', - ['svn', 'switch', '--relocate', $curSvnHost, $svnHost]); + # All this pretended move stuff is just to avoid tons of debug output + # if run in pretend mode while still showing the message the first time. + $pretendedMoves->{$oldDir} //= { }; + if (!$pretendedMoves->{$oldDir}->{$newDir} && -e $oldDir && ! -e $newDir) { + info "\tMoving old kdesrc-build directory at\n\t\tb[$oldDir] to\n\t\tb[$newDir]"; - if($result) - { - error "Unable to switch snapshot Subversion source to the KDE Subversion server!"; - error "\tr[$!]"; + $pretendedMoves->{$oldDir}->{$newDir} = 1 if pretending; + safe_system('mv', $oldDir, $newDir) == 0 or + die "Unable to move directory $oldDir to $newDir"; + } - # Remove any created portions of the module tree. - p_chdir($pathinfo{'path'}); - safe_rmtree($pathinfo{'module'}); + return 1; +} - return 0; - } - } - else - { - debug "Skipping svn switch step, it is unnecessary."; - } +# Subroutine to return the directory that a module will be stored in. +# NOTE: The return value is a hash. The key 'module' will return the final +# module name, the key 'path' will return the full path to the module. The +# key 'fullpath' will return their concatenation. +# For example, with $module == 'KDE/kdelibs', and no change in the dest-dir +# option, you'd get something like: +# { +# 'path' => '/home/user/kdesrc/KDE', +# 'module' => 'kdelibs', +# 'fullpath' => '/home/user/kdesrc/KDE/kdelibs' +# } +# If dest-dir were changed to e.g. extragear-multimedia, you'd get: +# { +# 'path' => '/home/user/kdesrc', +# 'module' => 'extragear-multimedia', +# 'fullpath' => '/home/user/kdesrc/extragear-multimedia' +# } +# First parameter is the module. +# Second parameter is either source or build. +sub get_module_path_dir +{ + my $module = assert_isa(shift, 'Module'); + my $type = shift; + my $destdir = get_dest_dir($module); + my $srcbase = get_source_dir($module); + $srcbase = get_build_dir($module) if $type eq 'build'; - whisper "\tRestoring module file layout to normal."; + my $combined = "$srcbase/$destdir"; - # Finally, restore the file structure. - $result = log_command($module, 'svn-restore-checkout', - [ 'svn', 'revert', '-R', '.' ]); + # Remove dup // + $combined =~ s/\/+/\//; - if($result) - { - error "Unable to restore standard Subversion layout!"; + my @parts = split(/\//, $combined); + my %result = (); + $result{'module'} = pop @parts; + $result{'path'} = join('/', @parts); + $result{'fullpath'} = "$result{path}/$result{module}"; - # Remove any created portions of the module tree. - p_chdir($pathinfo{'path'}); - safe_rmtree($pathinfo{'module'}); + my $compatDestDir = get_dest_dir($module, $module->name()); + my $fullCompatPath = "$srcbase/$compatDestDir"; - return 0; + # kdesrc-build 1.14 changed the source directory layout to be more + # compatible with the sharply-growing number of modules. + if ($fullCompatPath ne $combined && -d $fullCompatPath) { + if ($type eq 'source') { + super_mkdir($result{'path'}); + moveOldDirectories($fullCompatPath, $combined); + } + elsif ($type eq 'build') { + # CMake doesn't like moving build directories, just destroy the + # old one. + state %warnedFor; + + if (!$warnedFor{$fullCompatPath}) { + $warnedFor{$fullCompatPath} = 1; + + safe_rmtree($fullCompatPath) or do { + warning("\tUnable to remove the old build directory for y[b[$module]"); + warning("\tThe disk layout has changed, you no longer need the old directory at"); + warning("\t\tb[$fullCompatPath]"); + warning("\tHowever you will have to delete it, kdesrc-build was unable to."); + } + }; + } } - info "Snapshot checkout complete, g[$module] at snapshot's revision."; - info "\nCompleting checkout by updating g[$module]"; + return %result; +} - $result = log_command($module, 'svn-first-up', ['svn', 'up']); - if($result) - { - error "Unable to update module r[$module] to latest code. The module"; - error "is correctly checked-out however, so it may be possible to try"; - error "again later."; +# This subroutine downloads the file pointed to by the URL given in the first +# parameter, saving to the given filename. (FILENAME, not directory). HTTP +# and FTP are supported, but this functionality requires libwww-perl +# +# First parameter: URL of link to download (i.e. http://kdesrc-build.kde.org/foo.tbz2) +# Second parameter: Filename to save as (i.e. $ENV{HOME}/blah.tbz2) +# Return value is 0 for failure, non-zero for success. +sub download_file +{ + my $url = shift; + my $filename = shift; - # Don't delete anything here, we're close enough to being good that - # kdesrc-build should be able to fix this later. - return 1; - } + my $ua = LWP::UserAgent->new(timeout => 30); - info "Checkout complete for g[$module]!"; + # Trailing space adds the appropriate LWP info since the resolver is not + # my custom coding anymore. + $ua->agent("kdesrc-build $versionNum "); + + whisper "Downloading g[$filename] from g[$url]"; + my $response = $ua->get($url, ':content_file' => $filename); + return 1 if $response->is_success; - return 1; + error "Failed to download y[b[$url] to b[$filename]"; + error "Result was: y[b[" . $response->status_line . "]"; + return 0; } # This subroutine is responsible for stripping the KDE/ part from the beginning @@ -2007,10 +2355,10 @@ # strip KDE/ everywhere. sub moduleBaseName { - my $module = shift; - $module =~ s/^KDE\///; + my $moduleName = shift; + $moduleName =~ s/^KDE\///; - return $module; + return $moduleName; } # Returns the user-selected branch for the given module, or 'master' if no @@ -2019,8 +2367,8 @@ # First parameter is the module name. sub get_git_branch { - my $module = shift; - my $branch = get_option($module, 'branch'); + my $module = assert_isa(shift, 'Module'); + my $branch = $module->getOption('branch'); $branch = 'master' unless $branch; return $branch; @@ -2029,11 +2377,11 @@ # Returns the current sha1 of the given git "commit-ish". sub git_commit_id { - my $module = shift; + my $module = assert_isa(shift, 'Module'); my $commit = shift; $commit = 'HEAD' unless $commit; - my $gitdir = get_fullpath($module, 'source-dir') . '/.git'; + my $gitdir = $module->fullpath('source') . '/.git'; # Note that the --git-dir must come before the git command itself. my ($id, undef) = slurp_program_output( @@ -2062,21 +2410,82 @@ return $count; } -# Returns the first valid value among the following (for the given module, -# assumed to be a Subversion module): -# 1. User's selected branch option -# 2. Default branch option (if non-empty) -# 3. 'trunk' +# Attempts to download and install a git snapshot for the given Module. This +# requires the module to have the '#snapshot-tarball' option set, normally +# done after KDEXMLReader is used to parse the projects.kde.org XML database. +# This function should be called with the current directory set to the be +# the source directory. # -# First parameter is the module name. -sub get_svn_branch +# After installing the tarball, an immediate git pull will be run to put the +# module up-to-date. The branch is not updated however! +# +# The user can cause this function to fail by setting the disable-snapshots +# option for the module (either at the command line or in the rc file). +# +# First and only parameter is the Module to install the snapshot for. +# +# Returns boolean true on success, false otherwise. +sub installGitSnapshot { - my $module = shift; - my $branch = get_option($module, 'branch'); - $branch = default_module_branch($module) unless $branch; - $branch = 'trunk' unless $branch; + my $module = assert_isa(shift, 'Module'); + my $tarball = $module->getOption('#snapshot-tarball'); - return $branch; + return 0 if $module->getOption('disable-snapshots'); + return 0 unless $tarball; + + if (pretending) { + pretend "\tWould have downloaded snapshot for g[$module], from"; + pretend "\tb[g[$tarball]"; + return 1; + } + + info "\tDownloading git snapshot for g[$module]"; + + my $filename = basename(URI->new($tarball)->path()); + my $tmpdir = File::Spec->tmpdir() // "/tmp"; + $filename = "$tmpdir/$filename"; # Make absolute + + if (!download_file($tarball, $filename)) { + error "Unable to download snapshot for module r[$module]"; + return 0; + } + + info "\tDownload complete, preparing module source code"; + + # It would be possible to use Archive::Tar, but it's apparently fairly + # slow. In addition we need to use -C and --strip-components (which are + # also supported in BSD tar, perhaps not Solaris) to ensure it's extracted + # in a known location. Since we're using "sufficiently good" tar programs + # we can take advantage of their auto-decompression. + my $sourceDir = $module->fullpath('source'); + super_mkdir($sourceDir); + + my $result = safe_system(qw(tar --strip-components 1 -C), + $sourceDir, '-xf', $filename); + my $savedError = $!; # Avoid interference from safe_unlink + safe_unlink ($filename); + + if ($result) { + error "Unable to extract snapshot for r[b[$module]: $savedError"; + safe_rmtree($sourceDir); + return 0; + } + + whisper "\tg[$module] snapshot is in place"; + + # Complete the preparation by running the initrepo.sh script + p_chdir($sourceDir); + $result = log_command($module, 'init-git-repo', ['/bin/sh', './initrepo.sh']); + + if ($result) { + error "Snapshot for r[$module] extracted successfully, but failed to complete initrepo.sh"; + safe_rmtree($sourceDir); + return 0; + } + + info "\tGit snapshot installed, now bringing up to date."; + $result = log_command($module, 'init-git-pull', ['git', 'pull']); + return ($result == 0); } # Perform a git clone to checkout the latest branch of a given git module @@ -2089,39 +2498,37 @@ # Returns boolean true if successful, false otherwise. sub git_clone_module { - my $module = shift; + my $module = assert_isa(shift, 'Module'); my $git_repo = shift; - my $srcdir = get_fullpath($module, 'source'); + my $srcdir = $module->fullpath('source'); my @args = ('--', $git_repo, $srcdir); # The -v forces progress output from git, which seems to work around either # a gitorious.org bug causing timeout errors after cloning large # repositories (such as qt-copy...) - unshift (@args, '-v') if $module eq 'qt-copy'; + unshift (@args, '-v') if $module->name() eq 'qt-copy'; note "Cloning g[$module]"; - my $result = log_command($module, 'git-clone', ['git', 'clone', @args]); + # Invert the result of installGitSnapshot to get a shell-style return code + # like those returned by log_command. Likewise the normal || must be a && + my $result = (!installGitSnapshot($module)) && + log_command($module, 'git-clone', ['git', 'clone', @args]); + if ($result == 0) { - set_persistent_option($module, 'git-cloned-repository', $git_repo); - } + $module->setPersistentOption('git-cloned-repository', $git_repo); - return ($result == 0); -} + my $branch = get_git_branch($module); -# Returns boolean true if the git checkout for the current source directory -# contains a specified branch name. No processing of the branch name is -# performed, so if you need to check for a remote head, use something like -# "refs/remotes/$remote/$branch". -# -# First parameter is the branch name. -sub git_has_branch -{ - my $branch = shift; + # Switch immediately to user-requested branch now. + if ($branch ne 'master') { + info "\tSwitching to branch g[$branch]"; + p_chdir($srcdir); + $result = log_command($module, 'git-checkout', + ['git', 'checkout', '-b', "origin-$branch", "origin/$branch"]); + } + } - # system() is used instead of safe_system since we'd like pretend output - # to reflect reality. - my $result = system(qw(git show-ref --verify --quiet), $branch); return ($result == 0); } @@ -2155,6 +2562,7 @@ sub git_get_best_remote_names { my $repoUrl = shift; + $repoUrl =~ s,^kde:,git://anongit.kde.org/,; my @outputs; # The Repo URL isn't much good, let's find a remote name to use it with. @@ -2179,6 +2587,9 @@ $remoteName =~ s/^remote\.//; $remoteName =~ s/\.url$//; # Extract the cruft + $url =~ s,^kde:,git://anongit.kde.org/,; + #info "\tgit_get_best_remote_names($repoUrl) - $remoteName = $url"; + # Skip other remotes next if $url ne $repoUrl; @@ -2186,6 +2597,7 @@ next if $remoteName !~ /^[\w-]*$/; # A winner is this one. + #info "\tWinner: $remoteName"; push @results, $remoteName; } @@ -2214,7 +2626,7 @@ # Don't call this function unless you've already checked that a suitable # remote-tracking branch doesn't exist. # -# First parameter: The module being worked on. +# First parameter: The Module being worked on. # Second parameter: A *reference* to a list of remote names (all pointing to # the same repository) which are valid. # Third parameter: The name of the remote head we need to make a branch name @@ -2223,7 +2635,7 @@ # name can be generated. sub git_make_branchname { - my $module = shift; + my $module = assert_isa(shift, 'Module'); my $remoteNamesRef = shift; my $branch = shift; my $chosenName; @@ -2239,22 +2651,23 @@ return "origin-$branch"; } -# This subroutine finds an existing remote-tracking branch name for the given repository's -# named remote. For instance if the user was using the local remote-tracking branch -# called 'qt-stable' to track kde-qt's master branch, this subroutine would return the -# branchname 'qt-stable' when passed kde-qt and 'master'. +# This subroutine finds an existing remote-tracking branch name for the given +# repository's named remote. For instance if the user was using the local +# remote-tracking branch called 'qt-stable' to track kde-qt's master branch, +# this subroutine would return the branchname 'qt-stable' when passed kde-qt +# and 'master'. # -# First parameter: The module we are working on. -# Second parameter: A *reference* to a list of remote names to check against. +# The current directory must be the source directory of the git module. +# +# First parameter : A *reference* to a list of remote names to check against. # It is important that this list all really point against the # same repository URL however. (See # git_get_best_remote_names) -# Third parameter: The remote head name to find a local branch for. +# Second parameter: The remote head name to find a local branch for. # Returns: Empty string if no match is found, or the name of the local remote-tracking # branch if one exists. sub git_get_remote_branchname { - my $module = shift; my $remoteNamesRef = shift; my $branchName = shift; @@ -2302,7 +2715,7 @@ # exceptions being thrown however. sub git_stash_and_update { - my $module = shift; + my $module = assert_isa(shift, 'Module'); my $date = strftime ("%F-%R", gmtime()); # ISO Date, hh:mm time # To find out if we should stash, we just use git diff --quiet, twice to @@ -2389,10 +2802,10 @@ # returned only via exceptions because of this. sub git_update_module { - my $module = shift; - my $srcdir = get_fullpath($module, 'source'); - my $old_repo = get_persistent_option($module, 'git-cloned-repository'); - my $cur_repo = get_option($module, 'repository'); + my $module = assert_isa(shift, 'Module'); + my $srcdir = $module->fullpath('source'); + my $old_repo = $module->getPersistentOption('git-cloned-repository'); + my $cur_repo = $module->getOption('repository'); my $branch = get_git_branch($module); my $remoteName = GIT_REMOTE_ALIAS; my $result; @@ -2432,14 +2845,14 @@ note " y[b[*]\tAttempting to perform the switch"; # Update what we think is the current repository on-disk. - set_persistent_option($module, 'git-cloned-repository', $cur_repo); + $module->setPersistentOption('git-cloned-repository', $cur_repo); } # Download updated objects # This also updates remote heads so do this before we start comparing branches # and such, even though we will later use git pull. if (0 != log_command($module, 'git-fetch', ['git', 'fetch', $remoteName])) { - die "Unable to perform git fetch or $remoteName, which should be $cur_repo"; + die "Unable to perform git fetch for $remoteName, which should be $cur_repo"; } # The 'branch' option requests a given head in the user's selected @@ -2449,7 +2862,7 @@ # to find a matching SHA1. Any local branches that are found must also be # remote-tracking. If this is all true we just re-use that branch, # otherwise we create our own remote-tracking branch. - my $branchName = git_get_remote_branchname($module, \@remoteNames, $branch); + my $branchName = git_get_remote_branchname(\@remoteNames, $branch); if (not $branchName) { my $newName = git_make_branchname($module, \@remoteNames, $branch); @@ -2489,15 +2902,50 @@ # Returns the number of files updated (actually it just returns 0 now, but maybe someday) sub update_module_git_checkout { - my $module = shift; - my $srcdir = get_fullpath($module, 'source'); + my $module = assert_isa(shift, 'Module'); + my $srcdir = $module->fullpath('source'); - if (-e $srcdir) { + if (-d "$srcdir/.git") { # Note that this function will throw an exception on failure. return git_update_module($module); } else { - my $git_repo = get_option($module, 'repository'); + # Check if an existing source directory is there somehow. + if (-e "$srcdir") { + if ($module->getOption('#delete-my-patches')) { + warning "\tRemoving conflicting source directory ", + "as allowed by --delete-my-patches"; + warning "\tRemoving b[$srcdir]"; + safe_rmtree($srcdir) or do { + die "Unable to delete r[b[$srcdir]!"; + }; + } + else { + error <getOption('repository'); if (not $git_repo) { die "Unable to checkout $module, you must specify a repository to use."; @@ -2525,6 +2973,7 @@ sub checkout_module_path { my ($module, @path) = @_; + assert_isa($module, 'Module'); my %pathinfo = get_module_path_dir($module, 'source'); my @args; @@ -2535,18 +2984,6 @@ p_chdir ($pathinfo{'path'}); - # First let's see if we have a snapshot checkout available. If so, it - # would probably be quicker to use it. - if (not scalar @path and not get_option($module, 'disable-snapshot')) - { - if(install_module_snapshot($module)) - { - whisper "Snapshot checkout successful!"; - # Success, no need to continue on this route. - return undef; - } - } - my $svn_url = svn_module_url($module); my $modulename = $pathinfo{'module'}; # i.e. kdelibs for KDE/kdelibs as $module @@ -2578,13 +3015,12 @@ sub update_module_path { my ($module, @path) = @_; - my $fullpath = get_fullpath($module, 'source'); + assert_isa($module, 'Module'); + my $fullpath = $module->fullpath('source'); my @args; p_chdir ($fullpath); - eval { plugin_update_module_path($module); }; - push @args, ('svn', 'up', '--non-interactive'); push @args, '-N' if scalar @path; @@ -2706,7 +3142,7 @@ # Subroutine to run a command, optionally filtering on the output of the child # command. # -# First parameter is the name of the module being built (for logging purposes +# First parameter is the module object being built (for logging purposes # and such). # Second parameter is the name of the log file to use (relative to the log # directory). @@ -2729,18 +3165,13 @@ sub log_command { my ($module, $filename, $argRef, $callbackRef) = @_; + assert_isa($module, 'Module'); my $pid; my @command = @{$argRef}; - my $logdir = get_log_dir($module); + my $logdir = $module->getLogDir(); debug "log_command(): Module $module, Command: ", join(' ', @command); - if (pretending) - { - pretend "\tWould have run g['", join ("' '", @command), "'"; - return 0; - } - # Fork a child, with its stdout connected to CHILD. $pid = open(CHILD, '-|'); if ($pid) @@ -2755,6 +3186,7 @@ } else { + chomp $_; debug $_; } } @@ -2775,11 +3207,22 @@ { # Child + # Avoid calling close subroutines in more than one routine. + @main::atexit_subs = (); + # Apply altered environment variables. - whisper "Environment altered for child"; - $ENV{$_} = $ENV_VARS{$_} foreach keys %ENV_VARS; + while (my ($key, $value) = each %ENV_VARS) { + $ENV{$key} = $value; + debug "\tSetting environment variable g[$key] to g[b[$value]"; + } - if (not defined $logdir or not -e $logdir) + if (pretending) + { + pretend "\tWould have run g['", join ("' '", @command), "'"; + exit 0; + } + + if (not $logdir or not -e $logdir) { # Error creating directory for some reason. error "\tLogging to std out due to failure creating log dir."; @@ -2793,7 +3236,7 @@ # other commands will fail instead of hanging at the terminal. As it stands, it can still # be canceled using an exported env var just in case. - open (STDIN, "&STDOUT") unless $command[0] eq 'svn' || $module eq 'qt-copy'; + if($command[0] ne 'svn' && $module->name() ne 'qt-copy') { + open (STDERR, ">&STDOUT"); + } # Call internal function, name given by $command[1] if($command[0] eq 'kdesrc-build') { # No colors! - ($RED, $GREEN, $YELLOW, $NORMAL, $BOLD) = ("") x 5; + ksb::Debug::setColorfulOutput(0); debug "Calling $command[1]"; my $cmd = $command[1]; splice (@command, 0, 2); # Remove first two elements. no strict 'refs'; # Disable restriction on symbolic subroutines. - if (not &{$cmd}(@command)) # Call sub + if (! &{$cmd}(@command)) # Call sub { exit EINVAL; } @@ -2851,12 +3296,14 @@ # Second parameter is the filename in the log directory of the error log. sub set_error_logfile { - my ($module, $logfile) = @_; - my $logdir = get_log_dir($module); + my $module = assert_isa(shift, 'Module'); + my $logfile = shift; return unless $logfile; - set_option($module, '#error-log-file', "$logdir/$logfile"); + my $logdir = $module->getLogDir(); + + $module->setOption('#error-log-file', "$logdir/$logfile"); debug "Logfile for $module is $logfile"; # Setup symlink in the module log directory pointing to the appropriate @@ -2878,8 +3325,7 @@ # log_command() (described here as well), except that the callback argument is # not used. # -# First parameter is the name of the module being built (for logging purposes -# and such). +# First parameter is the Module being built (for logging purposes and such). # Second parameter is the name of the log file to use (relative to the log # directory). # Third parameter is a reference to an array with the command and its @@ -2889,6 +3335,7 @@ sub run_make_command { my ($module, $filename, $argRef) = @_; + assert_isa($module, 'Module'); debug "run_make_command: $module, ", join(', ', @{$argRef}); @@ -2944,9 +3391,9 @@ sub is_subdir_buildable { my ($module, $dir) = @_; + assert_isa($module, 'Module'); - return 0 if $dir eq 'kalyptus' and $module eq 'kdebindings'; - return 0 if $dir eq 'scripts' and ($module eq 'l10n-kde4'); + return 0 if ($dir eq 'scripts' && ($module->name() =~ '^l10n-kde4')); return 1; } @@ -3033,20 +3480,22 @@ # Subroutine to run the make command with the arguments given by the passed # list. The first argument of the list given must be the module that we're -# making. +# making (which itself must be a Module object, not merely the name). # # Returns 0 on success, non-zero on failure (shell script style) sub safe_make (@) { my ($module, @args) = @_; - my $logdir = get_log_dir($module); - my $checkout_dirs = get_option($module, "checkout-only"); + assert_isa($module, 'Module'); + + my $logdir = $module->getLogDir(); + my $checkout_dirs = $module->getOption("checkout-only"); my @dirs = split(' ', $checkout_dirs); my $install_mode = (scalar @args > 0) && ($args[0] =~ /^(un)?install$/); my $uninstalling = $install_mode && $args[0] eq 'uninstall'; my $make; - my $opts = get_option($module, 'make-options'); + my $opts = $module->getOption('make-options'); # Non Linux systems can sometimes fail to build when GNU Make would work, # so prefer GNU Make if present, otherwise try regular make. Also, convert @@ -3084,7 +3533,7 @@ { $description = clr "g[$module]"; - my @install_cmd = split(' ', get_option ($module, 'make-install-prefix')); + my @install_cmd = split(' ', $module->getOption('make-install-prefix')); if (@install_cmd) { # Add -S option if we're running sudo and it's not already @@ -3143,7 +3592,7 @@ } } - my $builddir = get_fullpath($module, 'build') . "/$subdir"; + my $builddir = $module->fullpath('build') . "/$subdir"; $builddir =~ s/\/*$//; # Remove trailing / p_chdir ($builddir); @@ -3155,73 +3604,6 @@ return 0; } -# This function returns the default branch for a given module. Use this function whenever -# you have to deal with checking whether the user is using the default branch. -# -# If the branch option is set globally then that value is used to come up with an -# appropriate default (usually will be the same as the branch option but not always). -# -# This function may be called while parsing options for non-global modules, so -# it can only call get_option() for 'global' entries. -# -# First parameter: module to get default branch of. -# Returns: branch name. e.g. 'trunk', '4.3', 'work/make-it-cool' -sub default_module_branch -{ - # Add the appropriate branch to this hash for stable modules. Any module not listed - # here will default to global{'branch'}. - # tags/ is special as a returned module prefix as it is converted to be a - # tag internally instead of a branch. - my %branched_modules_exceptions = ( - # Don't integrate these kdesupport tags with the code near the end of this - # function as the naming conventions are actually slightly different. - '4.0' => { - 'kdesupport' => 'tags/kdesupport-for-4.1/kdesupport', # See below. - 'phonon' => '4.2', # Weird, I know. - }, - '4.1' => { - 'kdesupport' => 'tags/kdesupport-for-4.1/kdesupport', - 'phonon' => '4.2', # Weird, I know. - }, - '4.2' => { - 'kdesupport' => 'tags/kdesupport-for-4.2/kdesupport', - }, - '4.3' => { - 'kdesupport' => 'tags/kdesupport-for-4.3/kdesupport', - }, - '4.4' => { - 'kdesupport' => 'tags/kdesupport-for-4.4/kdesupport', - }, - '4.5' => { - 'kdesupport' => 'tags/kdesupport-for-4.5/kdesupport', - }, - ); - - # qr() compiles a regex for use in later matching. - my @unbranched_modules = ( qr(^extragear/), qr(^playground/), qr(^kdereview$) ); - - my $module = shift; - my $branch = get_option('global', 'branch'); - - # Using git? Default to master for now. - return 'master' if module_scm_type($module) eq 'git'; - - # If the module doesn't normally get branched there's not much we can do, so we'll just - # return the default. (We search against regexps instead of module names here) - if (scalar grep { $module =~ $_ } @unbranched_modules) - { - return ''; - } - - # Some modules have a different branch name for a given KDE version, handle that. - if (exists $branched_modules_exceptions{$branch}->{$module}) - { - return $branched_modules_exceptions{$branch}->{$module}; - } - - return $branch; -} - # Given a module name, this subroutine returns a hash with the default module # options for the module. # @@ -3230,20 +3612,18 @@ # # First parameter is the module to get options for. # -# Return is a hash reference containing the default module options, suitable -# for assignment to %package_opts. +# Return is a hash reference containing the default module options. sub default_module_options { - my $module = shift; - my $branch = default_module_branch($module); + my $moduleName = shift; my %options = ( 'set-env' => { }, ); my %module_options = ( 'qt-copy' => { - 'configure-flags' => '-qt-gif -no-phonon -dbus -nomake demos -nomake examples -fast', - 'repository' => 'git://anongit.kde.org/qt-kde', - 'branch' => 'master', + 'configure-flags' => '-no-phonon -dbus -nomake demos -nomake examples -fast', + 'repository' => 'git://anongit.kde.org/qt', + 'branch' => '4.8', }, 'strigi' => { # Until the strigi build system supports independent submodule @@ -3251,7 +3631,7 @@ 'cmake-options' => '-DSTRIGI_SYNC_SUBMODULES=TRUE', 'reconfigure' => 'true', }, - 'kdesupport' => { + 'taglib' => { 'cmake-options' => '-DWITH_ASF=TRUE -DWITH_MP4=TRUE', }, 'dbusmenu-qt' => { @@ -3259,18 +3639,11 @@ }, ); - # Hack to support default "tags" instead of default branches for kdesupport. - if ($branch =~ /^tags\//) - { - $branch =~ s/^tags\///; # Strip tags/ - $options{'tag'} = $branch; - } - - # If no specific module options just return the default - return \%options unless exists $module_options{$module}; + # If no specific moduleName options just return the default + return \%options unless exists $module_options{$moduleName}; # Otherwise merge in options (uses Perl hash slice) - my $this_module_options = $module_options{$module}; + my $this_module_options = $module_options{$moduleName}; @options{keys %{$this_module_options}} = values %{$this_module_options}; return \%options; @@ -3285,7 +3658,7 @@ return unless $val; - debug "\tWould have set g[$var]=y[$val]." if pretending; + debug "\tMarking g[$var] to be set to y[$val]."; $ENV_VARS{$var} = $val; } @@ -3297,87 +3670,25 @@ %ENV_VARS = (); } -# Display a message to the user regarding their relative lack of -# ~/.kdesrc-buildrc, and point them to some help. We will continue using a -# default set of options. -sub no_config_whine -{ - my $searched = join("\n ", @rcfiles); - my $homepage = "http://kdesrc-build.kde.org/"; - - note <<"HOME"; -Unable to open configuration file! -We looked for: - $searched - -kdesrc-build will continue using a default set of options. These options may -not apply to you, so feel free to visit the kdesrc-build homepage - -b[g[$homepage] - -and access the kdesrc-build documentation. Also the latest release package -will have a sample configuration file that you can edit to your liking. - -HOME -} - -# This subroutine assigns the appropriate options to %package_opts and the -# update and build lists to build a default set of modules. -# -# Note: Call this and you stand the risk of losing the options you're already -# set, do this only if you need to setup options for the entire list of -# default modules. -sub setup_default_modules() -{ - # TODO: Move this to the build-support git repo. - my @defaultModuleList = qw( - qt-copy automoc cagibi attica soprano polkit-qt-1 phonon - strigi kdesupport dbusmenu-qt - kdelibs akonadi kdepimlibs - kde-runtime kde-workspace kde-baseapps - konsole kate kdeplasma-addons - phonon-gstreamer phonon-vlc - kdemultimedia kdeartwork kdepim kdeutils kdegraphics kdegames - kdetoys kdeedu kdenetwork - ); - - whisper "Setting up to build ", join(', ', @defaultModuleList), " by default."; - - for my $i (@defaultModuleList) { - my $options_ref = default_module_options($i); - - # Apply default option only if option not already set. If the option - # is here at this point it's probably user defined on the command line - # or setup by kdesrc-build based on an option. - for my $key (keys %{$options_ref}) { - if (not exists $package_opts{$i}{$key}) { - $package_opts{$i}{$key} = $options_ref->{$key}; - } - } - - Module->push(Module->new($i, 'null')); - } -} - # Reads a "line" from a file. This line is stripped of comments and extraneous # whitespace. Also, backslash-continued multiple lines are merged into a single # line. # # First parameter is the reference to the filehandle to read from. # Returns the text of the line. -sub read_line +sub readNextLogicalLine { - my $fh = shift; + my $fileReader = shift; - while(<$fh>) { + while($_ = $fileReader->readLine()) { # Remove trailing newline chomp; # Replace \ followed by optional space at EOL and try again. if(s/\\\s*$//) { - $_ .= <$fh>; - redo unless eof($fh); + $_ .= $fileReader->readLine(); + redo; } s/#.*$//; # Remove comments @@ -3398,6 +3709,7 @@ # Return value is (optionname, option-value) sub split_option_value { + my $ctx = assert_isa(shift, 'ksb::BuildContext'); my $input = shift; my $optionRE = qr/\$\{([a-zA-Z0-9-]+)\}/; @@ -3425,14 +3737,9 @@ my ($sub_var_name) = ($value =~ $optionRE); while ($sub_var_name) { - my $sub_var_value = get_option('global', $sub_var_name); - - if(not $sub_var_value) - { - my $line_no = $.; - warning " *\n * WARNING: $sub_var_name is not set at line y[$line_no]\n *"; - - $sub_var_value = ''; + my $sub_var_value = $ctx->getOption($sub_var_name) || ''; + if(!$ctx->hasOption($sub_var_value)) { + warning " *\n * WARNING: $sub_var_name is not set at line y[$.]\n *"; } debug "Substituting \${$sub_var_name} with $sub_var_value"; @@ -3456,55 +3763,47 @@ # 'module' if we should expect an end module statement. sub parse_module { - my ($fh, $module) = @_; - $module = 'global' unless $module; + my ($ctx, $fileReader, $moduleName) = @_; + assert_isa($ctx, 'ksb::BuildContext'); - # Setup default options in case user specifies only module name to get it - # to build. - if (not defined $package_opts{$module}) - { - $package_opts{$module} = default_module_options($module); - } + my $rcfile = $ctx->rcFile(); + my $module = $moduleName eq 'global' ? $ctx : Module->new($ctx, $moduleName); + my $endWord = $moduleName eq 'global' ? 'global' : 'module'; + my $endRE = qr/^end\s+$endWord/; # Read in each option - while (read_line($fh)) + while ($_ = readNextLogicalLine($fileReader)) { - if($module eq 'global') - { - last if /^end\s+global/; # Stop - } - else - { - last if /^end\s+module/; # Stop - } + last if m/$endRE/; # Sanity check, make sure the section is correctly terminated if(/^(module\s|module$)/) { - error "Invalid configuration file $rcfile at line $.\nAdd an 'end module' before " . + error "Invalid configuration file $rcfile at line $.\nAdd an 'end $endWord' before " . "starting a new module.\n"; die make_exception('Config', "Invalid $rcfile"); } - my ($option, $value) = split_option_value($_); + my ($option, $value) = split_option_value($ctx, $_); # Handle special options. - if ($module eq 'global' && $option eq 'git-repository-base') { + if ($moduleName eq 'global' && $option eq 'git-repository-base') { # This will be a hash reference instead of a scalar my ($repo, $url) = ($value =~ /^([a-zA-Z0-9_-]+)\s+(.+)$/); - $value = get_option('global', $option) || { }; + $value = $ctx->getOption($option) || { }; if (!$repo || !$url) { error <<"EOF"; The y[git-repository-base] option at y[b[$rcfile:$.] requires a repository name and URL. -e.g. git-repository base kde git://anongit.kde.org/ +e.g. git-repository base y[b[kde] g[b[git://anongit.kde.org/] Use this in a "module-set" group: e.g. -module-set kde +module-set kdesupport-set + repository y[b[kde] use-modules automoc akonadi soprano attica end module-set EOF @@ -3514,8 +3813,10 @@ $value->{$repo} = $url; } - set_option($module, $option, $value); + $module->setOption($option, $value); } + + return $module; } # Tries to download the kde_projects.xml file needed to make XML module support @@ -3525,41 +3826,44 @@ # Returns 0 if the file could not be downloaded, 1 otherwise. sub ensure_projects_xml_present { - my $srcdir = get_source_dir(); + my $ctx = assert_isa(shift, 'ksb::BuildContext'); + my $srcdir = get_source_dir($ctx); + my $file = "$srcdir/kde_projects.xml"; + state $cachedSuccess; - my $cached_status = get_option('global', '#cached_project_xml_check'); - if (defined $cached_status && $cached_status eq 'failed') { + # See if we've already tried to download. If we ever try to download for + # real, we end up unlinking the file if it didn't successfully complete the + # download, so we shouldn't have to worry about a corrupt XML file hanging + # out for all time. + if (defined $cachedSuccess && !$cachedSuccess) { die make_exception('Internal', "Attempted to find projects.xml after it already failed"); } - return $cached_status if $cached_status; + return 1 if $cachedSuccess; # Not previously attempted, let's make a try. super_mkdir($srcdir) unless -d "$srcdir"; - my $file = "$srcdir/kde_projects.xml"; - my $host = "projects.kde.org"; - my $path = "/kde_projects.xml"; - my $redirections = { }; + my $url = "http://projects.kde.org/kde_projects.xml"; my $result = 1; if (!pretending) { info " * Downloading projects.kde.org project database..."; - $result = download_http_file($host, $path, $file, $redirections); + $result = download_file($url, $file); } elsif (! -e $file) { note " y[*] b[ACTUALLY downloading projects.kde.org project database to make the rest]"; note " y[*] b[of the --pretend output make sense.]"; - $result = download_http_file($host, $path, $file, $redirections); + $result = download_file($url, $file); } else { info " * y[Using existing projects.kde.org project database], output may change"; info " * when database is updated next."; } - set_option('global', '#cached_project_xml_check', - $result ? 'success' : 'failed'); + $cachedSuccess = $result; if (!$result) { + unlink $file if -e $file; die make_exception('Runtime', "Unable to download kde_projects.xml for the kde-projects repository!"); } @@ -3574,17 +3878,19 @@ # Returns the expanded list of module names to include. sub parse_moduleset { - my $fh = shift; + my $ctx = assert_isa(shift, 'ksb::BuildContext'); + my $fileReader = shift; my $moduleSetName = shift || ''; - my $repoSet = get_option('global', 'git-repository-base'); + my $repoSet = $ctx->getOption('git-repository-base'); + my $rcfile = $ctx->rcFile(); my @modules; my %optionSet; # We read all options, and apply them to all modules my $startLine = $.; # For later error messages - while(read_line($fh)) { + while($_ = readNextLogicalLine($fileReader)) { last if /^end\s+module(-?set)?$/; - my ($option, $value) = split_option_value($_); + my ($option, $value) = split_option_value($ctx, $_); if ($option eq 'use-modules') { @modules = split(' ', $value); @@ -3595,28 +3901,6 @@ die make_exception('Config', 'Invalid use-modules'); } } - # TODO: Compat hack, to be removed later. - elsif ($option eq 'use-xml-modules') { - die make_exception('Config', <new($moduleName, $moduleType); + my $newModule = Module->new($ctx, $moduleName, $moduleType); $newModule->setModuleSet($moduleSetName); push @moduleList, $newModule; - if (not defined $package_opts{$moduleName}) - { - $package_opts{$moduleName} = default_module_options($moduleName); - } - - # Dump all options into the existing option hash. - @{$package_opts{$moduleName}}{keys %optionSet} = values %optionSet; + # Dump all options into the existing Module's options. + $newModule->setOption(%optionSet); # Fixup for the special repository handling if need be. if (!$usingXML && exists $optionSet{'repository'}) { $selectedRepo = $repoSet->{$optionSet{'repository'}} unless $selectedRepo; - set_option($moduleName, 'repository', $selectedRepo . $module); + $newModule->setOption('repository', $selectedRepo . $moduleName); } } @@ -3700,33 +3979,53 @@ # included in the sequence they were originally. sub expandXMLModules { + my $ctx = assert_isa(shift, 'ksb::BuildContext'); my @modules = @_; - debug "Expanding XML modules in " . join(', ', map { $_->{name} } @modules); - # Using a sub allows me to use the 'return' keyword. my $filter = sub { - debug "$_->{name} is not XML-based" unless $_->{type} eq 'proj'; + my $moduleSet = shift; - return $_ if $_->{'type'} ne 'proj'; + # Only attempt to expand out XML-based modules. + return $moduleSet if $moduleSet->type() ne 'proj'; - ensure_projects_xml_present() or + ensure_projects_xml_present($ctx) or die "kde-projects repository information could not be downloaded: $!."; - my $name = $_->{'name'}; + my $name = $moduleSet->name(); + my $srcdir = get_source_dir($ctx); + + # It's possible to match modules which are marked as inactive on + # projects.kde.org, elide those. my @xmlResults = grep { $_->{'active'} ne 'false' - } (KDEXMLReader->getModulesForProject($name)); + } (KDEXMLReader->getModulesForProject($name, $srcdir)); - # Setup module options - foreach my $xml (@xmlResults) { - debug "Module $name from module-set has XML module $xml->{name}"; - debug "\twith repository b[$xml->{repo}]"; - clone_options($name, $xml->{'name'}); - set_option($xml->{'name'}, 'repository', $xml->{'repo'}); + if (!@xmlResults) { + warning " y[b[*] Module y[$name] is apparently XML-based, but contains no\n", + "active modules to build!"; + my $count = KDEXMLReader->getModulesForProject($name, $srcdir); + if ($count > 0) { + warning "\tAlthough no active modules are available, there were\n", + "\t$count inactive modules. Perhaps the git modules are not ready?"; + } } - return map { Module->new($_->{'name'}, 'git') } (@xmlResults); + # Setup module options. This alters the results in @xmlResults. + foreach (@xmlResults) { + my $result = $_; + + # This alters the item we were looking at. + $_ = Module->new($ctx, $result->{'name'}, 'git'); + $_->cloneOptionsFrom($moduleSet); + $_->setOption('repository', $result->{'repo'}); + $_->setOption('#xml-full-path', $result->{'fullName'}); + + my $tarball = $result->{'tarball'}; + $_->setOption('#snapshot-tarball', $tarball) if $tarball; + }; + + return @xmlResults; }; return map { &$filter($_) } (@modules); @@ -3751,75 +4050,27 @@ my ($buildModuleList, $knownModules) = @_; my $filter = sub { - my $setName = $_->{name}; - return $_ if exists $package_opts{$setName}; + my $setName = $_->name(); + + # If the module name matches a read-in Module, then it's not a set. + return $_ if grep { $setName eq $_->name() } (@$knownModules); + + # XML module can only happen if forced by user on command line, allow + # it. + return $_ if $_->type() eq 'proj'; + + # Otherwise assume it's a set, replace this with all sub-modules in that + # module set. my @modulesInSet = grep { $_->moduleSet() eq $setName } (@$knownModules); - if (not @modulesInSet) { + if (!@modulesInSet) { die make_exception('Runtime', "Unknown module or module-set: $setName"); } return @modulesInSet; }; - return map { &$filter } (@$buildModuleList); -} - -# Searches for the appropriate rc file to use. The user may specify one -# using --rc-file, or otherwise the current directory is searched for -# "kdesrc-buildrc", or ~/.kdesrc-buildrc is used. Currently evil hacks are -# used for further fallbacks, but don't count on that staying that way. -# (The global @rcfiles list is used to search for the appropriate file) -# -# If --rc-file was specified but that file couldn't be found, an exception -# is raised. -# -# The global $rcfile variable is set based on the file actually found. -sub find_rcfile -{ - # The options are stored in the file $rcfile - my $success = 0; - - for my $file (@rcfiles) - { - if (open CONFIG, "<$file") - { - $success = 1; - - # rel2abs used since path for rcfile is used later in execution - # when the cwd may have changed so we need to expand path here. - $rcfile = File::Spec->rel2abs($file); - close CONFIG; # Actually read it later. - last; - } - } - - if (not $success) - { - if(scalar @rcfiles == 1) - { - # This can only happen if the user uses --rc-file, if we fail to - # load the file, we need to fail to load. - error <rcFile(); my ($option, $modulename, %readModules); + my $fileReader = RecursiveFH->new(); + $fileReader->addFilehandle($fh); + # Read in global settings - while (<$fh>) + while ($_ = $fileReader->readLine()) { s/#.*$//; # Remove comments s/^\s*//; # Remove leading whitespace @@ -3849,25 +4104,15 @@ die make_exception('Config', 'Missing global section'); } - # Now read in each global option - parse_module($fh, 'global'); + # Now read in each global option. + parse_module($ctx, $fileReader, 'global'); last; } my $using_default = 1; - if (exists $ENV{"COVERITY_RUN"}) { - - info "We're being run by coverity. ignoring non global options in the"; - info "config file"; - - close $fh; - setup_default_modules(); - return; - } - # Now read in module settings - while (<$fh>) + while ($_ = $fileReader->readLine()) { s/#.*$//; # Remove comments s/^\s*//; # Remove leading whitespace @@ -3889,31 +4134,28 @@ } # A moduleset can give us more than one module to add. - push @module_list, parse_moduleset($fh, $modulename); + push @module_list, parse_moduleset($ctx, $fileReader, $modulename); } else { - parse_module($fh, $modulename); - push @module_list, Module->new($modulename); + push @module_list, parse_module($ctx, $fileReader, $modulename); } # Don't build default modules if user has their own wishes. $using_default = 0; } - close $fh; - # All modules and their options have been read, filter out modules not # to update or build, based on the --ignore-modules option already present # on the command line. manual-update and manual-build are also relevant, # but handled in updateModulePhases. @module_list = grep { - not exists $ignore_list{$_->{name}} + not exists $ignore_list{$_->name()} } (@module_list); # If the user doesn't ask to build any modules, build a default set. # The good question is what exactly should be built, but oh well. if ($using_default) { - setup_default_modules(); + $ctx->setup_default_modules(); return (); } @@ -3926,74 +4168,37 @@ # as well. sub module_needs_builddir_help { - my $module = shift; - my @module_help_list = qw/kdebindings/; + my $module = assert_isa(shift, 'Module'); # l10n/lang needs help. - return 1 if ($module =~ /^l10n-kde4\/?/); - - # Other CMake-using modules are fine. - return 0 if module_uses_cmake($module); - - return list_has(@module_help_list, $module); + return 1 if ($module->name() =~ /^l10n-kde4\/?/); } # This subroutine reads the set-env option for a given module and initializes # the environment based on that setting. sub setup_module_environment { - my $module = shift; + my $module = assert_isa(shift, 'Module'); my ($key, $value); # Let's see if the user has set env vars to be set. - my $env_hash_ref = get_option($module, 'set-env'); + my $env_hash_ref = $module->getOption('set-env'); while (($key, $value) = each %{$env_hash_ref}) { setenv($key, $value); } } -# Sets our debugging color aliases for use at the terminal. No parameters, -# no return value. -sub set_debug_colors -{ - if(-t STDOUT and get_option('global', 'colorful-output')) - { - $RED = "\e[31m"; - $GREEN = "\e[32m"; - $YELLOW = "\e[33m"; - $NORMAL = "\e[0m"; - $BOLD = "\e[1m"; - } - else - { - ($RED, $GREEN, $YELLOW, $NORMAL, $BOLD) = ("") x 5; - } -} - -sub setup_operating_environment -{ - # Set the process priority - setpriority PRIO_PROCESS, 0, get_option('global', 'niceness'); - - # Set the IO priority if available. - if(get_option('global', 'use-idle-io-priority')) { - # -p $$ is our PID, -c3 is idle priority - # 0 return value means success - if(safe_system('ionice', '-c3', '-p', $$) != 0) { - warning " b[y[*] Unable to lower I/O priority, continuing..."; - } - } -} - # Print out an error message, and a list of modules that match that error # message. It will also display the log file name if one can be determined. # The message will be displayed all in uppercase, with PACKAGES prepended, so # all you have to do is give a descriptive message of what this list of # packages failed at doing. -sub output_failed_module_list($@) +sub output_failed_module_list { - my ($message, @fail_list) = @_; + my ($ctx, $message, @fail_list) = @_; + assert_isa($ctx, 'ksb::BuildContext'); + $message = uc $message; # Be annoying debug "Message is $message"; @@ -4006,23 +4211,23 @@ warning "\nr[b[<<< PACKAGES $message >>>]"; - for (@fail_list) + for my $module (@fail_list) { - $logfile = get_option($_, '#error-log-file'); + $logfile = $module->getOption('#error-log-file'); # async updates may cause us not to have a error log file stored. There's only # one place it should be though, take advantage of side-effect of log_command() # to find it. if (not $logfile) { - my $logdir = get_log_dir($_) . "/error.log"; + my $logdir = $module->getLogDir() . "/error.log"; $logfile = $logdir if -e $logdir; } $logfile = "No log file" unless $logfile; $logfile =~ s|$homedir|~|; - warning "r[$_]" if pretending; - warning "r[$_] - g[$logfile]" if not pretending; + warning "r[$module]" if pretending; + warning "r[$module] - g[$logfile]" if not pretending; } } } @@ -4030,28 +4235,22 @@ # This subroutine reads the fail_lists dictionary to automatically call # output_failed_module_list for all the module failures in one function # call. -sub output_failed_module_lists() +sub output_failed_module_lists { - for my $type (@fail_display_order) + my $ctx = assert_isa(shift, 'ksb::BuildContext'); + + # This list should correspond to the possible phase names (although + # it doesn't yet since the old code didn't, TODO) + for my $phase ($ctx->phases()->phases()) { - my @failures = @{$fail_lists{$type}}; - output_failed_module_list("failed to $type", @failures); + my @failures = $ctx->failedModulesInPhase($phase); + output_failed_module_list($ctx, "failed to $phase", @failures); } # See if any modules fail continuously and warn specifically for them. - my $persistent_opt = sub { - my $mod = shift; - - return ((exists $package_opts{$mod}{'persistent-options'}{'failure-count'}) and - (int $package_opts{$mod}{'persistent-options'}{'failure-count'} > 3)); - }; - - my @super_fail = grep { &{$persistent_opt}($_) }(keys %package_opts); - - # Only show packages we're actually updating/building - @super_fail = grep { - list_has(@update_list, $_) or list_has(@build_list, $_) - } (@super_fail); + my @super_fail = grep { + ($_->getPersistentOption('failure-count') // 0) > 3 + } (@{$ctx->moduleList()}); if (@super_fail) { @@ -4117,157 +4316,12 @@ my ($var, @values) = split(' ', $value); - $$href{$option} = ( ) unless exists $$href{$option}; - $$href{$option}{$var} = join(' ', @values); + ${$href}{$option} //= { }; + ${$href}{$option}->{$var} = join(' ', @values); return 1; } -# Sets the option for the given module to the given value. If the data for the -# module doesn't exist yet, it will be defined starting with a default value. -# First parameter: module to set option for (or 'global') -# Second parameter: option name (Preceded by # for a sticky option) -# Third parameter: option value -# Return value is void -sub set_option -{ - my ($module, $option, $value) = @_; - - # Set module options. To see where the warning is not a bug, go to - # read_options() where the module-specific options are set. - if (not exists $package_opts{$module}) - { - $package_opts{$module} = default_module_options($module); - } - - return if handle_set_env($package_opts{$module}, $option, $value); - - debug " Setting $module,$option = $value"; - $package_opts{$module}{$option} = $value; - - if ($option eq 'colorful-output') - { - set_debug_colors(); # Update ASAP - } -} - -# Sets a "persistent" option which will be read in for a module when kdesrc-build starts -# up and written back out at (normal) program exit. -# -# First parameter is the module to set the option for, or 'global'. -# Second parameter is the name of the value to set (i.e. key) -# Third parameter is the value to store, which must be a scalar. -sub set_persistent_option -{ - my ($module, $key, $value) = @_; - - # A reference to a hash is used in the normal package_opts hash table with the - # special key persistent-options. - if (not exists $package_opts{$module}{'persistent-options'}) - { - $package_opts{$module}{'persistent-options'} = { }; - } - - $package_opts{$module}{'persistent-options'}{$key} = $value; -} - -# Returns the value of a "persistent" option (normally read in as part of startup), or -# undef if there is no value stored. -# -# First parameter is the module to get the option for, or 'global' if not for a module. -# Note that unlike set_option/get_option, no inheritance is done at this point so if -# an option is present globally but not for a module you must check both if that's what -# you want. -# Second parameter is the name of the value to retrieve (i.e. the key) -# A scalar is always the return value. -sub get_persistent_option -{ - my ($module, $key) = @_; - - # Don't auto-vivify the value if it's not there. - return undef unless exists $package_opts{$module}{'persistent-options'}; - return undef unless exists $package_opts{$module}{'persistent-options'}{$key}; - - return $package_opts{$module}{'persistent-options'}{$key}; -} - -# Writes out the persistent options to the file .kdesrc-build-data. Note: If -# the file already exists, it is only overwritten if the file contains -# "AUTOGENERATED BY kdesrc-build" in the first line in case someone actually -# used this file name before this feature was added. -# -# The directory used is the same directory that contains the rc file in use. -sub write_persistent_options -{ - return if pretending; - - my $dir = dirname($rcfile ? $rcfile : ""); - my $fh = IO::File->new("> $dir/.kdesrc-build-data"); - - if (not defined $fh) - { - error "Unable to save persistent module data: b[r[$!]"; - return; - } - - print $fh "# AUTOGENERATED BY kdesrc-build $versionNum\n"; - - # Modules with persistent options - my @names = grep { exists $package_opts{$_}{'persistent-options'} } keys %package_opts; - - # References to the persistent hash tables. - my @refs = map { $package_opts{$_}{'persistent-options'} } @names; - - my %output; - - # This is a hash slice, it basically does $output{$names[i]} = $refs[i] for - # all entries in the lists. - @output{@names} = @refs; - - $Data::Dumper::Indent = 1; - print $fh Data::Dumper->Dump([\%output], ["persistent_options"]); -} - -# Reads in all persistent options from the file where they are kept -# (.kdesrc-build-data) for use in the program. -# -# The directory used is the same directory that contains the rc file in use. -sub read_persistent_options -{ - my $dir = dirname($rcfile ? $rcfile : ""); - my $fh = IO::File->new("<$dir/.kdesrc-build-data"); - - # Don't penalize user for name change. - $fh = IO::File->new("<$dir/.kdesvn-build-data") unless defined $fh; - return unless defined $fh; - - my $persistent_data; - { - local $/ = undef; # Read in whole file with <> operator. - $persistent_data = <$fh>; - } - - # $persistent_data should be Perl code which, when evaluated will give us - # a hash called persistent-options which we can then merge into our - # package_opts. - - my $persistent_options; - - # eval must appear after declaration of $persistent_options - eval $persistent_data; - if ($@) - { - # Failed. - error "Failed to read persistent module data: r[b[$@]"; - return; - } - - for my $key (keys %{$persistent_options}) - { - $package_opts{$key}{'persistent-options'} = ${$persistent_options}{$key}; - } -} - # Returns an array of lines output from a program. Use this only if you # expect that the output will be short. # @@ -4314,9 +4368,9 @@ # Returns the string value of the parameter or undef if an error occurred. sub get_svn_info { - my $module = shift; + my $module = assert_isa(shift, 'Module'); my $param = shift; - my $srcdir = get_fullpath($module, 'source'); + my $srcdir = $module->fullpath('source'); my $result; # Predeclare to outscope upcoming eval # Search each line of output, ignore stderr. @@ -4357,7 +4411,7 @@ # First parameter is the name of the module to examine. sub current_module_svn_revision { - my $module = shift; + my $module = assert_isa(shift, 'Module'); return get_svn_info($module, 'Revision'); } @@ -4368,60 +4422,32 @@ # First parameter is the name of the module to examine. sub current_module_revision { - my $module = shift; + my $module = assert_isa(shift, 'Module'); - if (module_scm_type($module) eq 'svn') { + if ($module->type() eq 'svn') { return current_module_svn_revision($module); } - elsif (module_scm_type($module) eq 'git') { + elsif ($module->type() eq 'git') { return git_commit_id($module); } return undef; } -# Subroutine to recursively deep copy (from a completely independent clone) -# of the modules given for module A (first parameter) to module B (second -# parameter). -# -# If options are already set for B, the function returns immediately to -# avoid overwriting already set options. -# -# No return value. -sub clone_options -{ - my ($a, $b) = @_; - - return if exists $package_opts{$b}; - - $package_opts{$b} = { 'set-env' => { } }; - - # set-env is special because it itself holds another reference. All the - # others can be copies. - for my $key (keys %{$package_opts{$a}}) - { - next if $key eq 'set-env'; - $package_opts{$b}{$key} = $package_opts{$a}{$key}; - } - - # Handle set-env options. - for my $key (keys %{$package_opts{$a}{'set-env'}}) - { - $package_opts{$b}{'set-env'}{$key} = $package_opts{$a}{'set-env'}{$key}; - } -} - # Subroutine to process the command line arguments, which should be passed as # a list. The list of module names passed on the command line will be returned, -# other options are generally entered into the 'global' option set. +# In addition, a second parameter should be passed, a reference to a hash that +# will hold options that cannot be set until the rc-file is read. +# # NOTE: One exception to the return value is that if --run is passed, the list # of options to pass to the new program is returned instead (you can tell by # evaluating the '#start-program' option. # NOTE: Don't call finish() from this routine, the lock hasn't been obtained. -# NOTE: The options have not been loaded yet either. Any option which -# requires more than rudimentary processing should set a flag for later work. sub process_arguments { + my $ctx = assert_isa(shift, 'ksb::BuildContext'); + my $pendingOptions = shift; + my $phases = $ctx->phases(); my @savedOptions = @_; # Used for --debug my @options = @_; my $arg; @@ -4445,214 +4471,182 @@ /^(-h)|(--?help)$/ && do { print < Read configuration from filename instead of default. - --nice= Allows you to run the script with a lower priority - The default value is 10 (lower priority by 10 steps). - --prefix=/kde/path This option is a shortcut to change the setting for - kdedir from the command line. It implies - --reconfigure. --resume-from= Starts building from the given package, without performing the source update. --resume-after= Starts building after the given package, without performing the source update. - --revision (or -r)= Forces update to revision from Subversion. - --refresh-build Start the build from scratch. --reconfigure Run CMake/configure again, but don't clean the build directory. --build-system-only Create the build infrastructure, but don't actually perform the build. - --run= Runs the given program in the same environment - kdesrc-build runs in. - --install Try to install the packages passed on the command - line, or all packages in ~/.kdesrc-buildrc that don't - have manual-build set. Building and source - updates are not performed. --