change setup dir to /usr & add rpm spec file

pull/48/head
liaozaixue 2014-08-19 15:04:14 +08:00
parent 711371cfb8
commit b832e104b2
5 changed files with 146 additions and 34 deletions

View File

@ -3,10 +3,10 @@
COMPILE = $(CC) $(CFLAGS) COMPILE = $(CC) $(CFLAGS)
ENABLE_STATIC_LIB = $(ENABLE_STATIC_LIB) ENABLE_STATIC_LIB = $(ENABLE_STATIC_LIB)
ENABLE_SHARED_LIB = $(ENABLE_SHARED_LIB) ENABLE_SHARED_LIB = $(ENABLE_SHARED_LIB)
INC_PATH = -I../common -I../tracker -I/usr/local/include INC_PATH = -I../common -I../tracker -I/usr/include
LIB_PATH = $(LIBS) LIB_PATH = $(LIBS)
TARGET_PATH = $(TARGET_PREFIX)/bin TARGET_PATH = $(TARGET_PREFIX)/bin
TARGET_LIB = $(TARGET_PREFIX)/lib TARGET_LIB = $(TARGET_PREFIX)/lib64
TARGET_INC = $(TARGET_PREFIX)/include TARGET_INC = $(TARGET_PREFIX)/include
CONFIG_PATH = $(TARGET_CONF_PATH) CONFIG_PATH = $(TARGET_CONF_PATH)
@ -77,17 +77,18 @@ ALL_PRGS = fdfs_monitor fdfs_test fdfs_test1 fdfs_crc32 fdfs_upload_file \
STATIC_LIBS = libfastcommon.a libfdfsclient.a STATIC_LIBS = libfastcommon.a libfdfsclient.a
SHARED_LIBS = libfastcommon.so.1 libfdfsclient.so.1 SHARED_LIBS = libfastcommon.so libfdfsclient.so
CLIENT_SHARED_LIBS = libfdfsclient.so
ALL_LIBS = $(STATIC_LIBS) $(SHARED_LIBS) ALL_LIBS = $(STATIC_LIBS) $(SHARED_LIBS)
all: $(ALL_OBJS) $(ALL_PRGS) $(ALL_LIBS) all: $(ALL_OBJS) $(ALL_PRGS) $(ALL_LIBS)
libfastcommon.so.1: libfastcommon.so:
$(COMPILE) -o $@ $< -shared $(FAST_SHARED_OBJS) $(LIB_PATH) $(COMPILE) -o $@ $< -shared $(FAST_SHARED_OBJS) $(LIB_PATH)
ln -fs libfastcommon.so.1 libfastcommon.so # ln -fs libfastcommon.so.1 libfastcommon.so
libfdfsclient.so.1: libfdfsclient.so:
$(COMPILE) -o $@ $< -shared $(FDFS_SHARED_OBJS) $(LIB_PATH) -L. -lfastcommon $(COMPILE) -o $@ $< -shared $(FDFS_SHARED_OBJS) $(LIB_PATH) -lfastcommon
ln -fs libfdfsclient.so.1 libfdfsclient.so # ln -fs libfdfsclient.so.1 libfdfsclient.so
libfastcommon.a: libfastcommon.a:
ar cru $@ $< $(FAST_STATIC_OBJS) ar cru $@ $< $(FAST_STATIC_OBJS)
libfdfsclient.a: libfdfsclient.a:
@ -106,19 +107,11 @@ install:
mkdir -p $(TARGET_LIB) mkdir -p $(TARGET_LIB)
cp -f $(ALL_PRGS) $(TARGET_PATH) cp -f $(ALL_PRGS) $(TARGET_PATH)
if [ $(ENABLE_STATIC_LIB) -eq 1 ]; then cp -f $(STATIC_LIBS) $(TARGET_LIB); fi if [ $(ENABLE_STATIC_LIB) -eq 1 ]; then cp -f $(STATIC_LIBS) $(TARGET_LIB); fi
if [ $(ENABLE_SHARED_LIB) -eq 1 ]; then cp -f $(SHARED_LIBS) $(TARGET_LIB); fi if [ $(ENABLE_SHARED_LIB) -eq 1 ]; then cp -f $(CLIENT_SHARED_LIBS) $(TARGET_LIB); fi
if [ $(ENABLE_SHARED_LIB) -eq 1 ]; then ln -fs $(TARGET_LIB)/libfastcommon.so.1 $(TARGET_LIB)/libfastcommon.so; fi
if [ $(ENABLE_SHARED_LIB) -eq 1 ]; then ln -fs $(TARGET_LIB)/libfdfsclient.so.1 $(TARGET_LIB)/libfdfsclient.so; fi
if [ ! -f $(CONFIG_PATH)/client.conf ]; then cp -f ../conf/client.conf ../conf/http.conf $(CONFIG_PATH); fi
mkdir -p $(TARGET_INC)
mkdir -p $(TARGET_INC)/fastcommon
mkdir -p $(TARGET_INC)/fastdfs mkdir -p $(TARGET_INC)/fastdfs
cp -f $(FAST_HEADER_FILES) $(TARGET_INC)/fastcommon
cp -f $(FDFS_HEADER_FILES) $(TARGET_INC)/fastdfs cp -f $(FDFS_HEADER_FILES) $(TARGET_INC)/fastdfs
if [ ! -f $(CONFIG_PATH)/client.conf ]; then cp -f ../conf/client.conf $(CONFIG_PATH)/client.conf.sample; fi
if [ $(ENABLE_SHARED_LIB) -eq 1 -a $(TARGET_LIB) = "/usr/local/lib" ]; then sh ./fdfs_link_library.sh; fi
clean: clean:
rm -f $(ALL_OBJS) $(ALL_PRGS) $(ALL_LIBS) libfastcommon.so libfdfsclient.so rm -f $(ALL_OBJS) $(ALL_PRGS) $(ALL_LIBS)

