X-Git-Url: http://gitweb/?a=blobdiff_plain;f=pkgmk.in;h=45406c6b5e1d5bdb83dd61d2c8239092b0ea0d8c;hb=174925ab782bcb7a893d56a79b16b8d767eaaf6d;hp=13cf2d0fcbebbde72c6d0cb3458f803677263e2d;hpb=163aacb1ff22837484088c1b41272684df7fc2f2;p=pkgutils-cross.git diff --git a/pkgmk.in b/pkgmk.in index 13cf2d0..45406c6 100755 --- a/pkgmk.in +++ b/pkgmk.in @@ -3,7 +3,10 @@ # pkgutils # # Copyright (c) 2000-2005 Per Liden -# Copyright (c) 2006-2007 by CRUX team (http://crux.nu) +# Copyright (c) 2006-2013 by CRUX team (http://crux.nu) +# +# Patches for crosscompilation by Jose V Beneyto +# (CRUX-ARM System Team ) # # 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 @@ -21,6 +24,18 @@ # USA. # +## +# error codes +E_GENERAL=1 +E_PKGFILE=2 # invalid Pkgfile +E_DIR_PERM=3 # (source/build) directory missing or missing read/write permission +E_DOWNLOAD=4 # error during download +E_UNPACK=5 # error during unpacking of source file(s) +E_MD5=6 # md5sum verification failed +E_FOOTPRINT=7 # footprint check failure +E_BUILD=8 # error while running 'build()' +E_INSTALL=9 # error while installing the package via 'pkgadd' + info() { echo "=======> $1" } @@ -49,29 +64,29 @@ get_basename() { check_pkgfile() { if [ ! "$name" ]; then error "Variable 'name' not specified in $PKGMK_PKGFILE." - exit 1 + exit $E_PKGFILE elif [ ! "$version" ]; then error "Variable 'version' not specified in $PKGMK_PKGFILE." - exit 1 + exit $E_PKGFILE elif [ ! "$release" ]; then error "Variable 'release' not specified in $PKGMK_PKGFILE." - exit 1 + exit $E_PKGFILE elif [ "`type -t build`" != "function" ]; then error "Function 'build' not specified in $PKGMK_PKGFILE." - exit 1 + exit $E_PKGFILE fi } check_directory() { if [ ! -d $1 ]; then error "Directory '$1' does not exist." - exit 1 + exit $E_DIR_PERM elif [ ! -w $1 ]; then error "Directory '$1' not writable." - exit 1 + exit $E_DIR_PERM elif [ ! -x $1 ] || [ ! -r $1 ]; then error "Directory '$1' not readable." - exit 1 + exit $E_DIR_PERM fi } @@ -87,7 +102,7 @@ download_file() { if [ ! "`type -p wget`" ]; then error "Command 'wget' not found." - exit 1 + exit $E_GENERAL fi LOCAL_FILENAME=`get_filename $1` @@ -129,7 +144,7 @@ download_file() { if [ $error != 0 ]; then error "Downloading '$1' failed." - exit 1 + exit $E_DOWNLOAD fi mv -f "$LOCAL_FILENAME_PARTIAL" "$LOCAL_FILENAME" @@ -143,13 +158,13 @@ download_source() { if [ ! -e $LOCAL_FILENAME ]; then if [ "$LOCAL_FILENAME" = "$FILE" ]; then error "Source file '$LOCAL_FILENAME' not found (can not be downloaded, URL not specified)." - exit 1 + exit $E_DOWNLOAD else if [ "$PKGMK_DOWNLOAD" = "yes" ]; then download_file $FILE else error "Source file '$LOCAL_FILENAME' not found (use option -d to download)." - exit 1 + exit $E_DOWNLOAD fi fi fi @@ -162,7 +177,7 @@ unpack_source() { for FILE in ${source[@]}; do LOCAL_FILENAME=`get_filename $FILE` case $LOCAL_FILENAME in - *.tar.gz|*.tar.Z|*.tgz|*.tar.bz2|*.tbz2|*.tar.xz|*.txz|*.tar.lzma|*.zip|*.rpm) + *.tar|*.tar.gz|*.tar.Z|*.tgz|*.tar.bz2|*.tbz2|*.tar.xz|*.txz|*.tar.lzma|*.zip|*.rpm) COMMAND="bsdtar -p -o -C $SRC -xf $LOCAL_FILENAME" ;; *) COMMAND="cp $LOCAL_FILENAME $SRC" ;; @@ -177,7 +192,7 @@ unpack_source() { rm -rf $PKGMK_WORK_DIR fi error "Building '$TARGET' failed." - exit 1 + exit $E_UNPACK fi done } @@ -224,11 +239,11 @@ check_md5sum() { if [ "$PKGMK_CHECK_MD5SUM" = "yes" ]; then error "Md5sum not ok." - exit 1 + exit $E_MD5 fi error "Building '$TARGET' failed." - exit 1 + exit $E_MD5 fi else if [ "$PKGMK_CHECK_MD5SUM" = "yes" ]; then @@ -236,7 +251,7 @@ check_md5sum() { rm -rf $PKGMK_WORK_DIR fi info "Md5sum not found." - exit 1 + exit $E_MD5 fi warning "Md5sum not found, creating new." @@ -266,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 } @@ -302,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" @@ -378,8 +400,9 @@ build_package() { if [ "$PKGMK_NO_STRIP" = "no" ]; then strip_files fi - + compress_manpages + fix_cross_paths cd $PKG info "Build result:"