Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=kdetesting2.git;a=commitdiff;h=db708ea5e1ffdf94a0d4deace57b5130ec2c1765

commit db708ea5e1ffdf94a0d4deace57b5130ec2c1765
Author: Michel Hermier <herm...@frugalware.org>
Date:   Sat Aug 6 09:32:07 2011 +0200

kde.sh: Change the splitting logic a little.

* Simplify it by vectorising to arrays code that was using if ... elif
... code.
* Introduce new KDE_path_install that abstract installation of a single
path content.
* Remove _F_kde_subpkgs_custom_path: This is an idiot proof option.

diff --git a/source/include/kde.sh b/source/include/kde.sh
index 8e3d9e2..07c052f 100644
--- a/source/include/kde.sh
+++ b/source/include/kde.sh
@@ -190,20 +190,50 @@ __KDE_pre_build_check()

###
# == PROVIDED FUNCTIONS
+# * KDE_cleanup: Remove duplicates in Fdestdir from all the subpkgs
+###
+KDE_cleanup()
+{
+       Fcleandestdir "${subpkgs[@]}"
+}
+
+###
+# * KDE_path_install: Install the content of a path if it exist. Parameters: 1)
+# Path to install.
+###
+KDE_path_install()
+{
+       Fmessage "Installing files from path $1."
+       make -C "$1" DESTDIR="$Fdestdir" install || Fdie
+}
+
+###
# * KDE_project_install: Install a specific package. Parameters: 1) Name of the
-# project (Must also be the name of a directory).
+# project. 2) path of the project (optional).
###
KDE_project_install()
{
-       if [ -d "filters" ]; then # Koffice
-               if [ -d "filters/$1" ]; then
-                       Fmessage "Installing filters from filters/ dir for $1."
-                       make -C "filters/$1" DESTDIR="$Fdestdir" install || Fdie
+       local fail=1 path="${2:-$1}"
+       local -a paths
+       paths=(
+               "$path"
+               "apps/$path"
+               "apps/lib/$path"
+               "experimental/$path"    # for kdebase-runtime
+               "filters/$path"         # for koffice
+               "lib/$path"
+               "libs/$path"
+       )
+
+       for path in "${paths[@]}"; do
+               Fmessage "Installing project $1 ($path) ???"
+               if [ -d "$path" ]; then
+                       Fmessage "Installing project $1 ($path)"
+                       KDE_path_install "$path"
+                       fail=0
fi
-       fi
-       ## install the package
-       Fmessage "Installing main files for $1."
-       make -C "$1" DESTDIR="$Fdestdir" install || Fdie
+       done
+
## install the documentation
if __kde_in_array "$pkgname-docs" "${subpkgs[@]}"; then
# documentation is in $pkgname-docs so ...
@@ -213,37 +243,32 @@ KDE_project_install()
fi
else
# documentation is per package so ...
-               local path
-               for path in "doc" "apps/doc"; do
-                       if [ -d "$path/$1" ]; then #  does the package has docs 
?
-                               ## install docs
-                               Fmessage "Installing docs from TOP_SRC/$path 
dir for $1."
-                               make -C "$path/$1" DESTDIR="$Fdestdir" install 
|| Fdie
+               paths=(
+                       "doc/$1"
+                       "apps/doc/$1"
+               )
+
+               for path in "${paths[@]}"; do
+                       if [ -d "$path" ]; then #  does the package has docs ?
+                               Fmessage "Installing project $1 documentation"
+                               KDE_path_install "$path"
fi
done
fi
+       return $fail
}

-
###
# * KDE_project_split(): Moves a KDE project to a subpackage. Parameters:
# 1) name of the subpackage 2) Name of the project (see KDE_project_install).
# Example: KDE_project_split kopete-irc kopete/protocols/irc
###

-__kde_remove_files()
+KDE_project_split()
{
-       local i j
-       [ -z "$1" ] && Fdie
-       for i in `find $Fdestdir -name "$1"`
-       do
-               if [ -f "$i" ]; then
-                       j=`echo $i|sed 's|.*/pkg/||g'`
-                       Frm $j
-               else
-                       Fdie
-               fi
-       done
+       KDE_project_install "$1" "$2"
+       KDE_cleanup
+       Fsplit "$1" /\*
}

__kde_find_split_files()
@@ -262,12 +287,6 @@ __kde_find_split_files()
done
}

