 
     File.write!(dest, contents)
     config
+  end
+
+  defp normalize_version(version) do
+    version |> String.split([".", "-"]) |> Enum.map(fn(segment) ->  Regex.replace(~r/[^0-9]+/, segment, "") end) |> Enum.join(".")
   end
 
   defp copy_extra_sources(config) do

        rpmbuild:        @_RPM_BUILD_TOOL,
        rpmbuild_opts:   @_RPM_BUILD_ARGS,
        priv_path:       Path.join([__DIR__, "..", "..", "priv"]) |> Path.expand,
        sources_path:    Path.join([build_dir, "SOURCES", app_name]),
        target_rpm_path: Path.join([File.cwd!, "rel", name, "releases", version, rpm_file_name(name, version, build_arch)]),
        app_tar_path:    Path.join([File.cwd!, "rel", name, app_name]),
        summary:         @_DEFAULT_SUMMARY,


    contents = File.read!(spec)
    |> String.replace(@_NAME, config.name)
    |> String.replace(@_VERSION, config.version |> normalize_version)
    |> String.replace(@_TOPDIR, config.build_dir)
    |> String.replace(@_BUILD_ARCH, config.build_arch)
    |> String.replace(@_SUMMARY, config.summary)
