[pisa-src] r1065 - in trunk: . test/packaging tools

  • From: René Hummen <rene.hummen@xxxxxxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Thu, 08 Oct 2009 18:10:44 +0200

Author: hummen
Date: Thu Oct  8 18:10:44 2009
New Revision: 1065

Log:
added msleep as I didn't find a package for high precision sleep

Added:
   trunk/tools/msleep.c
Modified:
   trunk/Makefile.am
   trunk/configure.ac
   trunk/test/packaging/create-package.sh
   trunk/test/packaging/debbuild

Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am   Thu Oct  8 17:57:49 2009        (r1064)
+++ trunk/Makefile.am   Thu Oct  8 18:10:44 2009        (r1065)
@@ -13,7 +13,7 @@
 EXTRA_DIST += tools/writeff.pl tools/tunnel/screamer.rb
 EXTRA_DIST += tools/tunnel/seteth1address
 
-SUBDIRS  = libpisa pairing performance pisacd pisand pisasd test pisabeacon
+SUBDIRS  = libpisa pairing performance pisacd pisand pisasd test pisabeacon 
tools
 SUBDIRS += community-operator # has to be enabled for compilation on openwrt
 
 pisaincludedir=$(includedir)

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac  Thu Oct  8 17:57:49 2009        (r1064)
+++ trunk/configure.ac  Thu Oct  8 18:10:44 2009        (r1065)
@@ -184,6 +184,8 @@
 AC_SUBST(PISA_PISASD_INCLUDES, "$PISA_PISASD")
 AC_SUBST(PISA_PISABEACON, "$TOPSRC/pisabeacon")
 AC_SUBST(PISA_PISABEACON_INCLUDES, "$PISA_PISABEACON")
+AC_SUBST(PISA_TOOLS, "$TOPSRC/tools")
+AC_SUBST(PISA_TOOLS_INCLUDES, "$PISA_TOOLS")
 
 
 
@@ -216,6 +218,7 @@
                 test/Makefile
                 community-operator/Makefile
                 performance/Makefile
+                tools/Makefile
                 Makefile])
 
 AC_OUTPUT

Modified: trunk/test/packaging/create-package.sh
==============================================================================
--- trunk/test/packaging/create-package.sh      Thu Oct  8 17:57:49 2009        
(r1064)
+++ trunk/test/packaging/create-package.sh      Thu Oct  8 18:10:44 2009        
(r1065)
@@ -22,8 +22,8 @@
 PKGEXE=$PKGROOT/test/packaging
 PKG_WEB_DIR=
 PKG_SERVER_DIR=
-DEBDIR=/usr/src/debian
-RPMDIR=/usr/src/redhat
+DEBDIR=$PWD/buildenv
+RPMDIR=$PWD/buildenv
 SUBDEBDIRS="BUILD DEBS SOURCES SPECS SDEBS"
 SUBRPMDIRS="BUILD RPMS SOURCES SPECS SRPMS"
 SUDO=sudo
@@ -156,15 +156,15 @@
     do
        if test ! -d $DEBDIR/$SUBDIR
        then
-           $SUDO mkdir -p $DEBDIR/$SUBDIR
+           mkdir -p $DEBDIR/$SUBDIR
        fi
     done
 
-    $SUDO cp $SPECFILE $DEBDIR/SPECS
+    cp $SPECFILE $DEBDIR/SPECS
 
-    $SUDO mv -f $TARBALL /usr/src/debian/SOURCES
+    mv -f $TARBALL $DEBDIR/SOURCES
     # http://www.deepnet.cx/debbuild/
-    $SUDO $PKGEXE/debbuild -ba $SPECFILE
+    $PKGEXE/debbuild --buildroot $DEBDIR -ba $SPECFILE
 }
 
 ############### Main program #####################
@@ -256,8 +256,8 @@
 
 EOF
 
