diff options
author | Tristan Van Berkom <tristan@upstairslabs.com> | 2013-12-17 17:23:01 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan@upstairslabs.com> | 2013-12-17 17:23:01 +0900 |
commit | 22ddb259a38c5f9554c59460489a357c275088e4 (patch) | |
tree | 159d0e25e01cbf495de70fb9563c04889b7c5a0f /build | |
parent | 1049df0b5503f224bf962663d19caed84cc72749 (diff) | |
download | glade-22ddb259a38c5f9554c59460489a357c275088e4.tar.gz |
Final touches to the bundle environment
Diffstat (limited to 'build')
-rw-r--r-- | build/linux/LibcWrapGenerator.vala | 44 | ||||
-rwxr-xr-x | build/linux/PrepareAppDir.sh | 10 | ||||
-rw-r--r-- | build/linux/README | 25 | ||||
-rw-r--r-- | build/linux/README.lfs | 352 | ||||
-rw-r--r-- | build/linux/jhbuildrc | 6 |
5 files changed, 39 insertions, 398 deletions
diff --git a/build/linux/LibcWrapGenerator.vala b/build/linux/LibcWrapGenerator.vala index a6a61752..8a3bff1e 100644 --- a/build/linux/LibcWrapGenerator.vala +++ b/build/linux/LibcWrapGenerator.vala @@ -87,7 +87,7 @@ class VersionNumber : Object else revision = 0; } catch (GLib.RegexError e) { - stdout.printf("Error compiling regular expression!"); + stdout.printf ("Error compiling regular expression: %s", e.message); Posix.exit(-1); } } @@ -128,7 +128,7 @@ public class Main : Object { private const GLib.OptionEntry[] options = { { "libdir", 'l', 0, OptionArg.FILENAME, ref libdir, "Library directory", "<DIRECTORY>" }, - { "output", 'o', 0, OptionArg.STRING, ref output, "Header to create", "<FILENAME>" }, + { "output", 'o', 0, OptionArg.STRING, ref output, "Header to create", "<FILENAME>" }, { "target", 't', 0, OptionArg.STRING, ref target, DEFAULT_TARGET_HELP, "<MAJOR.MINOR[.MICRO]>" }, { null } }; @@ -137,10 +137,12 @@ public class Main : Object { private static VersionNumber minimumVersion; private static Gee.HashMap<string, VersionNumber>symbolMap; private static Gee.HashSet<string>filterMap; - private static Regex regex; public static int main (string[] args) { + /* Initialize the default here */ + target = DEFAULT_TARGET; + try { var opt_context = new OptionContext ("- Libc compatibility header generator"); opt_context.set_help_enabled (true); @@ -164,9 +166,6 @@ public class Main : Object { return 0; } - if (target == null) - target = DEFAULT_TARGET; - /* Initialize local resources */ minimumVersion = new VersionNumber (target); @@ -182,7 +181,6 @@ public class Main : Object { stdout.printf ("Generating %s (glibc %s) from libs at '%s' .", output, minimumVersion.getString(), libdir); - regex = new Regex("(.*)(GLIBC_)([0-9]+\\.([0-9]+\\.)*[0-9]+)(\\)?)([ ]*)(.+)"); parseLibraries (); generateHeader (); @@ -197,7 +195,7 @@ public class Main : Object { return 0; } - private static void parseLibrary (FileInfo fileinfo) throws Error { + private static void parseLibrary (Regex regex, FileInfo fileinfo) throws Error { string output, errorOutput; int returnCode; @@ -267,24 +265,25 @@ public class Main : Object { private static void parseLibraries () throws Error { var libPath = File.new_for_path (libdir); var enumerator = libPath.enumerate_children (FileAttribute.STANDARD_NAME, 0, null); + var regex = new Regex ("(.*)(GLIBC_)([0-9]+\\.([0-9]+\\.)*[0-9]+)(\\)?)([ ]*)(.+)"); + var counter = 0; FileInfo fileinfo; - while ((fileinfo = enumerator.next_file(null)) != null) - { - if(++counter % 50 == 0) - { + while ((fileinfo = enumerator.next_file(null)) != null) { + + if (++counter % 50 == 0) { stdout.printf("."); stdout.flush(); } - parseLibrary (fileinfo); + parseLibrary (regex, fileinfo); } } - private static void appendSymbols (StringBuilder headerFile, bool overrides) { + private static void appendSymbols (StringBuilder headerFile, bool unavailableSymbols) { - if (overrides) + if (unavailableSymbols) headerFile.append("\n/* Symbols introduced in newer glibc versions, which must not be used */\n"); else headerFile.append("\n/* Symbols redirected to earlier glibc versions */\n"); @@ -306,13 +305,13 @@ public class Main : Object { if (version.newerThan (minimumVersion)) { versionToUse = "DONT_USE_THIS_VERSION_%s".printf (version.getString()); - if (!overrides) + if (!unavailableSymbols) continue; } else { versionToUse = version.getString (); - if (overrides) + if (unavailableSymbols) continue; } @@ -323,6 +322,13 @@ public class Main : Object { private static void generateHeader () throws Error { var headerFile = new StringBuilder (); + /* FIXME: Currently we do: + * + * if !defined (__OBJC__) && !defined (__ASSEMBLER__) + * + * But what we want is a clause which accepts any form of C including C++ and probably + * also including ObjC. That said, the generated header works fine for C and C++ sources. + */ headerFile.append ("/* glibc bindings for target ABI version glibc " + minimumVersion.getString() + " */\n"); headerFile.append ("#if !defined (__LIBC_CUSTOM_BINDINGS_H__)\n"); headerFile.append ("\n"); @@ -331,9 +337,7 @@ public class Main : Object { headerFile.append ("extern \"C\" {\n"); headerFile.append ("# endif\n"); - /* For prettier output, let's output the redirected symbols first, and - * then output the ones which must not be used (new in glibc > minimumVersion). - */ + /* First generate the available redirected symbols, then the unavailable symbols */ appendSymbols (headerFile, false); appendSymbols (headerFile, true); diff --git a/build/linux/PrepareAppDir.sh b/build/linux/PrepareAppDir.sh index e57041b7..17fd782d 100755 --- a/build/linux/PrepareAppDir.sh +++ b/build/linux/PrepareAppDir.sh @@ -17,16 +17,12 @@ # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# Usage: -# -# ./PrepareAppDir.sh /path/to/AppImage/Install /path/to/glade APP_DIR_ROOT=$1 -GLADE_DIR=$2 +BUNDLE_DIR=$2 -if test -z ${APP_DIR_ROOT} || test -z ${GLADE_DIR}; then - echo "Usage ./PrepareAppDir.sh /path/to/AppImage/Install /path/to/glade" +if test -z ${APP_DIR_ROOT} || test -z ${BUNDLE_DIR}; then + echo "Usage ./PrepareAppDir.sh /path/to/AppImage/Install /path/to/glade/build/linux" exit 0; fi diff --git a/build/linux/README b/build/linux/README index 3f10ee8c..47ed5959 100644 --- a/build/linux/README +++ b/build/linux/README @@ -87,43 +87,36 @@ this to be a "/full/path/to/the/checkout/of/glade" Building the stack ~~~~~~~~~~~~~~~~~~ - The AppDir is what AppImageKit refers to as the root filesystem inside the - bundle. - - The provided jhbuild scripts will create a directory in your ${HOME} named - 'AppImages', all of our building & bundling will take place inside this directory. - - Note, if you already have a jhbuild environment there is no need to worry, - our scripts do not interfere with your existing jhbuild environment. - To build the whole stack up to Glade, including Glade, issue this command: - GLADE_DIR=${GLADE_CHECKOUT} jhbuild -f ${GLADE_CHECKOUT}/build/linux/jhbuildrc build glade + BUNDLE_ROOT=~/GladeBundle BUNDLE_DIR=${GLADE_CHECKOUT}/build/linux jhbuild -f ${GLADE_CHECKOUT}/build/linux/jhbuildrc build - I've found the build to break sometimes at 'shared-mime-info', in this case I just rerun - the above command and it passes on the second try... nothing to see here... carry on... + This will build everything into the ${BUNDLE_ROOT} you specified, the actual installation + will be found in ${BUNDLE_ROOT}/Install + This will not interfere with any existing jhbuild environment you may already have setup, + everything is self contained and happens inside the ${BUNDLE_ROOT} you specify. Post processing the image directory ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Some post processing is needed on the AppDir, we intentionally keep this separate from the jhbuild setup. To perform the needed post processing, issue this command: - ${GLADE_CHECKOUT}/build/linux/PrepareAppDir.sh ${HOME}/AppImages/Install ${GLADE_CHECKOUT} + ${GLADE_CHECKOUT}/build/linux/PrepareAppDir.sh ${BUNDLE_ROOT}/Install ${GLADE_CHECKOUT}/build/linux - WARNING: The above script will modify the ${HOME}/AppImages/Install directory in such + WARNING: The above script will modify the ${BUNDLE_ROOT}/Install directory in such a way that it cannot be rebuilt (development headers and unneeded cruft is removed from the installation directory). This is why we use a script as a separate stage from building. - At this point, you should have a fully functional image in ${HOME}/AppImages/Install + At this point, you should have a fully functional image in ${BUNDLE_ROOT}/Install Bundling ~~~~~~~~ Build the bundle with one simple command: - /path/to/AppImageKit/AppImageAssistant ${HOME}/AppImages/Install /path/to/generated/glade + /path/to/AppImageKit/AppImageAssistant ${BUNDLE_ROOT}/Install ~/glade This will create a huge binary named 'glade' at the location of your choosing. diff --git a/build/linux/README.lfs b/build/linux/README.lfs deleted file mode 100644 index 3d68b112..00000000 --- a/build/linux/README.lfs +++ /dev/null @@ -1,352 +0,0 @@ -Instructions on how to build a bundle for 64bit linux systems. - -System requirements -~~~~~~~~~~~~~~~~~~~ - - o A 64bit linux system - - o AppImageKit (https://github.com/tristanvb/AppImageKit/) - - To build AppImageKit, you will require: - - A functional cross compiler to generate 32bit binaries as well as 64bit binaries - - libfuse (if AppImageKit doesnt find it, make sure there is a symbolic link to libfuse.so - from it's actual library, this is because AppImageKit uses CMake, which is just dumb). - - An old glib version installed on your system, the older the glib version the better - (this system glib version will be required on target hosts which want to run the bundle). - - Some other things like python, which you will just have to deal with the CMakeLists.txt - to figure out. - - o jhbuild - - You will need to build Glade and it's dependencies in a relocated environment, jhbuild is usually - a decent choice for this. - - o chrpath - - This will be required after your build root is complete, we use it to strip out the -rpaths which - libtool loves to embed into binaries. - - -Build & Bundle Instructions -~~~~~~~~~~~~~~~~~~~~~~~~~~~ -What follows here is a step by step guide to preparing your bundle, the following steps -should be completed in the order given. - - - Build AppImageKit - ~~~~~~~~~~~~~~~~~ - - Build AppImageKit in the normal way, you don't need to install it anywhere, - and make sure that you build it against your system libraries. - - DO NOT build this from inside your jhbuild shell or relocated - build environment - - To build you will run: - - cmake . - make - - Probably you will find yourself cursing a lot, forcing 'cmake .' to pass, - but this is just the nature of CMake. - - - Build relocated Glade - ~~~~~~~~~~~~~~~~~~~~~ - Use jhbuild or your own build scripts to build a properly relocated - sandbox of GTK+/Glade and it's requirements. - - This can be a long process, but if you already build Glade and GTK+ - from master, chances are that you've already done this. - - In any case of build setup you choose, the principals are the same: - - o Relocated environment, PKG_CONFIG_PATH, PATH, LD_LIBRARY_PATH - and ACLOCAL_FLAGS should all be set into your build environment to - prioritize your relocated install prefix - - o Dependencies should be built in strict order, the last dependency - must be installed into your relocated prefix before trying to - build the next dependency. - - o You don't want anything built into your relocated prefix to link - to your system libraries, however if you're not so conservative - (as I was not), you can omit the X11 libraries as well as fontconfig - and freetype libraries (and of course your C runtime libraries are fine). - - Remember that anything which links to your system libraries is - something which will try to link to the user's system libraries in - your bundle's runtime (so we can pretty much rely on X11 libs). - - - Apply patches from the patches/ subdirectory - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - There is currently one patch to force pango into not insisting - to prepend absolute paths to the relative paths we need to use - for the loading of pango modules. - - There may be more added to this subdirectory in the future. - - After applying patches, make sure that the modules in question - are built with the patches applied. - - - Make sure you've covered all of GTK+/Glade's dependencies - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - If you've used jhbuild, there is a big possibility that you are - missing dependencies. - - jhbuild tends to be lazy and relies on system libraries instead - of building them. - - Here is a full list of packages you will need (in order of dependency): - - zlib - libffi - glib - dbus - harfbuzz - pixman - cairo - pango - libpng - gdk-pixbuf - librsvg - atk - at-spi2-core - at-spi2-atk - gtk+ - gnome-themes-standard - hicolor-icon-theme - shared-mime-info - libcanberra - expat - libxml2 - glade - - Some of these are not required for GTK+ to function properly, but - are require for the theme. HOWEVER, these are all required to be be - built into your bundle. If you miss some of the modules that GTK+ loads - then GTK+ might decide to load one from the target system where the - bundle runs, which can only end in tears. - - Some dependencies might be missing in the above list, for normal operation - of Glade we only really need the png and svg gdk-pixbuf loaders, so we've - only built libpng and librsvg (but it might be prudent to include jpeg - libraries and other dependencies of gdk-pixbuf loaders). - - - Some build time exceptions to take care of - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - When building glib, you must ensure to pass '--disable-selinux' to glib's - configure script, otherwise you end up with an unneeded dependency on - the targe host for libselinux.so - - - Building into the bundle root - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Now we assume you have a functional Glade installed on your system - which links to the minimum system libraries as possible (only X11, - fontconfig and freetype). Now you must rebuild everything again. - - First create a directory which will serve as your bundle's root, - we'll refer to it from here on after as ${BUNDLE_ROOT}, we'll refer - to each dependency build directry as ${dependency}. - - It's important that you perform this step inside your relocated - build environment (for jhbuild, that means inside 'jhbuild shell'). - - For every dependency above you'll need to run these commands: - - cd ${dependency} - make clean - ./configure --prefix=/usr - make - make DESTDIR=${BUNDLE_ROOT} install - - Alternatively, for modules downloaded directly from git repositories: - - cd ${dependency} - git clean -xdf - ./autogen.sh --prefix=/usr - make - make DESTDIR=${BUNDLE_ROOT} install - - Note that for now, the libraries are built with a standard - system '/usr' prefix but we are compiling and linking against - the dependencies already installed into your relocated install - prefix. - - The important parts of this step are: - - o We clean out the existing package directories which we - already built into your relocated build environment. - - We don't want any residue here remaining from the previous build. - - o We do compile and link against the existing libraries installed - from your previous build. - - o We install using the '/usr' system prefix BUT we use the - DESTDIR standard to make the installation in ${BUNDLE_ROOT} - - During this phase, the same exceptions as above apply, i.e. libglib - must be configured with --disable-selinux (and any other customizations - you may have made there, you should make here). - - - Additional preparations for ${BUNDLE_ROOT} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Now we're getting close, but we need to do a couple more - preparations for the ${BUNDLE_ROOT} to work properly (and to run at all). - - o Add the AppRun program to the root. - - In the AppImageKit package you built at the beginning, you will find - an executable called 'AppRun'. Copy this file to the toplevel of - your ${BUNDLE_ROOT} - - o Add the AppRunScript.sh found in this directory to ${BUNDLE_ROOT} - - This script will setup the environment to run Glade based on the - ${APP_IMAGE_ROOT} which will be set in the environment when the - script is called. This script calls Glade with the arguments provided. - - o Add the glade.desktop file found in glade/data/glade.desktop to ${BUNDLE_ROOT} - - The AppImageKit uses this at bundling time to prepare it's bundle and - chose an appropriate icon to display for the executable. - - o Add the pangorc found in this directory to ${BUNDLE_ROOT} - - This will tell pango to look in the right place for it's modules - file in ${BUNDLE_ROOT}/usr/etc/pango/pango.modules - - o Generate and modify ${BUNDLE_ROOT}/usr/etc/pango/pango.modules - - Inside your relocated build environment, run the following command: - - pango-querymodules > ${BUNDLE_ROOT}/usr/etc/pango/pango.modules - - This will generate the pango.modules with the correct modules - found in your relocated build, however they will not have the - correct paths. - - Assuming that you've used '/opt/devel' (for example) as your install - prefix for your relocated build environment (possibly jhbuild), then - you'll need to replace '/opt/devel' with './usr' in the generated - pango.modules file. - - o Generate and modify ${BUNDLE_ROOT}/usr/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache - - Much like the above pango excercise, we need to generate and modify the module - cache for gdk-pixbuf (you can't build gdk-pixbuf without module support, as - you really need librsvg). - - So again, using your relocated build environment, generate the cache with - this command: - - gdk-pixbuf-query-loaders > ${BUNDLE_ROOT}/usr/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache - - And again, assuming you've used '/opt/devel' (for example), then - you'll need to replace '/opt/devel' with './usr' in the generated - loaders.cache file. - - o Create the icon theme cache - - Assuming you've followed the instructions to the letter, the installation - of 'hicolor-icon-theme' will have created an index.theme file at: - - ${BUNDLE_ROOT}/usr/share/icons/hicolor/index.theme - - It's imperative that this file exist. - - Now create the cache using this command: - - gtk-update-icon-cache ${BUNDLE_ROOT}/usr/share/icons/hicolor/ - - This should create a file named: - - ${BUNDLE_ROOT}/usr/share/icons/hicolor/icon-theme.cache - - o Generate the mime database - - The mime database should be created so that GTK+ knows how to handle image file - extensions and whatnot, and can find the correct pixbuf loader for them. - - Do this in your relocated environment with the following: - - update-mime-database ${BUNDLE_ROOT}/usr/share/mime - - And just ignore the error about XDG_DATA_DIRS, this is taken care of - by the AppRunScript.sh - - o Strip the -rpath from any binaries - - Libtool loves to encode hard coded paths into the binaries it creates, - since we will be running the bundle with LD_LIBRARY_PATH set in the - bundle's runtime environment (and these paths actually take precedence - over the LD_LIBRARY_PATH), we need to strip those out, this is where - chrpath comes in. - - Run chrpath as follows to ensure you don't have any prioritized paths - still pointing to your relocated install prefix: - - chrpath -d ${BUNDLE_ROOT}/usr/lib/*.so - chrpath -d ${BUNDLE_ROOT}/usr/bin/glade - chrpath -d ${BUNDLE_ROOT}/usr/bin/glade-previewer - - o Clean up the bundle of unwanted stuff - - This is optional but helps to reduce the binary size of the - generated bundle. Some good removals include: - - rm -rf ${BUNDLE_ROOT}/usr/include - rm -f `find ${BUNDLE_ROOT} -name "*.la"` - rm -f `find ${BUNDLE_ROOT} -name "*.a"` - - You can safely remove everything in ${BUNDLE_ROOT}/usr/bin except - for 'glade' and 'glade-previewer' - - There are also some directories in ${BUNDLE_ROOT}/usr/share that - can be discarded (notably the 'gtk-doc' directory). - - The ${BUNDLE_ROOT}/usr/share/locale directory can be removed and - with it, all translations, I don't recommend this for a Glade - bundle however it will also dramatically reduce the bundle size. - - Creating the bundle - ~~~~~~~~~~~~~~~~~~~ - Now that we're all done creating a proper ${BUNDLE_ROOT}, we can - go ahead and bundle it. - - Run the 'AppImageAssistant' binary (found in the AppImageKit directory - which we built at the beginning), you can run it from anywhere, I usually - run it like this: - - ./AppImageAssistant ${BUNDLE_ROOT} ~/glade - - This will create the 'glade' executable, which is probably around 50MB - large at this point (depending entirely on how much you successfully - trimmed out of ${BUNDLE_ROOT}). - - Congradulations, now you have a bundle :) - - -Debugging considerations -~~~~~~~~~~~~~~~~~~~~~~~~ -If your bundle is not working, you will have to get your hands (even more) -dirty and look into the AppRunScript.sh which launches Glade. - -I recommend inserting 'bash' after running Glade and regenerating the -bundle, this will give you a shell inside the bundled environment -where you can try to run ./usr/bin/glade under strace and inspect -all of the files which Glade and it's dependencies try to open. - -Hint: If Glade successfully opens anything starting with /usr, -this is usually a sign of trouble. - -Another sanity check is to run ldd on ./usr/bin/glade, it should -only resolve to system libraries for C runtime libraries, X11 -libraries, fontconfig and freetype. - diff --git a/build/linux/jhbuildrc b/build/linux/jhbuildrc index 3bf2a04f..af290ded 100644 --- a/build/linux/jhbuildrc +++ b/build/linux/jhbuildrc @@ -21,7 +21,7 @@ # Tristan Van Berkom <tristan@upstairslabs.com> # use_local_modulesets = True -modulesets_dir = os.getenv('GLADE_DIR') + '/build/linux/modulesets' +modulesets_dir = os.getenv('BUNDLE_DIR') + '/modulesets' moduleset = 'bundle.modules' # Unset autogenargs (screws with some modules like freetype) @@ -41,7 +41,7 @@ build_cflags += ' -DCAIRO_NO_MUTEX=1' # Include the libcwrap.h before anything else for every source, this # ensures we are targetting the right version of glibc -build_cflags += ' -include ' + os.getenv('GLADE_DIR') + '/build/linux/libcwrap.h' +build_cflags += ' -include ' + os.getenv('BUNDLE_DIR') + '/libcwrap.h' # Set the compiler flags for both C and C++ sources, overriding CC and CXX # ensures that they come before any flags that any buildscripts might add @@ -49,7 +49,7 @@ os.environ['CC'] = 'gcc ' + build_cflags os.environ['CXX'] = 'g++ ' + build_cflags # Enable our custom triggers -os.environ['JHBUILD_TRIGGERS'] = os.getenv('GLADE_DIR') + '/build/linux/triggers' +os.environ['JHBUILD_TRIGGERS'] = os.getenv('BUNDLE_DIR') + '/triggers' # A list of the modules to build. modules = [ 'glade' ] |