120
fastdfs.spec Normal file
View File

@ -0,0 +1,120 @@
%define FastDFS fastdfs
%define FastdfsServer fastdfs-server
%define ClientName libfdfsclient
%define FastTool fastdfs-tool
%define FastVersion 5.0.3
Name: %{FastDFS}
Version: %{FastVersion}
Release: 1%{?dist}
Summary: The fastdfs manager
License: GPL
Group: Arch/Tech
URL: http://perso.orange.fr/sebastien.godard/
Source: http://perso.orange.fr/sebastien.godard/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires: %__cp %__mv %__chmod %__grep %__mkdir %__install %__id
%description
This package provides tracker & storage of fastdfs
%package -n %{FastdfsServer}
Summary: fastdfs tracker & storage
%package -n %{FastTool}
Requires: libfastcommon
Summary: fastdfs tools
%package -n %{ClientName}
Requires: libfastcommon
Summary: The client dynamic library of fastdfs
%package -n %{ClientName}-devel
Requires: %{ClientName}
Summary: The client header of fastdfs
%description -n %{FastdfsServer}
This package provides tracker & storage of fastdfs
%description -n %{ClientName}
This package is client dynamic library of fastdfs
%description -n %{ClientName}-devel
This package is client header of fastdfs
%description -n %{FastTool}
This package is tools for fastdfs
%prep
%setup -q
%build
# FIXME: I need to fix the upstream Makefile to use LIBDIR et al. properly and
# send the upstream maintainer a patch.
# add DOCDIR to the configure part
./make.sh
%install
rm -rf %{buildroot}
DESTDIR=$RPM_BUILD_ROOT ./make.sh install
#make install IGNORE_MAN_GROUP=y DOC_DIR=%{_docdir}/%{name}-%{version} INIT_DIR=%{_initrddir}
#install -m 0644 sysstat.crond %{buildroot}/%{_sysconfdir}/cron.d/sysstat
#%find_lang %{name}
%post -n %{FastdfsServer}
/sbin/chkconfig --add fdfs_trackerd
/sbin/chkconfig --add fdfs_storaged
%preun -n %{FastdfsServer}
/sbin/chkconfig --del fdfs_trackerd
/sbin/chkconfig --del fdfs_storaged
%postun
%clean
#rm -rf %{buildroot}
%files
#%defattr(-,root,root,-)
#/usr/local/bin/*
#/usr/local/include/*
%files -n %{FastdfsServer}
%defattr(-,root,root,-)
/usr/bin/fdfs_trackerd
/usr/bin/fdfs_storaged
/usr/bin/restart.sh
/usr/bin/stop.sh
/etc/init.d/*
/etc/fdfs/tracker.conf.sample
/etc/fdfs/storage.conf.sample
%files -n %{ClientName}
/usr/lib64/libfdfsclient*
/etc/fdfs/client.conf.sample
%files -n %{ClientName}-devel
%defattr(-,root,root,-)
/usr/include/fastdfs/*
%files -n %{FastTool}
/usr/bin/fdfs_monitor
/usr/bin/fdfs_test
/usr/bin/fdfs_test1
/usr/bin/fdfs_crc32
/usr/bin/fdfs_upload_file
/usr/bin/fdfs_download_file
/usr/bin/fdfs_delete_file
/usr/bin/fdfs_file_info
/usr/bin/fdfs_appender_test
/usr/bin/fdfs_appender_test1
/usr/bin/fdfs_append_file
/usr/bin/fdfs_upload_appender
%changelog
* Mon Jun 23 2014 Zaixue Liao <liaozaixue@yongche.com>
- first RPM release (1.0)

25
make.sh
View File

@ -58,10 +58,11 @@ EOF
ENABLE_STATIC_LIB=0 ENABLE_STATIC_LIB=0
ENABLE_SHARED_LIB=1 ENABLE_SHARED_LIB=1
TARGET_PREFIX=/usr/local TARGET_PREFIX=$DESTDIR/usr
TARGET_CONF_PATH=/etc/fdfs TARGET_CONF_PATH=$DESTDIR/etc/fdfs
TARGET_INIT_PATH=$DESTDIR/etc/init.d
#WITH_LINUX_SERVICE=1 WITH_LINUX_SERVICE=1
DEBUG_FLAG=1 DEBUG_FLAG=1
@ -194,17 +195,15 @@ if [ "$1" = "install" ]; then
if [ "$WITH_LINUX_SERVICE" = "1" ]; then if [ "$WITH_LINUX_SERVICE" = "1" ]; then
if [ ! -d /etc/fdfs ]; then if [ ! -d /etc/fdfs ]; then
mkdir -p /etc/fdfs mkdir -p /etc/fdfs
cp -f conf/tracker.conf /etc/fdfs/ cp -f conf/tracker.conf $TARGET_CONF_PATH/tracker.conf.sample
cp -f conf/storage.conf /etc/fdfs/ cp -f conf/storage.conf $TARGET_CONF_PATH/storage.conf.sample
cp -f conf/client.conf /etc/fdfs/ cp -f conf/client.conf $TARGET_CONF_PATH/client.conf.sample
cp -f conf/http.conf /etc/fdfs/
cp -f conf/mime.types /etc/fdfs/
fi fi
mkdir -p $TARGET_INIT_PATH
cp -f init.d/fdfs_trackerd /etc/rc.d/init.d/ cp -f init.d/fdfs_trackerd $TARGET_INIT_PATH
cp -f init.d/fdfs_storaged /etc/rc.d/init.d/ cp -f init.d/fdfs_storaged $TARGET_INIT_PATH
/sbin/chkconfig --add fdfs_trackerd # /sbin/chkconfig --add fdfs_trackerd
/sbin/chkconfig --add fdfs_storaged # /sbin/chkconfig --add fdfs_storaged
fi fi
fi fi
fi fi

View File

@ -44,6 +44,6 @@ install:
mkdir -p $(TARGET_PATH) mkdir -p $(TARGET_PATH)
mkdir -p $(CONFIG_PATH) mkdir -p $(CONFIG_PATH)
cp -f $(ALL_PRGS) $(TARGET_PATH) cp -f $(ALL_PRGS) $(TARGET_PATH)
if [ ! -f $(CONFIG_PATH)/storage.conf ]; then cp -f ../conf/storage.conf ../conf/mime.types ../conf/http.conf $(CONFIG_PATH); fi if [ ! -f $(CONFIG_PATH)/storage.conf ]; then cp -f ../conf/storage.conf $(CONFIG_PATH)/storage.conf.sample; fi
clean: clean:
rm -f $(ALL_OBJS) $(ALL_PRGS) rm -f $(ALL_OBJS) $(ALL_PRGS)

View File

@ -34,6 +34,6 @@ install:
mkdir -p $(TARGET_PATH) mkdir -p $(TARGET_PATH)
mkdir -p $(CONFIG_PATH) mkdir -p $(CONFIG_PATH)
cp -f $(ALL_PRGS) $(TARGET_PATH) cp -f $(ALL_PRGS) $(TARGET_PATH)
if [ ! -f $(CONFIG_PATH)/tracker.conf ]; then cp -f ../conf/tracker.conf ../conf/mime.types ../conf/http.conf $(CONFIG_PATH); fi if [ ! -f $(CONFIG_PATH)/tracker.conf ]; then cp -f ../conf/tracker.conf $(CONFIG_PATH)/tracker.conf.sample; fi
clean: clean:
rm -f $(ALL_OBJS) $(ALL_PRGS) rm -f $(ALL_OBJS) $(ALL_PRGS)