CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
Merge remote-tracking branch 'upstream/master' into 3.1 3.1
authorJose V Beneyto <jose.beneyto@eslife.es>
Sat, 29 Nov 2014 00:38:18 +0000 (00:38 +0000)
committerJose V Beneyto <jose.beneyto@eslife.es>
Sat, 29 Nov 2014 00:38:18 +0000 (00:38 +0000)
README-cross [new file with mode: 0644]
pkgadd-cross [new file with mode: 0755]
pkgadd.cc
pkgadd.h
pkginfo-cross [new file with mode: 0755]
pkgmk-cross [new file with mode: 0755]
pkgmk-cross.conf [new file with mode: 0644]
pkgmk.in
pkgrm-cross [new file with mode: 0755]

diff --git a/README-cross b/README-cross
new file mode 100644 (file)
index 0000000..ed9a21b
--- /dev/null
@@ -0,0 +1,25 @@
+
+             README-cross
+
+             pkgutils for crosscompilations
+
+
+Build pkgutils
+$ make
+
+Edit pkgmk-cross.conf with your settings:
+$ vim pkgmk-cross.conf
+
+Add pkgmk-cross to the PATH environment variable:
+$ export PATH=/devel/crux-arm/pkgutils-cross:$PATH
+(note that append the old value for PATH at the end is important)
+
+Now you're ready to crosscompile packages:
+$ cd /devel/crux-arm/ports/core-cross/ncurses
+$ fakeroot pkgmk-cross -d
+
+And also to install (when you need a dependency installed)
+$ cd /devel/crux-arm/ports/core-cross/ncurses
+$ pkgadd-cross ncurses#X.X-1.pkg.tar.gz
+$ cd /devel/crux-arm/ports/core-cross/bash
+$ fakeroot pkgmk-cross -d
diff --git a/pkgadd-cross b/pkgadd-cross
new file mode 100755 (executable)
index 0000000..61bb88f
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+TOPDIR="$(cd $(dirname $(which $0)); pwd)"
+
+PKGADD=$TOPDIR/pkgadd
+PKGADD_CONF=$TOPDIR/pkgadd.conf
+PKGMK_CONF=$TOPDIR/pkgmk-cross.conf
+. $PKGMK_CONF
+
+if [ -z "$CLFS" ]; then
+  echo "Error, '\$CLFS' value not found"
+  echo "Please configure '$PKGMK_CONF' before use $(basename $0)"
+  exit 1
+fi
+
+if [ ! -f $CLFS/var/lib/pkg/db ]; then
+  install -d -m 0755 $CLFS/var/lib/pkg
+  touch $CLFS/var/lib/pkg/db
+fi
+
+# be sure that the path to package file exists
+# and if not prepend the package dir variable
+ARGS=""
+while [ "$1" ]; do
+  case $1 in
+    *.pkg.tar.*)
+      PATH_TO_PACKAGE="$1"
+      if [ ! -f "$PATH_TO_PACKAGE" ]; then
+        PATH_TO_PACKAGE="$PKGMK_PACKAGE_DIR/$PATH_TO_PACKAGE"
+      fi
+      ARGS="$ARGS $PATH_TO_PACKAGE"
+      ;;
+    *)
+      ARGS="$ARGS $1"
+      ;;
+  esac
+  shift
+done
+
+$PKGADD -c $PKGADD_CONF -r $CLFS $ARGS
+
+# we need to adjust .la files for our temporary root filesystem tree (CLFS)
+if [ $? -eq 0 ]; then
+  LIBTOOL_FILES=$(tar tf $PATH_TO_PACKAGE 2>/dev/null | grep '\.la$')
+  for la_file in $LIBTOOL_FILES; do
+    sed -e "s|libdir='/|libdir='$CLFS/|" -i $CLFS/$la_file
+  done
+fi
+
+# End of file
index 60bc65654f6a121703e584b1c1671a97b2ed46dc..2310ea05ede54e09e61bcb8637d9b44527939fc9 100644 (file)
--- a/pkgadd.cc
+++ b/pkgadd.cc
@@ -3,7 +3,9 @@
 // 
 //  Copyright (c) 2000-2005 Per Liden
 //  Copyright (c) 2006-2013 by CRUX team (http://crux.nu)
