Skip to content

Commit

Permalink
init project.
Browse files Browse the repository at this point in the history
  • Loading branch information
lostsnow committed Feb 27, 2016
0 parents commit 8366e26
Show file tree
Hide file tree
Showing 12 changed files with 425 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ubuntu:wily

RUN sed -i 's#archive.ubuntu.com#mirrors.aliyun.com#' /etc/apt/sources.list && \
apt-get update && \
apt-get install -y libevent-2.0 libmysqlclient18 libpq5 zlib1g libpcre3 \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/*

COPY bin/driver bin/portbind bin/dtrace_compile /usr/bin/

ENTRYPOINT ["/usr/bin/driver"]
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Docker Fluffos
==============

### build compile image

```bash
docker build -t lostsnow/fluffos-build ./build
```

### compile driver

```bash
docker run --rm -v /opt/projects/mud:/opt/projects lostsnow/fluffos-build
```

### build mudlib image

```bash
docker build -t lostsnow/fluffos .
```

### run mudlib

```bash
# https://github.com/mudchina/es2-utf8
mkdir -p /opt/projects/mud/es2-utf8/log
docker run --name es2 \
-p 4000:4000 \
-v /opt/projects/mud:/opt/projects \
lostsnow/fluffos /opt/projects/docker-fluffos/example/config.ES2
```
Binary file added bin/driver
Binary file not shown.
Binary file added bin/dtrace_compile
Binary file not shown.
Binary file added bin/portbind
Binary file not shown.
11 changes: 11 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ubuntu:wily

RUN sed -i 's#archive.ubuntu.com#mirrors.aliyun.com#' /etc/apt/sources.list && \
apt-get update && \
apt-get install -y git make g++ libevent-dev libmysqlclient-dev libpq-dev zlib1g-dev libpcre3-dev bison python wget tar gzip patch \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/*

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
88 changes: 88 additions & 0 deletions build/build.FluffOS
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash
set -eo pipefail

# By default driver compile to native environment, you can
# add "-m64" to force compile under 64bit, "-m32" for 32bit.
#
# If you are building binary to run on another machine, you
# should change -march=native to -mtune=generic
COMPILER_FLAGS=${COMPILER_FLAGS:-"-mtune=generic"}

OPTIMIZE="-O3 -funroll-loops"
DEBUG="-DNDEBUG -g"

# Change this if you want to use another make.
MAKE=make

# change this if you wish the driver binary to be named something else
# no suffix is needed.
DRIVER_BIN=driver

# Set INSTALL_DIR to the directory where you want to install the executables.
INSTALL_DIR=`dirname $(pwd)`/bin

#Enable warnings from the compiler (g++), if wanted.
WARN=(
"-Wall"
"-Wextra"
"-Wformat-security"
# Turn off some warnings from GCC.
"-Wno-char-subscripts"
"-Wno-sign-compare"
"-Wno-return-type"
"-Wno-unused-parameter"
"-Wno-missing-field-initializers"
# GCC's warning produces too many false positives:
# https://groups.google.com/a/google.com/forum/#!topic/c-users/jLRfP804wuc
# https://groups.google.com/a/google.com/d/msg/c-users/jLRfP804wuc/sKe4Ba2PKwAJ
"-Wno-overloaded-virtual"
# GCC's warning produces false positives:
# https://groups.google.com/a/google.com/d/msg/llvm-team/Mq_7JNPqE2o/lh2XpArujl8J
"-Wno-non-virtual-dtor"
# features
"-fdiagnostics-show-option"
"-fmessage-length=0"
# Less undefined behavior
"-funsigned-char"
"-fwrapv"
)
WARN="$(IFS=' '; echo "${WARN[*]}")"


if test $# -ne 0; then
case $1 in
develop)
echo Preparing to build developmental version of MudOS driver ...
OPTIMIZE="-O0"
DEBUG="-g -DDEBUG"
# Hardening mode activated, for more error visibility
DEBUG="$DEBUG -D_FORTIFY_SOURCE=2 -fstack-protector-all"
DEBUG="$DEBUG -Wstack-protector --param ssp-buffer-size=1 -fstrict-aliasing"
shift
;;
*)
;;
esac
else
echo Preparing to build standard driver ...
fi

####### END OF USER CONFIGURABLE OPTIONS

CFLAGS="$CFLAGS $COMPILER_FLAGS $WARN $OPTIMIZE $DEBUG"

if [ -d $(pwd)/../.git ]; then
if [ "$(git --no-pager show -s --format='%ae')" == "sunyucong@gmail.com" ]; then
SOURCE_REVISION="git"
else
SOURCE_REVISION="git-local"
fi
SOURCE_REVISION="$SOURCE_REVISION-$(git --no-pager show -s --format='%h-%ct')"
else
SOURCE_REVISION="unknown-nongit"
fi

# Force an reconfigure.
rm -f configure.h
CFLAGS=$CFLAGS CXXFLAGS=$CFLAGS MAKE=$MAKE ARCH=$ARCH DRIVER_BIN=$DRIVER_BIN OPTIMIZE=$OPTIMIZE SOURCE_REVISION=$SOURCE_REVISION ./configure --bindir=$INSTALL_DIR $@
$MAKE help
28 changes: 28 additions & 0 deletions build/drop-gets.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--- old/srclib/stdio.in.h
+++ new/srclib/stdio.in.h
@@ -679,22 +679,11 @@
# endif
#endif

-#if @GNULIB_GETS@
-# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef gets
-# define gets rpl_gets
-# endif
-_GL_FUNCDECL_RPL (gets, char *, (char *s) _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (gets, char *, (char *s));
-# else
-_GL_CXXALIAS_SYS (gets, char *, (char *s));
-# undef gets
-# endif
-_GL_CXXALIASWARN (gets);
/* It is very rare that the developer ever has full control of stdin,
- so any use of gets warrants an unconditional warning. Assume it is
- always declared, since it is required by C89. */
+ so any use of gets warrants an unconditional warning; besides, C11
+ removed it. */
+#undef gets
+#if HAVE_RAW_DECL_GETS
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif
21 changes: 21 additions & 0 deletions build/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

