Index: src/main/java/org/codehaus/mojo/rpm/Source.java
===================================================================
--- src/main/java/org/codehaus/mojo/rpm/Source.java	(revision 8579)
+++ src/main/java/org/codehaus/mojo/rpm/Source.java	(working copy)
@@ -44,6 +44,9 @@
     /** <code>true</code> to omit the default exclusions. */
     private boolean noDefaultExcludes;
 
+    /** target architecture for filtering */
+    private String targetArch;
+
     // // // Bean methods
 
     /**
@@ -126,6 +129,16 @@
         noDefaultExcludes = noDefExcl;
     }
 
+    public String getTargetArch()
+    {
+        return targetArch;
+    }
+
+    public void setTargetArch( String targetArch )
+    {
+        this.targetArch = targetArch;
+    }
+
     // // // Public methods
 
     /** {@inheritDoc} */
@@ -158,6 +171,11 @@
             sb.append( " [no default excludes]" );
         }
 
+        if ( targetArch != null )
+        {
+            sb.append( " target arch filter: " + targetArch );
+        }
+
         sb.append( "}" );
         return sb.toString();
     }
Index: src/main/java/org/codehaus/mojo/rpm/RPMMojo.java
===================================================================
--- src/main/java/org/codehaus/mojo/rpm/RPMMojo.java	(revision 8579)
+++ src/main/java/org/codehaus/mojo/rpm/RPMMojo.java	(working copy)
@@ -25,8 +25,11 @@
 import java.io.FileWriter;
 import java.io.PrintWriter;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
@@ -37,6 +40,7 @@
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.archiver.dir.DirectoryArchiver;
 import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
@@ -122,6 +126,13 @@
     private String distribution;
 
     /**
+     * The target architecture. This is overrides the needarch flag.
+     * 
+     * @parameter
+     */
+    private String targetArch;
+
+    /**
      * An icon for the package.
      * 
      * @parameter
@@ -448,10 +459,15 @@
         cl.createArgument().setValue( buildroot.getAbsolutePath() );
         cl.createArgument().setValue( "--define" );
         cl.createArgument().setValue( "_topdir " + workarea.getAbsolutePath() );
-        if ( !needarch )
+        if ( !needarch && StringUtils.isEmpty( targetArch ) )
         {
+            targetArch = "noarch";
+        }
+        if ( !StringUtils.isEmpty( targetArch ) )
+        {
             cl.createArgument().setValue( "--target" );
-            cl.createArgument().setValue( "noarch" );
+            cl.createArgument().setValue( targetArch );
+            getLog().info( "Target arch is: [" + targetArch + "]" );
         }
         if ( keyname != null )
         {
@@ -545,8 +561,8 @@
         }
         else
         {
-            version = projversion.substring( 0, projversion.indexOf( "-" ) );
-            getLog().warn( "Version string truncated to " + version );
+            version = projversion.replaceAll( "\\-", "_" );
+            getLog().warn( "Version string [" + projversion + "] modified to [" + version + "]" );
         }
 
         // Various checks in the mappings
@@ -629,9 +645,11 @@
      * @param excl The list of exclusions
      * @throws MojoExecutionException if a problem occurs
      */
-    private void copySource( File src, File dest, List incl, List excl )
+    private Map copySource( File src, File dest, List incl, List excl )
         throws MojoExecutionException
     {
+
+        Map resultMap = new HashMap();
         try
         {
             // Set the destination
@@ -662,6 +680,9 @@
             // Perform the copy
             copier.createArchive();
 
+            resultMap.putAll( copier.getFiles() );
+            resultMap.putAll( copier.getDirs() );
+
             // Clear the list for the next mapping
             copier.resetArchiver();
         }
@@ -669,6 +690,8 @@
         {
             throw new MojoExecutionException( "Unable to copy files for packaging: " + t.getMessage(), t );
         }
+
+        return resultMap;
     }
 
     /**
@@ -696,7 +719,8 @@
                 if ( item.getArtifactId().equals( dep.getArtifactId() ) )
                 {
                     getLog().debug( "... Artifact matches" );
-                    // ArtifactVersion av = item.getVersionRange().matchVersion( dep.getAvailableVersions() );
+                    // ArtifactVersion av = item.getVersionRange().matchVersion(
+                    // dep.getAvailableVersions() );
                     try
                     {
                         if ( item.getVersionRange().containsVersion( dep.getSelectedVersion() ) )
@@ -732,6 +756,8 @@
             copySource( icon, icondest, null, null );
         }
 
+        List extraMappings = new ArrayList();
+
         // Process each mapping
         for ( Iterator it = mappings.iterator(); it.hasNext(); )
         {
@@ -758,6 +784,14 @@
                     for ( Iterator sit = srcs.iterator(); sit.hasNext(); )
                     {
                         Source src = (Source) sit.next();
+                        // getLog().info("Filtering source #1: " + src.getLocation() + ", targetArch: [" +
+                        // src.getTargetArch() + "]");
+                        // filter files not for the targeted arch
+                        if ( !StringUtils.isEmpty( src.getTargetArch() ) && !src.getTargetArch().equals( targetArch ) )
+                        {
+                            // getLog().info("Filtered! - " + src.getLocation());
+                            continue;
+                        }
                         if ( src.getLocation().exists() )
                         {
                             List elist = src.getExcludes();
@@ -769,7 +803,19 @@
                                 }
                                 elist.addAll( FileUtils.getDefaultExcludesAsList() );
                             }
-                            copySource( src.getLocation(), dest, src.getIncludes(), elist );
+                            Map resultMap = copySource( src.getLocation(), dest, src.getIncludes(), elist );
+                            // getLog().info("Copier handled the following: ");
+                            Set keys = resultMap.keySet();
+                            /*
+                             * for (Iterator keysIt = keys.iterator(); keysIt.hasNext();) { Object object =
+                             * keysIt.next(); ArchiveEntry archiveEntry = (ArchiveEntry) resultMap.get(object);
+                             * getLog().info("key: [" + object.toString() + "], value: [" + archiveEntry.toString() +
+                             * "]"); } getLog().info("Copied source, map include dir is: " + map.isIncludeDirectory());
+                             */
+                            if ( !map.isIncludeDirectory() )
+                            {
+                                fillExtraMappings( extraMappings, map, src.getLocation(), keys );
+                            }
                         }
                         else
                         {
@@ -800,8 +846,71 @@
                 }
             }
         }
