From 7748c21bb98ce88bbfa4357cb65f901c8e41c8d4 Mon Sep 17 00:00:00 2001 From: Peter Lemenkov Date: Apr 14 2010 10:03:40 +0000 Subject: Added rpm macros and more cleanups --- diff --git a/erlang-find-provides.escript b/erlang-find-provides.escript new file mode 100755 index 0000000..4433337 --- /dev/null +++ b/erlang-find-provides.escript @@ -0,0 +1,24 @@ +#!/usr/bin/escript +%% -*- erlang -*- + +main(EbinFiles) -> + lists:foreach( + fun(BeamFile) -> + try + {ok, {Module, [{exports,Exports}]}} = beam_lib:chunks(BeamFile, [exports]), + case Module of + eunit_test -> io:format ("erlang(eunit_test:nonexisting_function/0)~n"); + wx -> io:format ("erlang(demo:start/0)~n"); + _ -> ok + end, + lists:foreach( fun({ModFun,Arity})->io:format("erlang(~p:~s/~p)~n", [Module, ModFun,Arity]) end, Exports) + catch + _:_ -> + ok + end + end, + EbinFiles); + +main(_) -> + halt(1). + diff --git a/erlang-find-provides.sh b/erlang-find-provides.sh new file mode 100755 index 0000000..0592130 --- /dev/null +++ b/erlang-find-provides.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +# This script reads filenames from STDIN and outputs any relevant provides +# information that needs to be included in the package. + +BUILDDIR= + +while true; do + case "$1" in + -b) BUILDDIR="$2"; shift 2;; + --) shift; break;; + *) echo "$0: option error at $1"; exit 1;; + esac +done + +filelist=`sed "s/['\"]/\\\&/g"` + +/usr/lib/rpm/rpmdeps --provides $filelist + +# Get the list of *.app files +appfiles=$(echo $filelist | tr [:blank:] '\n' | grep -o -E '.*/ebin/.*\.app$') + +for f in $appfiles; do + app=`cat $f | tr -d [:space:] | awk -F '{application,' '{print $2}'|cut -d , -f 1` + ver=`cat $f | tr -d [:space:] | grep -o -E '\{vsn,\".*[0-9]\"\}' | sed -e "s,.vsn\,\",,g;s,\".,,g"` + + # HiPE module is different from others + if [ "$app" == "hipe" ] ; + then + # Hardcoded minimal set of HiPE exported functions + echo "erlang(hipe_amd64_main:rtl_to_amd64/3)" + echo "erlang(hipe_arm_main:rtl_to_arm/3)" + echo "erlang(hipe:c/1)" + echo "erlang(hipe:compile/4)" + echo "erlang(hipe_data_pp:pp/4)" + echo "erlang(hipe_icode2rtl:translate/2)" + echo "erlang(hipe_icode_heap_test:cfg/1)" + echo "erlang(hipe_ppc_main:rtl_to_ppc/3)" + echo "erlang(hipe_rtl_arch:endianess/0)" + echo "erlang(hipe_rtl_arch:nr_of_return_regs/0)" + echo "erlang(hipe_rtl_arch:word_size/0)" + echo "erlang(hipe_rtl_cfg:init/1)" + echo "erlang(hipe_rtl_cfg:linearize/1)" + echo "erlang(hipe_rtl_cfg:pp/1)" + echo "erlang(hipe_rtl_cfg:remove_trivial_bbs/1)" + echo "erlang(hipe_rtl_cfg:remove_unreachable_code/1)" + echo "erlang(hipe_rtl_cleanup_const:cleanup/1)" + echo "erlang(hipe_rtl_lcm:rtl_lcm/2)" + echo "erlang(hipe_rtl_ssa_avail_expr:cfg/1)" + echo "erlang(hipe_rtl_ssa:check/1)" + echo "erlang(hipe_rtl_ssa_const_prop:propagate/1)" + echo "erlang(hipe_rtl_ssa:convert/1)" + echo "erlang(hipe_rtl_ssapre:rtl_ssapre/2)" + echo "erlang(hipe_rtl_ssa:remove_dead_code/1)" + echo "erlang(hipe_rtl_ssa:unconvert/1)" + echo "erlang(hipe_rtl_symbolic:expand/1)" + echo "erlang(hipe_sparc_main:rtl_to_sparc/3)" + echo "erlang(hipe_tagscheme:fixnum_val/1)" + echo "erlang(hipe_tagscheme:is_fixnum/1)" + echo "erlang(hipe_x86_main:rtl_to_x86/3)" + fi + + echo "erlang($app) = $ver" +done + +# Check for very special case - erts, by guessing by directory name +basedirs=$(echo $filelist | tr [:blank:] '\n' | grep -o -E 'erlang\/lib\/[a-zA-Z_0-9]*-[0-9.]*\/ebin' | cut -d \/ -f 3 | sort | uniq) +for bd in $basedirs; do + basename=`echo $bd | cut -d \- -f 1` + basever=`echo $bd | cut -d \- -f 2` + case $basename in + "erts") + echo "erlang($basename) = $basever" + + # BIFs from erts - this module is very specific + cat $BUILDDIR/erts/emulator/*/erl_bif_list.h 2>/dev/null |\ + grep -v am__AtomAlias |\ + grep -o -E 'am_.*\,am_.*\,.\,' |\ + sed s,am_,,g |\ + sed -e "s,Plus,+,g;s,Minus,-,g;s,Neqeq,=\/=,g;s,Neq,\/=,g;s,Div,\/,g;s,Eqeq,=\:=,g;s,Eq,==,g;s,Ge,>=,g;s,Gt,>,g;s,Le,=<,g;s,Lt,<,g;s,Times,*,g;s,subtract,--,g;s,append\,,++\,,g" |\ + awk -F \, '{print "erlang(" $1 ":" $2 "/" $3 ")" }' + + # Add BIFs for HiPE + grep "bif " $BUILDDIR/erts/emulator/hipe/*.tab | awk -F "bif " '{print "erlang(" $2 ")"}' + ;; + "wx") + echo "erlang($basename) = $basever" + ;; + *) + ;; + esac +done + +# Get the list of *.beam files +beamfiles=$(echo $filelist | tr [:blank:] '\n' | grep -o -E '.*/ebin/.*\.beam$') +/usr/lib/rpm/erlang-find-provides.escript $beamfiles | sed s,\',,g + diff --git a/erlang-find-requires.escript b/erlang-find-requires.escript new file mode 100755 index 0000000..1a16f76 --- /dev/null +++ b/erlang-find-requires.escript @@ -0,0 +1,19 @@ +#!/usr/bin/escript +%% -*- erlang -*- + +main(EbinFiles) -> + lists:foreach( + fun(BeamFile) -> + try + {ok, {_Module, [{imports,Imports}]}} = beam_lib:chunks(BeamFile, [imports]), + lists:foreach( fun({ModName,ModFun,Arity})->io:format("erlang(~s:~s/~p)~n", [ModName,ModFun,Arity]) end, Imports) + catch + _:_ -> + ok + end + end, + EbinFiles); + +main(_) -> + halt(1). + diff --git a/erlang-find-requires.sh b/erlang-find-requires.sh new file mode 100755 index 0000000..de6a87f --- /dev/null +++ b/erlang-find-requires.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# This script reads filenames from STDIN and outputs any relevant requires +# information that needs to be included in the package. + +filelist=`sed "s/['\"]/\\\&/g"` + +/usr/lib/rpm/rpmdeps --requires $filelist + +# Get the list of *.app files +appfiles=$(echo $filelist | tr [:blank:] '\n' | grep -o -E '.*/ebin/.*\.app$') + +for f in $appfiles; do + apps=`cat $f | tr -d [:space:] | grep -o -E '\{applications,\[.*[a-zA-Z0-9_]\]\}' | sed -e "s,.*\[,,g;s,\].*,,g;s.,. .g"` + for a in $apps; do + echo "erlang($a)" + done +done + +# Get the list of *.beam files +beamfiles=$(echo $filelist | tr [:blank:] '\n' | grep -o -E '.*/ebin/.*\.beam$') +/usr/lib/rpm/erlang-find-requires.escript $beamfiles | sort | uniq + diff --git a/erlang.spec b/erlang.spec index b53835d..d157cfb 100644 --- a/erlang.spec +++ b/erlang.spec @@ -3,7 +3,7 @@ Name: erlang Version: %{ver} -Release: %{rel}.2%{?dist} +Release: %{rel}.3%{?dist} Summary: General-purpose programming language and runtime environment Group: Development/Languages @@ -12,6 +12,11 @@ URL: http://www.erlang.org Source: http://www.erlang.org/download/otp_src_%{ver}%{rel}.tar.gz Source1: http://www.erlang.org/download/otp_doc_html_%{ver}%{rel}.tar.gz Source2: http://www.erlang.org/download/otp_doc_man_%{ver}%{rel}.tar.gz +Source3: erlang-find-provides.escript +Source4: erlang-find-provides.sh +Source5: erlang-find-requires.escript +Source6: erlang-find-requires.sh +Source7: macros.erlang # TODO this patch needs rebase against current tree Patch0: otp-links.patch Patch1: otp-0001-Do-not-format-man-pages.patch @@ -75,9 +80,11 @@ find $RPM_BUILD_ROOT%{_libdir}/erlang -name \*.o | xargs chmod 644 find $RPM_BUILD_ROOT%{_libdir}/erlang -name \*.bat | xargs rm -f find $RPM_BUILD_ROOT%{_libdir}/erlang -name index.txt.old | xargs rm -f -# doc +# install additional doc files mkdir -p erlang_doc tar -C erlang_doc -zxf %{SOURCE1} + +# install man-pages tar -C $RPM_BUILD_ROOT%{_libdir}/erlang -zxf %{SOURCE2} gzip $RPM_BUILD_ROOT%{_libdir}/erlang/man/man*/* @@ -94,9 +101,33 @@ cd $RPM_BUILD_ROOT%{_libdir}/erlang sed -i "s|$RPM_BUILD_ROOT||" erts*/bin/{erl,start} releases/RELEASES bin/{erl,start} # remove unneeded sources, but keep *.hrl and *.yrl -for d in $RPM_BUILD_ROOT%{_libdir}/erlang/lib/* ; do find $d/src -maxdepth 1 -type f ! -name "*.[yh]rl" -print -delete || true ; done +for d in $RPM_BUILD_ROOT%{_libdir}/erlang/lib/* ; do find $d/src -maxdepth 1 -type f ! -name "*.hrl" -print -delete || true ; done +rm -f $RPM_BUILD_ROOT%{_libdir}/erlang/lib/hipe-*/{cerl,flow,icode,main,misc,util}/*.erl +rm -f $RPM_BUILD_ROOT%{_libdir}/erlang/lib/orber-*/COSS/CosNaming/*.erl +rm -f $RPM_BUILD_ROOT%{_libdir}/erlang/lib/snmp-*/src/{agent,app,compiler,manager,misc}/*.erl +rm -f $RPM_BUILD_ROOT%{_libdir}/erlang/lib/wx-*/src/gen/*.erl find $RPM_BUILD_ROOT%{_libdir}/erlang/lib/ -maxdepth 2 -type d -name src -empty -delete +# remove C and Java sources +rm -rf $RPM_BUILD_ROOT%{_libdir}/erlang/lib/asn1-*/c_src +rm -rf $RPM_BUILD_ROOT%{_libdir}/erlang/lib/erl_interface-*/src +rm -rf $RPM_BUILD_ROOT%{_libdir}/erlang/lib/ic-*/c_src +rm -rf $RPM_BUILD_ROOT%{_libdir}/erlang/lib/ic-*/java_src +rm -rf $RPM_BUILD_ROOT%{_libdir}/erlang/lib/jinterface-*/java_src +rm -rf $RPM_BUILD_ROOT%{_libdir}/erlang/lib/odbc-*/c_src +rm -rf $RPM_BUILD_ROOT%{_libdir}/erlang/lib/tools-*/c_src + +# remove empty or intermediate files and directories +rm -r $RPM_BUILD_ROOT%{_libdir}/erlang/erts-*/doc +rm -r $RPM_BUILD_ROOT%{_libdir}/erlang/erts-*/man +rm -f $RPM_BUILD_ROOT%{_libdir}/erlang/lib/cosEvent-*/info +rm -f $RPM_BUILD_ROOT%{_libdir}/erlang/lib/cosEventDomain-*/info +rm -rf $RPM_BUILD_ROOT%{_libdir}/erlang/lib/crypto-*/priv/obj +rm -rf $RPM_BUILD_ROOT%{_libdir}/erlang/lib/hipe-*/vsn.mk +rm -r $RPM_BUILD_ROOT%{_libdir}/erlang/lib/odbc-*/priv/obj +rm -rf $RPM_BUILD_ROOT%{_libdir}/erlang/lib/ssl-*/priv/obj +rm -rf $RPM_BUILD_ROOT%{_libdir}/erlang/misc + # fix permissions for asn1 library chmod 755 $RPM_BUILD_ROOT%{_libdir}/erlang/lib/asn1-*/priv/lib/asn1_erl_drv.so @@ -107,6 +138,13 @@ chmod 755 $RPM_BUILD_ROOT%{_libdir}/erlang/lib/megaco-*/priv/lib/megaco_flex_sca # fix permissons for wx library chmod 755 $RPM_BUILD_ROOT%{_libdir}/erlang/lib/wx-*/priv/*/wxe_driver.so +# Install RPM related files +install -D -p -m 0755 %{SOURCE3} $RPM_BUILD_ROOT%{_libdir}/rpm/erlang-find-provides.escript +install -D -p -m 0755 %{SOURCE4} $RPM_BUILD_ROOT%{_libdir}/rpm/erlang-find-provides.sh +install -D -p -m 0755 %{SOURCE5} $RPM_BUILD_ROOT%{_libdir}/rpm/erlang-find-requires.escript +install -D -p -m 0755 %{SOURCE6} $RPM_BUILD_ROOT%{_libdir}/rpm/erlang-find-requires.sh +install -D -p -m 0644 %{SOURCE7} $RPM_BUILD_ROOT%{_sysconfdir}/rpm/macros.erlang + %clean rm -rf $RPM_BUILD_ROOT @@ -118,6 +156,13 @@ rm -rf $RPM_BUILD_ROOT %{_bindir}/* %{_libdir}/erlang +# RPM stuff +%{_sysconfdir}/rpm/macros.erlang +%{_libdir}/rpm/erlang-find-provides.escript +%{_libdir}/rpm/erlang-find-provides.sh +%{_libdir}/rpm/erlang-find-requires.escript +%{_libdir}/rpm/erlang-find-requires.sh + %files doc %defattr(-,root,root) @@ -129,6 +174,11 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Fri Mar 26 2010 Peter Lemenkov - R13B-04.3 +- Added rpm-related stuff for auto-generating erlang dependencies in the future builds +- Since now *.yrl files are removed too. +- Removed unnecessary C and Java sources + * Fri Mar 26 2010 Peter Lemenkov - R13B-04.2 - Do not remove all files from %%{_libdir}/erlang/lib/*/src - keep *.[yh]rl intact diff --git a/import.log b/import.log index 9a70af5..5537ce7 100644 --- a/import.log +++ b/import.log @@ -1,2 +1,3 @@ erlang-R13B-04_1_fc12:F-12:erlang-R13B-04.1.fc12.src.rpm:1268837646 erlang-R13B-04_2_fc12:F-12:erlang-R13B-04.2.fc12.src.rpm:1269609314 +erlang-R13B-04_3_fc12:F-12:erlang-R13B-04.3.fc12.src.rpm:1271239367 diff --git a/macros.erlang b/macros.erlang new file mode 100644 index 0000000..88542e0 --- /dev/null +++ b/macros.erlang @@ -0,0 +1,13 @@ +# handy macros for erlang-related packages + +%_erldir %{_libdir}/erlang +%_erllibdir %{_erldir}/lib + +%__erlang_provides %{_rpmconfigdir}/erlang-find-provides.sh -b %{_builddir}/%{buildsubdir} -- +%__erlang_requires %{_rpmconfigdir}/erlang-find-requires.sh + +%__erlang_provides_requires \ +%global _use_internal_dependency_generator 0\ +%global __find_provides %__erlang_provides\ +%global __find_requires %__erlang_requires\ +%{nil}