-KDE_project_split()
-{
-       KDE_project_install "$2"
-       Fsplit "$1" /\*
-}
-
###
# * KDE_split(): Moves the _F_kde_subpkgs name list to subpackages. Parameters:
# None. To find the projects dir, front "$pkgname-" and '-' are changed in '/'
@@ -275,58 +294,30 @@ KDE_project_split()
# subdirectory project. Example: "kdelibs-kioslave-ftp" would search for
# kioslave/ftp project subdir.
###
-__KDE_split_pkg() # internal and should be extended to handle all kind paths
-{
-       local extinfo pkgdir="$2"
-       Fmessage "$(pwd): __KDE_split_pkg '$*'"
-       if [ "$1" != "$2"  ]; then
-               extinfo=" ( subpkg_name $1 )"
-       fi
-       ## check whatever that project exists
-       if [ -d "$pkgdir" ]; then
-               Fmessage "Found Kde-Project "$pkgdir"$extinfo in TOP_SRC dir.. 
Splitting.."
-               KDE_project_split "$i" "$pkgdir"
-       elif [ -d "apps/$pkgdir" ]; then ## kdebase
-               Fmessage "Found Kde-Project "$pkgdir"$extinfo in apps/ dir.. 
Splitting.."
-               KDE_project_split "$i" "apps/$pkgdir"
-       elif [ -d "libs/$pkgdir" ]; then
-               Fmessage "Found Kde-Project "$pkgdir"$extinfo in libs/ dir.. 
Splitting."
-               KDE_project_split "$i" "libs/$pkgdir"
-       elif [ -d "apps/lib/$pkgdir" ]; then ## kdebase
-               Fmessage "Found Kde-Project "$pkgdir"$extinfo in apps/lib/ 
dir.. Splitting."
-               KDE_project_split "$i" "apps/lib/$pkgdir"
-       elif [ -d "lib/$pkgdir" ]; then
-               Fmessage "Found Kde-Project "$pkgdir"$extinfo in lib/ dir.. 
Splitting."
-               KDE_project_split "$i" "lib/$pkgdir"
-       elif [ -d "experimental/$pkgdir" ]; then
-               Fmessage "Found Kde-Project "$pkgdir"$extinfo in experimental/ 
dir.. Splitting."
-               KDE_project_split "$i" "experimental/$pkgdir"
-       else ## TODO: Add apps/*/<something> checks , maybe more paths ?
-               return 1
-       fi
-       return 0
-}
-
__KDE_split()
{
## we use for weird or not logical names
## $pkgname-<the_weird_name>
-       local clean="$(eval "echo -n \"\${1/#$pkgname-/}"\")" # Remove front 
"$pkgname-"
-       if [ "$1" != "$clean" ] && \
-          __KDE_split "$clean"; then # Remove front "$pkgname-"
+       local path="${2:-$1}"
+       local clean="$(eval "echo -n \"\${path/#$pkgname-/}"\")" # Remove front 
"$pkgname-"
+       if [ "$path" != "$clean" ] && \
+          __KDE_split "$1" "$clean"; then
return 0
fi
-       if __KDE_split_pkg "$1" "$1"; then
+
+       if KDE_project_install "$1" "${path}"; then
return 0
fi
-       if __KDE_split_pkg "$1" "${1//-//}"; then # Transform "-" into "/"
+       if KDE_project_install "$1" "${path//-//}"; then # Transform "-" into 
"/"
return 0
fi
-       clean="${1/#lib/}"
-       if [ "$1" != "$clean" ] && \
-          __KDE_split "$clean"; then # Remove front "lib"
+
+       clean="${path/#lib/}" # Remove front "lib"
+       if [ "$path" != "$clean" ] && \
+          __KDE_split "$1" "$clean"; then
return 0
fi
+
return 1
}

@@ -338,22 +329,20 @@ KDE_split()
do
## Shall we add something more generic some _ignore= ?
## but for that we need some hacks in makepkg I guess
-               if [ "$i" == "$pkgname-docs" ]; then
-                       Fmessage "Ignoring $pkgname-docs KDE_install() will 
take care.."
-                       continue
-               elif [ "$i" == "$pkgname-compiletime" ]; then
-                       Fmessage "Ignoring $pkgname-compiletime KDE_install() 
will take care.."
+               case "$i" in
+               "$pkgname-docs"| \
+               "$pkgname-compiletime")
+                       Fmessage "Ignoring $i KDE_install() will take care.."
continue
-               fi
+               esac

-               if ! __KDE_split "$i"; then
-                       if [ -z "$_F_kde_subpkgs_custom_path" ]; then
-                               Fmessage "Could not find $i!! Maybe is not in 
the TOP_SRC or libs dir? Or Typo?"
-                               Fdie
-                       else
-                               Fmessage "Could not find $i but 
_F_kde_subpkgs_custom_path is set!"
-                               Fmessage "Won't die() here, assuming build() 
will handle this package!..."
-                       fi
+               Fmessage "Splitting $i"
+               if __KDE_split "$i"; then
+                       KDE_cleanup
+                       Fsplit "$i" /\*
+               else
+                       Fmessage "Could not find $1 for automagic 
_F_kde_subpkgs splitting !!"
+                       Fdie
fi
done
}
@@ -371,23 +360,16 @@ KDE_make()
CMake_make "$@"
}

-
KDE_make_split()
{
-## only check on core stuff
-if [ "$_F_kde_defaults" -eq 1 ]; then
-       __KDE_pre_build_check
-fi
+       ## only check on core stuff
+       if [ "$_F_kde_defaults" -eq 1 ]; then
+               __KDE_pre_build_check
+       fi
KDE_make "$@"
KDE_split
}

-KDE_cleanup()
-{
-       Fcleandestdir "${_F_kde_subpkgs[@]}"
-       Fcleandestdir "${subpkgs[@]}"
-}
-
KDE_install()
{
make DESTDIR="$Fdestdir" install || Fdie
@@ -410,10 +392,9 @@ KDE_install()
fi
}

-
KDE_build()
{
-       KDE_make_split
+       KDE_make_split "$@"
KDE_install
}

@@ -424,4 +405,3 @@ build()
{
KDE_build
}
-
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to