if [ ! -d "/fluffos-build.lock" ]; then
apt-get update

(wget -qO - http://ftpmirror.gnu.org/libiconv/libiconv-1.14.tar.gz | tar zxf - -C /tmp)
cd /tmp/libiconv-1.14
# libiconv remove gets declarations patch
# https://github.com/paulczar/omnibus-fpm/blob/master/config/patches/libiconv/libiconv-1.14_srclib_stdio.in.h-remove-gets-declarations.patch
cp /opt/projects/docker-fluffos/build/drop-gets.diff ./ && patch -p1 < drop-gets.diff
make clean && ./configure --prefix=/usr && make -s && make install && rm -rf /tmp/libiconv-1.14

cd /opt/projects/fluffos/src
cp /opt/projects/docker-fluffos/build/{build.FluffOS,local_options} ./
./build.FluffOS && make

cp ./{driver,dtrace_compile,portbind} /opt/projects/docker-fluffos/bin/
rm -rf /var/lib/apt/lists/*

touch /fluffos-build.lock
fi
85 changes: 85 additions & 0 deletions build/local_options
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* local_options.h: compile-time configuration of the driver
*/

/****************************************************************************
* EVERY time you change ANYTHING in this file, RECOMPILE from scratch. *
* (type "make clean" then "make" on a UNIX system) Failure to do so may *
* cause the driver to behave oddly. *
****************************************************************************/

/* NOTES: Many of the configurable options are now set in the runtime config.
*
* This file only contain a list of default settings, for quick diffing .
* See detailed explaination from 'local_options.README'
*/

#ifndef _LOCAL_OPTIONS_H_
#define _LOCAL_OPTIONS_H_

/****************************************************************************
* COMPAT *
****************************************************************************/
#undef NO_ADD_ACTION
#undef NO_SNOOP
#undef NO_ENVIRONMENT
#undef NO_WIZARDS
#undef NO_LIGHT
#define OLD_ED
#undef ED_INDENT_CASE
#define ED_INDENT_SPACES 4
#undef RECEIVE_ED
#define RESTRICTED_ED
#undef SENSIBLE_MODIFIERS

/****************************************************************************
* MISCELLANEOUS *
****************************************************************************/
#define CUSTOM_CRYPT
#undef COMPAT_32
#define DEFAULT_PRAGMAS PRAGMA_WARNINGS + PRAGMA_SAVE_TYPES + PRAGMA_ERROR_CONTEXT + PRAGMA_OPTIMIZE
#define SAVE_EXTENSION ".o"
#undef PRIVS
#undef NO_SHADOWS
#define USE_ICONV
#undef IPV6
#undef DTRACE

/****************************************************************************
* PACKAGES *
****************************************************************************/
#define PACKAGE_OPS
#define PACKAGE_CORE

#define PACKAGE_CONTRIB
#define PACKAGE_DEVELOP
#define PACKAGE_MATH
#undef PACKAGE_MATRIX
#define PACKAGE_MUDLIB_STATS
#define PACKAGE_SOCKETS
#undef PACKAGE_PARSER
#define PACKAGE_EXTERNAL
#define PACKAGE_DB
#ifdef PACKAGE_DB
#define USE_MYSQL 1
#undef USE_MSQL
#undef USE_POSTGRES
#undef USE_SQLITE3
#define DEFAULT_DB USE_MYSQL
#endif
#define PACKAGE_ASYNC
#define PACKAGE_SHA1
#undef PACKAGE_CRYPTO
#define PACKAGE_TRIM
#define PACKAGE_PCRE
#undef PACKAGE_DWLIB
#define PACKAGE_UIDS
#ifdef PACKAGE_UIDS
#define AUTO_SETEUID
#undef AUTO_TRUST_BACKBONE
#endif
#define PACKAGE_COMPRESS
#define SAVE_GZ_EXTENSION ".o.gz"
#undef PACKAGE_THREAD

#endif /* _LOCAL_OPTIONS_H_ */
Loading

0 comments on commit 8366e26

Please sign in to comment.