rpms/jpackage-utils/devel abs2rel.lua, NONE, 1.1 abs2rel.sh, NONE, 1.1 jpackage-utils.spec, 1.51, 1.52

Michel Alexandre Salim salimma at fedoraproject.org
Tue May 4 19:25:37 UTC 2010


Author: salimma

Update of /cvs/pkgs/rpms/jpackage-utils/devel
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv23991/devel

Modified Files:
	jpackage-utils.spec 
Added Files:
	abs2rel.lua abs2rel.sh 
Log Message:
* Tue May  4 2010 Michel Salim <salimma at fedoraproject.org> - 0:1.7.5-3.10
- Add Lua abs2rel script



--- NEW FILE abs2rel.lua ---
--[[
abs2rel for Lua

split and split_path taken from "Split a string with a pattern, Take Two"
  http://lua-users.org/wiki/SplitJoin
--]]

function split(str, pat)
   local t = {}  -- NOTE: use {n = 0} in Lua-5.0
   local fpat = "(.-)" .. pat
   local last_end = 1
   local s, e, cap = str:find(fpat, 1)
   while s do
      if s ~= 1 or cap ~= "" then
	 table.insert(t,cap)
      end
      last_end = e+1
      s, e, cap = str:find(fpat, last_end)
   end
   if last_end <= #str then
      cap = str:sub(last_end)
      table.insert(t, cap)
   end
   return t
end

function split_path(str)
   return split(str,'[\\/]+')
end

-- parts = split_path("/usr/local/bin")
--> {'usr','local','bin'}

function join(words, sep)
   local s = ""
   for i,v in ipairs(words) do
      s = s .. sep .. v
   end
   return string.sub (s, string.len(sep)+1)
end

function abs2rel (path, base)
   if path == base then return "." end
   local pathdirs = split_path (path)
   local basedirs = split_path (base)
   local i = 1
   local rem_i = math.min(#pathdirs, #basedirs)

   -- remove common parts of both paths
   while (rem_i > 0) and (pathdirs[i] == basedirs[i]) do
      rem_i = rem_i - 1
      table.remove(pathdirs, 1)
      table.remove(basedirs, 1)
   end

   -- now for each remaining basedirs, replace them with ..
   if #basedirs > 0 then
      for i, v in ipairs(basedirs) do
	 basedirs[i] = ".."
      end
   end
   for i, v in ipairs(pathdirs) do
      basedirs[#basedirs+1] = v
   end
   return join(basedirs, "/")
end


--- NEW FILE abs2rel.sh ---
#!/bin/sh
(cd `dirname $0` && lua -l abs2rel -e "print(abs2rel(\"$1\", \"$2\"))")



Index: jpackage-utils.spec
===================================================================
RCS file: /cvs/pkgs/rpms/jpackage-utils/devel/jpackage-utils.spec,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -p -r1.51 -r1.52
--- jpackage-utils.spec	30 Apr 2010 21:00:18 -0000	1.51
+++ jpackage-utils.spec	4 May 2010 19:25:36 -0000	1.52
@@ -34,13 +34,15 @@
 
 Name:           jpackage-utils
 Version:        1.7.5
-Release:        3.9%{?dist}
+Release:        3.10%{?dist}
 Epoch:          0
 Summary:        JPackage utilities
 License:        BSD
 URL:            http://www.jpackage.org/
 Source0:        %{name}-%{version}.tar.bz2
 Source1:        %{name}-README
+Source2:	abs2rel.sh
+Source3:	abs2rel.lua
 Patch0:         %{name}-enable-gcj-support.patch
 Patch1:         %{name}-own-mavendirs.patch
 Patch2:         %{name}-prefer-jre.patch
@@ -65,7 +67,7 @@ information.
 %patch1 -p1
 %patch2 -p1
 
-cp %{SOURCE1} .
+cp -p %{SOURCE1} %{SOURCE2} %{SOURCE3} .
 
 %build
 echo "JPackage release %{distver} (%{distribution}) for %{buildarch}" \
@@ -118,6 +120,10 @@ install -dm 755 ${RPM_BUILD_ROOT}${_mave
 install -pm 755 bin/* ${RPM_BUILD_ROOT}%{_bindir}
 install -pm 644 etc/font.properties ${RPM_BUILD_ROOT}%{_sysconfdir}/java
 
+# Install abs2rel scripts
+install -pm 755 abs2rel.sh  ${RPM_BUILD_ROOT}%{_javadir}-utils
+install -pm 644 abs2rel.lua ${RPM_BUILD_ROOT}%{_javadir}-utils
+
 # Create an initial (empty) depmap
 echo -e "<dependencies>\\n" \
   > ${RPM_BUILD_ROOT}${_mavendepmapdir}/maven2-depmap.xml
@@ -205,6 +211,9 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Tue May  4 2010 Michel Salim <salimma at fedoraproject.org> - 0:1.7.5-3.10
+- Add Lua abs2rel script
+
 * Fri Apr 30 2010 Deepak Bhole <dbhole at redhat.com> - 0:1.7.5-3.9
 - Stopgap fix for rhbz#461683 from Ville Skyttä.
 



More information about the scm-commits mailing list