+
+        // getLog().info("Extra mappings size is: " + extraMappings.size());
+        mappings.addAll( extraMappings );
     }
 
+    private void fillExtraMappings( List extraMappings, Mapping map, File src, Set includes )
+    {
+        // getLog().info("Filling extra mappings for: " + map.getDirectory());
+        if ( src.isDirectory() )
+        {
+            for ( Iterator it = includes.iterator(); it.hasNext(); )
+            {
+                String value = (String) it.next();
+                if ( value.length() > 0 )
+                {
+                    extraMappings.add( createExtraMapping( map, map.getDirectory() + "/" + value ) );
+                }
+            }
+            /*
+             * String[] srcFiles = src.list(); if (srcFiles != null) { for (int i = 0; i < srcFiles.length; i++) { if
+             * (includes.contains(srcFiles[i])) { extraMappings.add(createExtraMapping(map, map.getDirectory() + "/" +
+             * srcFiles[i])); } } }
+             */
+        }
+        else
+        {
+            extraMappings.add( createExtraMapping( map, map.getDirectory() + "/" + src.getName() ) );
+        }
+    }
+
+    private Mapping createExtraMapping( Mapping map, String filename )
+    {
+        // getLog().info("Creating new mapping for: " + filename);
+        Mapping extraMap = new Mapping();
+        extraMap.setDirectory( filename );
+        extraMap.setArtifact( map.getArtifact() );
+        extraMap.setConfiguration( map.isConfiguration() );
+        extraMap.setDependency( map.getDependency() );
+        extraMap.setDocumentation( map.isDocumentation() );
+        extraMap.setFilemode( map.getFilemode() );
+        extraMap.setGroupname( map.getGroupname() );
+        extraMap.setUsername( map.getUsername() );
+        List sources = map.getSources();
+        List filteredSources = null;
+        if ( sources != null )
+        {
+            filteredSources = new ArrayList();
+            for ( Iterator sit = sources.iterator(); sit.hasNext(); )
+            {
+                Source src = (Source) sit.next();
+                // getLog().info("Filtering source #2: " + src.getLocation() + ", targetArch: [" + src.getTargetArch() +
+                // "]");
+                // filter files not for the targeted arch
+                if ( !StringUtils.isEmpty( src.getTargetArch() ) && !src.getTargetArch().equals( targetArch ) )
+                {
+                    continue;
+                }
+                filteredSources.add( src );
+            }
+        }
+        extraMap.setSources( filteredSources );
+        extraMap.setIncludeDirectory( true );
+        return extraMap;
+    }
+
     /**
      * Read a file into a string.
      * 
Index: src/main/java/org/codehaus/mojo/rpm/Mapping.java
===================================================================
--- src/main/java/org/codehaus/mojo/rpm/Mapping.java	(revision 8580)
+++ src/main/java/org/codehaus/mojo/rpm/Mapping.java	(working copy)
@@ -35,6 +35,9 @@
     /** Destination directory name. */
     private String directory;
 
+    /** Include directory in RPM? Default is yes. */
+    private boolean includeDirectory = true;
+
     /** <code>true</code> if the files are configuration. */
     private boolean configuration;
 
@@ -82,6 +85,22 @@
     }
 
     /**
+     * Include directory in package? If false, directory must exist already.
+     */
+    public boolean isIncludeDirectory()
+    {
+        return includeDirectory;
+    }
+
+    /**
+     * Set whether or not to include the directory in the package.
+     */
+    public void setIncludeDirectory( boolean includeDirectory )
+    {
+        this.includeDirectory = includeDirectory;
+    }
+
+    /**
      * Retrieve the configuration status. This value is <code>true</code> if the file(s) in this mapping are
      * configuration files.
      * 