-// 
+//
+//  Patches for alternative pkgadd.conf file by Jose V Beneyto <sepen@crux.nu>
+//
 //  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
@@ -33,6 +35,7 @@ void pkgadd::run(int argc, char** argv)
        // Check command line options
        //
        string o_root;
+       string o_config;
        string o_package;
        bool o_upgrade = false;
        bool o_force = false;
@@ -43,6 +46,10 @@ void pkgadd::run(int argc, char** argv)
                        assert_argument(argv, argc, i);
                        o_root = argv[i + 1];
                        i++;
+               } else if (option == "-c" || option == "--config") {
+                       assert_argument(argv, argc, i);
+                       o_config = argv[i + 1];
+                       i++;
                } else if (option == "-u" || option == "--upgrade") {
                        o_upgrade = true;
                } else if (option == "-f" || option == "--force") {
@@ -71,7 +78,7 @@ void pkgadd::run(int argc, char** argv)
                db_open(o_root);
 
                pair<string, pkginfo_t> package = pkg_open(o_package);
-               vector<rule_t> config_rules = read_config();
+               vector<rule_t> config_rules = read_config(o_config);
 
                bool installed = db_find_pkg(package.first);
                if (installed && !o_upgrade)
@@ -112,18 +119,21 @@ void pkgadd::print_help() const
 {
        cout << "usage: " << utilname << " [options] <file>" << endl
             << "options:" << endl
-            << "  -u, --upgrade       upgrade package with the same name" << endl
-            << "  -f, --force         force install, overwrite conflicting files" << endl
-            << "  -r, --root <path>   specify alternative installation root" << endl
-            << "  -v, --version       print version and exit" << endl
-            << "  -h, --help          print help and exit" << endl;
+            << "  -u, --upgrade        upgrade package with the same name" << endl
+            << "  -f, --force          force install, overwrite conflicting files" << endl
+            << "  -r, --root <path>    specify alternative installation root" << endl
+            << "  -c, --config <file>  use alternate configuration file" << endl
+            << "  -v, --version        print version and exit" << endl
+            << "  -h, --help           print help and exit" << endl;
 }
 
-vector<rule_t> pkgadd::read_config() const
+vector<rule_t> pkgadd::read_config(string file) const
 {
        vector<rule_t> rules;
        unsigned int linecount = 0;
-       const string filename = root + PKGADD_CONF;
+       string filename = root + PKGADD_CONF;
+
+       if (!file.empty()) filename = file;
        ifstream in(filename.c_str());
 
        if (in) {
index f7f9b6474e9fde19233151a7b31b2fe200503999..0879808a44698ffc6c0af38ec30b43148864bf2b 100644 (file)
--- a/pkgadd.h
+++ b/pkgadd.h
@@ -48,7 +48,7 @@ public:
        virtual void print_help() const;
 
 private:
-       vector<rule_t> read_config() const;
+       vector<rule_t> read_config(string file) const;
        set<string> make_keep_list(const set<string>& files, const vector<rule_t>& rules) const;
        set<string> apply_install_rules(const string& name, pkginfo_t& info, const vector<rule_t>& rules);
        void find_rules(const vector<rule_t>& rules, rule_event_t event, vector<rule_t>& found) const;
diff --git a/pkginfo-cross b/pkginfo-cross
new file mode 100755 (executable)
index 0000000..69c795a
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+TOPDIR="$(cd $(dirname $(which $0)); pwd)"
+
+PKGINFO=$TOPDIR/pkginfo
+
+PKGMK_CONF=$TOPDIR/pkgmk-cross.conf
+. $PKGMK_CONF
+
+if [ -z "$CLFS" ]; then
+  echo "Error, '\$CLFS' value not found"
+  echo "Please configure '$PKGMK_CONF' before use $(basename $0)"
+  exit 1
+fi
+
+if [ -x $PKGINFO ]; then
+  $PKGINFO -r $CLFS $@
+else
+  ln -s pkgadd $PKGINFO
+  $PKGINFO -r $CLFS $@
+fi
+
+# End of file
diff --git a/pkgmk-cross b/pkgmk-cross
new file mode 100755 (executable)
index 0000000..6d02f4b
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+TOPDIR="$(cd $(dirname $(which $0)); pwd)"
+TMP_CONF="$(mktemp)"
+
+PKGMK=$TOPDIR/pkgmk
+PKGMK_CONF=$TOPDIR/pkgmk-cross.conf
+PKGMK_ARGS=""
+PKGMK_OPTIMIZE=""
+
+while [ "$1" ]; do
+  if [ "$1" != "-o" ]; then
+    PKGMK_ARGS="$PKGMK_ARGS $1"
+  else
+    shift
+    PKGMK_OPTIMIZE="$1"
+  fi
+  shift
+done
+
+if [ ! -z "$PKGMK_OPTIMIZE" ]; then
+  _cflags="$(grep "^${PKGMK_OPTIMIZE}_CFLAGS=" $PKGMK_CONF | cut -d'=' -f2- | sed 's|"||g')"
+  if [ ! -z "$_cflags" ]; then
+    sed '/_CFLAGS=/d' $PKGMK_CONF | sed "s|CFLAGS=.*|CFLAGS=\"$_cflags\"|" > $TMP_CONF
+    PKGMK_CONF="$TMP_CONF"
+  else
+    echo "Error, invalid optimization: '$PKGMK_OPTIMIZE'"
+    exit 1
+  fi
+fi
+
+if [ -x $PKGMK ]; then
+  $PKGMK -cf $PKGMK_CONF $PKGMK_ARGS
+else
+  chmod +x $PKGMK
+  $PKGMK -cf $PKGMK_CONF $PKGMK_ARGS
+fi
+
+rm -f $TMP_CONF
+
+# End of file
diff --git a/pkgmk-cross.conf b/pkgmk-cross.conf
new file mode 100644 (file)
index 0000000..1d9be33
--- /dev/null
@@ -0,0 +1,59 @@
+#
+# pkgmk.conf: pkgmk(8) configuration
+#
+
+export CHOST="$(echo $MACHTYPE)"
+
+# hardfp (mainline)
+export CTARGET="arm-crux-linux-gnueabihf"
+export CLFS="/devel/crux-arm/toolchain/clfs"
+export CROSSTOOLS="/devel/crux-arm/toolchain/crosstools"
+#
+# softfp
+#export CTARGET="arm-crux-linux-gnueabi"
+#export CLFS="/devel/crux-arm/toolchain-softfp/clfs"
+#export CROSSTOOLS="/devel/crux-arm/toolchain-softfp/crosstools"
+#
+# noeabi
+#export CTARGET="arm-crux-linux-gnu"
+#export CLFS="/devel/crux-arm/toolchain-noeabi/clfs"
+#export CROSSTOOLS="/devel/crux-arm/toolchain-noeabi/crosstools"
+
+export PATH="$CROSSTOOLS/bin:$PATH"
+export LD_LIBRARY_PATH="$CROSSTOOLS/lib:$CROSSTOOLS/usr/lib:/usr/lib/libfakeroot"
+
+export CC="$CTARGET-gcc"
+export CXX="$CTARGET-g++"
+export AR="$CTARGET-ar"
+export AS="$CTARGET-as"
+export RANLIB="$CTARGET-ranlib"
+export LD="$CTARGET-ld"
+export STRIP="$CTARGET-strip"
+
+# hardfp (mainline)
+export CFLAGS="-O2 -pipe -mfloat-abi=hard"
+#
+# softfp
+#export CFLAGS="-O2 -pipe -mno-unaligned-access"
+#
+# device optimizations (not really required if you can use native builds)
+#arm9tdmi_CFLAGS="-O2 -pipe -march=armv4 -mtune=arm9tdmi"
+#armv5te_CFLAGS="-O2 -pipe -msoft-float -march=armv5te"
+#strongarm_CFLAGS="-O2 -pipe -march=armv4 -mtune=strongarm"
+#xscale_CFLAGS="-O2 -pipe -msoft-float -march=armv5te -mtune=xscale"
+
+export CXXFLAGS="$CFLAGS"
+
+STRIP_CMD="$STRIP"
+
+# PKGMK_SOURCE_MIRRORS=()
+# PKGMK_SOURCE_DIR="$PWD"
+# PKGMK_PACKAGE_DIR="$PWD"
+# PKGMK_WORK_DIR="$PWD/work"
+# PKGMK_DOWNLOAD="no"
+# PKGMK_IGNORE_FOOTPRINT="no"
+# PKGMK_NO_STRIP="no"
+# PKGMK_WGET_OPTS=""
+PKGMK_COMPRESSION_MODE="xz"
+
+# End of file
index 997453deb50f39ae87bed92b53fe8bef3efe682d..45406c6b5e1d5bdb83dd61d2c8239092b0ea0d8c 100755 (executable)
--- a/pkgmk.in
+++ b/pkgmk.in
@@ -4,6 +4,9 @@
 # 
 #  Copyright (c) 2000-2005 Per Liden
 #  Copyright (c) 2006-2013 by CRUX team (http://crux.nu)
+#
+#  Patches for crosscompilation by Jose V Beneyto <sepen@crux.nu>
+#  (CRUX-ARM System Team <devel@crux-arm.nu>)
 # 
 #  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
@@ -278,13 +281,13 @@ strip_files() {
        find . -type f -printf "%P\n" | $FILTER | while read FILE; do
                case $(file -b "$FILE") in
                *ELF*executable*not\ stripped)
-                       strip --strip-all "$FILE"
+                       $STRIP_CMD --strip-all "$FILE"
                        ;;
                *ELF*shared\ object*not\ stripped)
-                       strip --strip-unneeded "$FILE"
+                       $STRIP_CMD --strip-unneeded "$FILE"
                        ;;
                current\ ar\ archive)
-                       strip --strip-debug "$FILE"
+                       $STRIP_CMD --strip-debug "$FILE"
                esac
        done
 }