-echo "*** Cleaning up binaries from ${PKG_DIR} ***"
-$SUDO rm -f ${PKG_DIR}/*.${BIN_FORMAT}
+echo "*** Cleaning up ${DEBDIR} ***"
+rm -rf ${DEBDIR}
 
 if test x"$1" = x"rpm" || test x"$BIN_FORMAT" = x"rpm"
 then

Modified: trunk/test/packaging/debbuild
==============================================================================
--- trunk/test/packaging/debbuild       Thu Oct  8 17:57:49 2009        (r1064)
+++ trunk/test/packaging/debbuild       Thu Oct  8 18:10:44 2009        (r1065)
@@ -5,9 +5,10 @@
 # unlikely to conform to "Debian Policy".
 ###
 # SVN revision info
-# $Date: 2008-06-10 13:08:54 -0400 (Tue, 10 Jun 2008) $
-# SVN revision $Rev: 145 $
-# Last update by $Author: kdeugau $
+# $Date$
+# debbuild - Revision 150: /trunk
+# SVN revision $Rev$
+# Last update by $Author$
 ###
 # Copyright 2005-2008 Kris Deugau <kdeugau@xxxxxxxxxx>
 #
@@ -63,6 +64,7 @@
 my %specglobals;       # For %define's in specfile, among other things.
 
 $specglobals{'_vendor'} = 'debbuild';
+$specglobals{'vendor'} = 'debbuild';
 
 # Initialized globals
 my $verbosity = 0;
@@ -90,35 +92,7 @@
                'amd64' =>      '-O2 -g'
        );
 my $hostarch;  # we set this later...
-my $scriptletbase =
-q(#!/bin/sh
-
-  RPM_SOURCE_DIR="%{_topdir}/SOURCES"
-  RPM_BUILD_DIR="%{_topdir}/BUILD"
-  RPM_OPT_FLAGS="%{optflags}"
-  RPM_ARCH="%{_arch}"
-  RPM_OS="linux"
-  export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
-  RPM_DOC_DIR="/usr/share/doc"
-  export RPM_DOC_DIR
-  RPM_PACKAGE_NAME="%{name}"
-  RPM_PACKAGE_VERSION="%{version}"
-  RPM_PACKAGE_RELEASE="%{release}"
-  export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
-  RPM_BUILD_ROOT="%{buildroot}"
-  export RPM_BUILD_ROOT
-);
-foreach (`dpkg-architecture`) {
-  s/=(.+)/="$1"/;
-  $scriptletbase .= "  $_";
-  ($hostarch) = (/^DEB_HOST_ARCH="(.+)"$/) if /DEB_HOST_ARCH=/;
-}
-$scriptletbase .=
-q(
-  set -x
-  umask 022
-  cd %{_topdir}/BUILD
-);
+my $scriptletbase;
 
 # Hackery to try to bring some semblance of sanity to packages built for more
 # than one Debian version at the same time.  Whee.
@@ -179,6 +153,38 @@
 load_userconfig();
 parse_cmd();
 
+$topdir = $cmdbuildroot if $cmdbuildroot;
+
+$scriptletbase =
+q(#!/bin/sh
+
+  RPM_SOURCE_DIR="%{_topdir}/SOURCES"
+  RPM_BUILD_DIR="%{_topdir}/BUILD"
+  RPM_OPT_FLAGS="%{optflags}"
+  RPM_ARCH="%{_arch}"
+  RPM_OS="linux"
+  export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
+  RPM_DOC_DIR="/usr/share/doc"
+  export RPM_DOC_DIR
+  RPM_PACKAGE_NAME="%{name}"
+  RPM_PACKAGE_VERSION="%{version}"
+  RPM_PACKAGE_RELEASE="%{release}"
+  export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
+  RPM_BUILD_ROOT="%{buildroot}"
+  export RPM_BUILD_ROOT
+);
+foreach (`dpkg-architecture`) {
+  s/=(.+)/="$1"/;
+  $scriptletbase .= "  $_";
+  ($hostarch) = (/^DEB_HOST_ARCH="(.+)"$/) if /DEB_HOST_ARCH=/;
+}
+$scriptletbase .=
+q(
+  set -x
+  umask 022
+  cd %{_topdir}/BUILD
+);
+
 if ($cmdopts{install}) {
   install_sdeb();
   exit 0;
@@ -347,6 +353,8 @@
          $cmdopts{type} = 's';
        } elsif (/^--showpkgs/) {
          $cmdopts{type} = 'd'; # d for 'diagnostic' or 'debug' or 'dump'
+       } elsif (/^--buildroot/) {
+          # nothing to do?  Can't see anything needed, we handle the actual 
definition later.
        } elsif (/^--define/) {
          # nothing to do?  Can't see anything needed, we handle the actual 
definition later.
 ##fixme
@@ -865,7 +873,8 @@
         $specglobals{buildroot} = $1;
       } elsif (/^source0?:\s*(.+)/i) {
         $pkgdata{main}{source} = $1;
-        die "Unknown tarball format $1\n" if $1 !~ /\.tar\.(?:gz|bz2)$/;
+       # .tar, .tar.gz, .tar.bz2, .tgz
+        die "Unknown tarball format $1\n" if $1 !~ 
/\.(?:tar(?:\.(?:gz|bz2))?|tgz)$/;
       } elsif (/^source([0-9]+):\s*(.+)/i) {
         $pkgdata{sources}{$1} = $2;
       } elsif (/^patch([^:]+):\s*(.+)$/i) {
@@ -917,7 +926,7 @@
 
   $cleanscript = expandmacros($cleanscript,'gp');
 
-  $specglobals{buildroot} = $cmdbuildroot if $cmdbuildroot;
+  #$specglobals{buildroot} = $cmdbuildroot if $cmdbuildroot;
   $specglobals{buildroot} = expandmacros($specglobals{buildroot},'gp');
 
   close SPECFILE;
@@ -1439,7 +1448,9 @@
     next if m|/lib(?:64)?/ld-linux|;   # Hack! Hack!  PTHBTT!  (libc suxx0rz)
     next if /linux-gate.so/;           # Kernel hackery for teh 
W1n!!1!1eleventy-one!1  (Don't ask.  Feh.)
 
-    my ($req) = (/^\s+([a-z0-9._-]+)/); # dig out the actual library (so)name
+    my ($req) = (m|=\>\s+([a-z0-9._/-]+)|); # dig out the actual library 
(so)name.
+       # And feh, we need the *path*, since I've discovered a new edge case 
where
+       # the same libnnn.1.2.3 *file*name is found across *several* lib dirs.  
>:(
 
     # Ignore libs provided by this package.  Note that we don't match
     # on word-boundary at the *end* of the lib we're looking for, as the
@@ -1590,6 +1601,7 @@
   # Package data
   if ($section =~ /p/) {
     $macrostring =~ s/\%\{buildroot\}/$specglobals{buildroot}/gi;
+    $macrostring =~ 
s/\%\{source0?}/$topdir\/SOURCES\/$pkgdata{main}{source}/gi;
     foreach my $source (keys %{$pkgdata{sources}}) {
       $macrostring =~ 
s/\%\{source$source\}/$topdir\/SOURCES\/$pkgdata{sources}{$source}/gi;
     }

Added: trunk/tools/msleep.c
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/tools/msleep.c        Thu Oct  8 18:10:44 2009        (r1065)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2009, Distributed Systems Group, RWTH Aachen
+ * All rights reserved.
+ */
+
+/**
+ * @file usleep.c
+ * @brief Provides similar functionality to sleep with higher precision.
+ * @author Ren� Hummen <hummen@xxxxxxxxxxxxxxxxx>
+ * @date 08.10.2009
+ */
+
+#include <ctype.h>             /* isprint() */
+#include <stdio.h>             /* printf(), ... */
+#include <stdlib.h>            /* atoi() */
+#include <getopt.h>            /* command line parsing */
+#include <unistd.h>            /* usleep */
+
+#define DEFAULT_MSECS  100000
+#define USEC_TO_MSEC   1000
+
+useconds_t get_msecs_from_args(const int argc, char *argv[]);
+
+
+int main(int argc, char *argv[])
+{
+       useconds_t msecs = 0;
+
+       msecs = get_msecs_from_args(argc, argv);
+
+       if (usleep(msecs))
+               printf("failed to msleep\n");
+
+       exit(0);
+}
+
+useconds_t get_msecs_from_args(const int argc, char *argv[])
+{
+       int c = 0;
+       useconds_t msecs = DEFAULT_MSECS;
+
+       while ((c = getopt(argc, argv, "hi:")) != -1)
+       {
+               switch (c)
+               {
+                       case 'h':
+                               printf("usage: \tusleep [-i <uint> ms]\n");
+                               exit(0);
+                       case 'i':
+                               msecs = atoi(optarg) * USEC_TO_MSEC;
+                               break;
+                       case '?':
+                               if (optopt == 'i')
+                                       fprintf(stderr, "Option -%c requires an 
argument.\n", optopt);
+                               else if (isprint(optopt))
+                                       fprintf(stderr, "Unknown option 
`-%c'.\n", optopt);
+                               else
+                                       fprintf(stderr, "Unknown option 
character `\\x%x'.\n", optopt);
+                               exit(1);
+                       default:
+                               break;
+               }
+       }
+
+       return msecs;
+}

Other related posts: