Skip to content

Commit

Permalink
Merge pull request #41 from 45Drives/package-el8
Browse files Browse the repository at this point in the history
Package el8
  • Loading branch information
joshuaboud authored Apr 8, 2021
2 parents bb34510 + 840f007 commit bf809aa
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docker/el8
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM centos:8

LABEL description="Container in which to build el8 applications"

ENV TZ=America/Glace_Bay
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN dnf group install -y "Development Tools"
RUN dnf install -y rpm-build rpm-devel rpmlint make python3 bash diffutils patch rpmdevtools boost-devel tbb-devel gcc-toolset-9-gcc gcc-toolset-9-gcc-c++ fuse3-devel
ENV PATH=/opt/rh/gcc-toolset-9/root/usr/bin:$PATH

# install powertools
RUN dnf install -y dnf-plugins-core
RUN dnf config-manager -y --set-enabled powertools

# install rocksdb devel
RUN dnf install -y gflags gflags-devel snappy snappy-devel zlib zlib-devel bzip2 bzip2-devel lz4-devel libzstd-devel wget boost-static lz4-libs zlib-static
RUN wget https://github.com/facebook/rocksdb/archive/v6.1.2.zip && \
unzip v6.1.2.zip && \
cd rocksdb-6.1.2 && \
PORTABLE=1 DISABLE_WARNING_AS_ERROR=1 make -j8 static_lib && \
INSTALL_PATH=/usr make install-static && \
cd .. && \
rm -rf rocksdb-6.1.2 v6.1.2.zip

RUN mkdir -p /home/rpm/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS,tmp}

RUN echo %_topdir /home/rpm/rpmbuild > /etc/rpm/macros
RUN echo %_tmppath %{_topdir}/tmp >> /etc/rpm/macros

RUN chmod -R 777 /home/rpm
46 changes: 46 additions & 0 deletions el8/autotier.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
%define __spec_install_post %{nil}
%define debug_package %{nil}
%define __os_install_post %{_dbpath}/brp-compress

Name: autotier
Version: 1.1.3
Release: 1%{?dist}
Summary: Tiered FUSE Passthrough Filesystem

License: GPL-3.0+
URL: github.com/45drives/autotier/blob/master/README.md
Source0: %{name}-%{version}.tar.gz

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

%description
A passthrough FUSE filesystem that intelligently moves files
between storage tiers based on frequency of use, file age, and tier fullness.

%prep
%setup -q

%build
make EXTRA_CFLAGS="-DEL8" EXTRA_LIBS="-lz -lzstd -llz4 -lbz2 -lsnappy" -j8

%install
make DESTDIR=%{buildroot} PACKAGING=1 install

%clean
make DESTDIR=%{buildroot} clean

%files
%defattr(-,root,root,-)
%config %{_sysconfdir}/autotier.conf
%{_bindir}/*
/opt/45drives/%{name}/*
%docdir /usr/share/man/man8
%doc /usr/share/man/man8/*
/usr/share/bash-completion/completions/*

%post
groupadd -f autotier

%changelog
* Thu Apr 08 2021 Josh Boudreau <[email protected]> 1.1.3.-1
- First EL8 build.
3 changes: 3 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ CLI_LIBS = -l:libboost_system.a -l:libboost_filesystem.a
CC = g++
CFLAGS = -Wall -Wextra -Isrc/incl -I/usr/include/fuse3 -D_FILE_OFFSET_BITS=64

FS_LIBS += $(EXTRA_LIBS)
CFLAGS += $(EXTRA_CFLAGS)

FS_SOURCE_FILES := $(shell find src/impl/autotierfs -name *.cpp)
FS_OBJECT_FILES := $(patsubst src/impl/%.cpp, build/%.o, $(FS_SOURCE_FILES))

Expand Down
20 changes: 20 additions & 0 deletions package-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

# Copyright (C) 2019-2021 Joshua Boudreau <[email protected]>
#
# This file is part of autotier.
#
# autotier is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# autotier is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with autotier. If not, see <https://www.gnu.org/licenses/>.

./package-deb.sh && ./package-el8.sh
72 changes: 72 additions & 0 deletions package-el8.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env bash

# Copyright (C) 2019-2021 Joshua Boudreau <[email protected]>
#
# This file is part of autotier.
#
# autotier is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# autotier is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with autotier. If not, see <https://www.gnu.org/licenses/>.

TMP_DIR=/tmp/autotier

if [[ "$#" == 1 && "$1" == "clean" ]]; then
rm -rf $TMP_DIR
rm -rf dist/el8
exit 0
fi

command -v docker > /dev/null 2>&1 || {
echo "Please install docker.";
exit 1;
}

# if docker image DNE, build it
if [[ "$(docker images -q autotier-el8-builder 2> /dev/null)" == "" ]]; then
docker build -t autotier-el8-builder - < docker/el8
res=$?
if [ $res -ne 0 ]; then
echo "Building docker image failed."
exit $res
fi
fi

make clean

mkdir -p dist/el8
mkdir -p $TMP_DIR

# Tar up source
SOURCE_NAME=autotier-$(grep Version el8/autotier.spec --color=never | awk '{print $2}')
SOURCE_PATH=$TMP_DIR/$SOURCE_NAME
mkdir -p $SOURCE_PATH
SOURCE_LOC="$(dirname "$SOURCE_PATH")"

cp -r src/ makefile doc/ $SOURCE_PATH

pushd $SOURCE_LOC
tar -czvf $SOURCE_NAME.tar.gz $SOURCE_NAME
popd

# build rpm from source tar and place it dist/el8 by mirroring dist/el8 to rpmbuild/RPMS
docker run -u $(id -u):$(id -g) -w /home/rpm/rpmbuild -it -v$SOURCE_LOC:/home/rpm/rpmbuild/SOURCES -v$(pwd)/dist/el8:/home/rpm/rpmbuild/RPMS -v$(pwd)/el8:/home/rpm/rpmbuild/SPECS --rm autotier-el8-builder rpmbuild -ba SPECS/autotier.spec
res=$?
if [ $res -ne 0 ]; then
echo "Packaging failed."
exit $res
fi

rm -rf $SOURCE_LOC

echo "rpm is in dist/el8/"

exit 0
2 changes: 2 additions & 0 deletions src/impl/autotierfs/fuseOps/fusePassthrough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ int FusePassthrough::mount_fs(fs::path mountpoint, char *fuse_opts){
.read_buf = fuse_ops::read_buf,
.flock = fuse_ops::flock,
.fallocate = fuse_ops::fallocate,
#ifndef EL8
.copy_file_range = fuse_ops::copy_file_range,
.lseek = fuse_ops::lseek,
#endif
};
std::vector<char *>argv = {strdup("autotier"), strdup(mountpoint.c_str())};
if(fuse_opts){
Expand Down
1 change: 1 addition & 0 deletions src/incl/fuseOps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <rocksdb/db.h>
#include <thread>
#include <mutex>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;

Expand Down

0 comments on commit bf809aa

Please sign in to comment.