@@ -314,6 +317,13 @@ compress_manpages() {
        done
 }
 
+fix_cross_paths() {
+        # remove the last / from CLFS path if appeared
+        CLFS=${CLFS%*/}
+
+        find $PKG -type f -name '*.la' -exec sed -e "s|$CLFS||g" -e "s|$CROSTOOLS/$CTARGET|/usr|g" -i {} \;
+}
+
 check_footprint() {
        local FILE="$PKGMK_WORK_DIR/.tmp"
        
@@ -390,8 +400,9 @@ build_package() {
                if [ "$PKGMK_NO_STRIP" = "no" ]; then
                        strip_files
                fi
-               
+
                compress_manpages
+               fix_cross_paths
                
                cd $PKG
                info "Build result:"
@@ -611,12 +622,6 @@ parse_options() {
 }
 
 main() {
-       # multilib
-       PKGMK_ARCH=64
-       if [ -f ".32bit" ]; then
-               PKGMK_ARCH=32
-       fi
-
        local FILE TARGET
        
        parse_options "$@"
diff --git a/pkgrm-cross b/pkgrm-cross
new file mode 100755 (executable)
index 0000000..6470a24
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+TOPDIR="$(cd $(dirname $(which $0)); pwd)"
+
+PKGRM=$TOPDIR/pkgrm
+
+PKGMK_CONF=$TOPDIR/pkgmk-cross.conf
+. $PKGMK_CONF
+
+if [ -z "$CLFS" ]; then
+  echo "Error, '\$CLFS' value not found"
+  echo "Please configure '$PKGMK_CONF' before use $(basename $0)"
+  exit 1
+fi
+
+if [ -x $PKGRM ]; then
+  $PKGRM -r $CLFS $@
+else
+  ln -s pkgadd $PKGRM
+  $PKGRM -r $CLFS $@
+fi
+
+# End of file