wok-current rev 3679

Fix: ocsinventory-agent. Add Tazpkg.pm. Fix filesystem reports.
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Sun Jul 12 23:18:03 2009 +0200 (2009-07-12)
parents 91491c1bd7b6
children 894c779750dc
files ocsinventory-agent/receipt ocsinventory-agent/stuff/Drives.pm.u ocsinventory-agent/stuff/Tazpkg.pm ocsinventory-agent/stuff/manifest.u
line diff
     1.1 --- a/ocsinventory-agent/receipt	Sat Jul 11 17:13:21 2009 +0200
     1.2 +++ b/ocsinventory-agent/receipt	Sun Jul 12 23:18:03 2009 +0200
     1.3 @@ -8,7 +8,7 @@
     1.4  SOURCE="OCSNG_UNIX_AGENT"
     1.5  TARBALL="$SOURCE-$VERSION.tar.gz"
     1.6  DEPENDS="perl perl-lwp-useragent perl-uri-url dmidecode"
     1.7 -SUGGESTED="nmap perl-ssleay"
     1.8 +SUGGESTED="nmap perl-net-ssleay"
     1.9  BUILD_DEPENDS="perl"
    1.10  WEB_SITE="http://www.ocsinventory-ng.org/"
    1.11  WGET_URL="http://downloads.sourceforge.net/sourceforge/ocsinventory/$TARBALL"
    1.12 @@ -16,19 +16,24 @@
    1.13  # Rules to configure and make the package.
    1.14  compile_rules()
    1.15  {
    1.16 -	  
    1.17  	src=$WOK/$PACKAGE/Ocsinventory-Agent-1.0.1
    1.18  
    1.19  	cp stuff/Slitaz.pm $src/lib/Ocsinventory/Agent/Backend/OS/Linux/Distro/NonLSB
    1.20 +	cp stuff/Tazpkg.pm $src/lib/Ocsinventory/Agent/Backend/OS/Generic/Packaging
    1.21 +	
    1.22  	cd $src
    1.23  	
    1.24  	# don't run postinstall script
    1.25  	rm -f run-postinst
    1.26 -	patch -p1 -i ../stuff/manifest.u || exit
    1.27 +	for p in ../stuff/*.u
    1.28 +	do
    1.29 +		[ -f done.$(basename $p) ] && continue
    1.30 +		patch -p1 -i $p || exit
    1.31 +		touch done.$(basename $p)
    1.32 +	done
    1.33  	perl Makefile.PL 
    1.34  	rm -f run-postinst
    1.35 -	 make && \
    1.36 -	 make DESTDIR=$PWD/_pkg install
    1.37 +	make && make DESTDIR=$PWD/_pkg install
    1.38  }
    1.39  
    1.40  # Rules to gen a SliTaz package suitable for Tazpkg.
    1.41 @@ -45,11 +50,17 @@
    1.42  }
    1.43  
    1.44  post_install(){
    1.45 -	echo "postinstall commands"
    1.46 +	echo "Processing post-install commands..."
    1.47  	cat > $1/etc/ocsinventory-agent/ocsinventory-agent.cfg <<EOT
    1.48  basevardir=/var/lib/ocsinventory-agent
    1.49  server=http://$(hostname)/ocsinventory
    1.50  EOT
    1.51 +	# We need fix missing status for dpkg
    1.52 +	# So we can Ocs agent can run Tazpkg.pm
    1.53 +	if [ ! -d $1/var/lib/dpkg ]; then
    1.54 +		install -o root -g root -m 0755 -d $1/var/lib/dpkg
    1.55 +		touch $1/var/lib/dpkg/status
    1.56 +	fi
    1.57  }	
    1.58  
    1.59  clean_wok()
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/ocsinventory-agent/stuff/Drives.pm.u	Sun Jul 12 23:18:03 2009 +0200
     2.3 @@ -0,0 +1,47 @@
     2.4 +--- Ocsinventory-Agent-1.0.1.ori/lib/Ocsinventory/Agent/Backend/OS/Linux/Drives.pm	Fri Mar  6 19:02:57 2009
     2.5 ++++ Ocsinventory-Agent-1.0.1/lib/Ocsinventory/Agent/Backend/OS/Linux/Drives.pm	Sun Jul 12 22:29:32 2009
     2.6 +@@ -1,9 +1,11 @@
     2.7 + package Ocsinventory::Agent::Backend::OS::Linux::Drives;
     2.8 ++# Modified bye Erjo <erjo@slitaz.org>
     2.9 ++# Busybox df applet as no -T -P options.
    2.10 + 
    2.11 + use strict;
    2.12 + sub check {
    2.13 +   return unless can_run ("df");
    2.14 +-  my $df = `df -TP`;
    2.15 ++  my $df = `df -k`;
    2.16 +   return 1 if $df =~ /\w+/;
    2.17 +   0
    2.18 + }
    2.19 +@@ -19,14 +21,14 @@
    2.20 +   my $volumn;
    2.21 + 
    2.22 + 
    2.23 +-  foreach(`df -TP`) { # TODO retrive error
    2.24 +-    if(/^(\S+)\s+(\S+)\s+(\S+)\s+(?:\S+)\s+(\S+)\s+(?:\S+)\s+(\S+)\n/){
    2.25 ++  foreach(`df -k`) { # TODO retrive error
    2.26 ++    if(/^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\n/){
    2.27 +       $free = sprintf("%i",($4/1024)); 
    2.28 +-      $filesystem = $2;
    2.29 +-      $total = sprintf("%i",($3/1024));
    2.30 +-      $type = $1;
    2.31 +-      $volumn = $5;
    2.32 +-
    2.33 ++      $filesystem = $1;
    2.34 ++      $total = sprintf("%i",($2/1024));
    2.35 ++      $type = `grep ^$1 /etc/mtab | cut -d " " -f 3`;;
    2.36 ++      $volumn = $6;
    2.37 ++	  
    2.38 + # no virtual FS
    2.39 +       next if ($type =~ /^(tmpfs|usbfs|proc|devpts|devshm|udev)$/);
    2.40 +       next if ($filesystem =~ /^(tmpfs)$/);
    2.41 +@@ -36,8 +38,7 @@
    2.42 + 	  FILESYSTEM => $filesystem,
    2.43 + 	  TOTAL => $total,
    2.44 + 	  TYPE => $type,
    2.45 +-	  VOLUMN =>
    2.46 +-	  $volumn
    2.47 ++	  VOLUMN => $volumn
    2.48 + 	})
    2.49 +     }
    2.50 +   }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/ocsinventory-agent/stuff/Tazpkg.pm	Sun Jul 12 23:18:03 2009 +0200
     3.3 @@ -0,0 +1,24 @@
     3.4 +package Ocsinventory::Agent::Backend::OS::Generic::Packaging::Tazpkg;
     3.5 +
     3.6 +use strict;
     3.7 +use warnings;
     3.8 +
     3.9 +sub check { can_run("tazpkg") }
    3.10 +
    3.11 +sub run {
    3.12 +  my $params = shift;
    3.13 +  my $inventory = $params->{inventory};
    3.14 +
    3.15 +# use dpkg-query -W -f='${Package}|||${Version}\n'
    3.16 +  foreach (`tazpkg list `){
    3.17 +    if (/^(\S+)\s+([0-9]+.*)\s+(.*)/) {
    3.18 +      $inventory->addSoftwares({
    3.19 +	  'NAME'          => $1,
    3.20 +	  'VERSION'       => $2,
    3.21 +	  });
    3.22 +    }
    3.23 +  }
    3.24 +
    3.25 +}
    3.26 +
    3.27 +1;
     4.1 --- a/ocsinventory-agent/stuff/manifest.u	Sat Jul 11 17:13:21 2009 +0200
     4.2 +++ b/ocsinventory-agent/stuff/manifest.u	Sun Jul 12 23:18:03 2009 +0200
     4.3 @@ -1,10 +1,10 @@
     4.4  --- Ocsinventory-Agent-1.0.1.ori/MANIFEST	Sun Mar 22 20:19:28 2009
     4.5 -+++ Ocsinventory-Agent-1.0.1/MANIFEST	Thu Jul  9 16:27:30 2009
     4.6 -@@ -82,6 +82,7 @@
     4.7 - lib/Ocsinventory/Agent/Backend/OS/Linux/Distro/LSB.pm
     4.8 - lib/Ocsinventory/Agent/Backend/OS/Linux/Distro/NonLSB.pm
     4.9 - lib/Ocsinventory/Agent/Backend/OS/Linux/Distro/NonLSB/Debian.pm
    4.10 -+lib/Ocsinventory/Agent/Backend/OS/Linux/Distro/NonLSB/Slitaz.pm
    4.11 - lib/Ocsinventory/Agent/Backend/OS/Linux/Distro/NonLSB/Fedora.pm
    4.12 - lib/Ocsinventory/Agent/Backend/OS/Linux/Distro/NonLSB/Gentoo.pm
    4.13 - lib/Ocsinventory/Agent/Backend/OS/Linux/Distro/NonLSB/Knoppix.pm
    4.14 ++++ Ocsinventory-Agent-1.0.1/MANIFEST	Sun Jul 12 22:31:59 2009
    4.15 +@@ -71,6 +71,7 @@
    4.16 + lib/Ocsinventory/Agent/Backend/OS/Generic/Packaging.pm
    4.17 + lib/Ocsinventory/Agent/Backend/OS/Generic/Packaging/BSDpkg.pm
    4.18 + lib/Ocsinventory/Agent/Backend/OS/Generic/Packaging/Deb.pm
    4.19 ++lib/Ocsinventory/Agent/Backend/OS/Generic/Packaging/Tazpkg.pm
    4.20 + lib/Ocsinventory/Agent/Backend/OS/Generic/Packaging/Gentoo.pm
    4.21 + lib/Ocsinventory/Agent/Backend/OS/Generic/Packaging/RPM.pm
    4.22 + lib/Ocsinventory/Agent/Backend/OS/Generic/Screen.pm