aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build.sh4
-rw-r--r--scripts/dmm.spec45
-rwxr-xr-xscripts/generate_dmm_deb.sh42
-rwxr-xr-xscripts/generate_dmm_rpm.sh2
-rwxr-xr-xscripts/git/commit-msg-hook.py136
-rw-r--r--scripts/git/commit-msg-template28
6 files changed, 210 insertions, 47 deletions
diff --git a/scripts/build.sh b/scripts/build.sh
index 66a3236..6379ed1 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -1,3 +1,4 @@
+#!/bin/bash -x
#########################################################################
# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#########################################################################
-#!/bin/bash -x
set -x
@@ -149,6 +149,8 @@ fi
if [ "$OS_ID" == "centos" ]; then
make pkg-rpm
+elif [ "$OS_ID" == "ubuntu" ]; then
+ make pkg-deb
fi
#===========check running env =================
diff --git a/scripts/dmm.spec b/scripts/dmm.spec
deleted file mode 100644
index 4869140..0000000
--- a/scripts/dmm.spec
+++ /dev/null
@@ -1,45 +0,0 @@
-Name: dmm
-Version: 18.04
-Release: 1%{?dist}
-Summary: DMM Project
-
-License: GPL
-URL: https://gerrit.fd.io/r/dmm
-Source: %{name}-%{version}.tar.gz
-
-%description
-The DMM framework provides posix socket APIs to the application. A protocol
-stack could be plugged into the DMM. DMM will choose the most suitable stack
-for the application.
-
-%prep
-%setup -q
-
-
-%build
-cd build/
-cmake ..
-make -j 8
-
-%install
-cd ../../BUILDROOT
-mkdir -p %{name}-%{version}-%{release}.x86_64/usr/bin
-mkdir -p %{name}-%{version}-%{release}.x86_64/usr/lib64
-
-install -c ../BUILD/%{name}-%{version}/release/bin/kc_common %{name}-%{version}-%{release}.x86_64/usr/bin
-install -c ../BUILD/%{name}-%{version}/release/bin/ks_epoll %{name}-%{version}-%{release}.x86_64/usr/bin
-install -c ../BUILD/%{name}-%{version}/release/bin/vc_common %{name}-%{version}-%{release}.x86_64/usr/bin
-install -c ../BUILD/%{name}-%{version}/release/bin/vs_epoll %{name}-%{version}-%{release}.x86_64/usr/bin
-install -c ../BUILD/%{name}-%{version}/release/bin/ks_select %{name}-%{version}-%{release}.x86_64/usr/bin
-install -c ../BUILD/%{name}-%{version}/release/bin/vs_select %{name}-%{version}-%{release}.x86_64/usr/bin
-
-install -c ../BUILD/%{name}-%{version}/release/lib64/libdmm_api.a %{name}-%{version}-%{release}.x86_64/usr/lib64
-install -c ../BUILD/%{name}-%{version}/release/lib64/libnStackAPI.so %{name}-%{version}-%{release}.x86_64/usr/lib64
-
-%files
-/usr/bin/*
-/usr/lib64/*
-%doc
-
-
-%changelog
diff --git a/scripts/generate_dmm_deb.sh b/scripts/generate_dmm_deb.sh
new file mode 100755
index 0000000..5168d07
--- /dev/null
+++ b/scripts/generate_dmm_deb.sh
@@ -0,0 +1,42 @@
+#########################################################################
+#
+# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#########################################################################
+#!/bin/sh
+
+cur_directory=${PWD}
+
+mkdir -p /tmp/mkdeb
+mkdir -p /tmp/mkdeb/DEBIAN
+mkdir -p /tmp/mkdeb/usr/bin
+mkdir -p /tmp/mkdeb/usr/lib
+
+cd ../
+git archive --format=tar.gz -o /tmp/dmm.tar.gz --prefix=dmm/ HEAD
+
+cd /tmp/
+tar xzvf dmm.tar.gz
+cd dmm/build
+cmake ..
+make -j 8
+
+cd ../
+cp -f release/bin/* /tmp/mkdeb/usr/bin
+cp -f release/lib64/* /tmp/mkdeb/usr/lib
+cp -f pkg/deb/control /tmp/mkdeb/DEBIAN/
+
+cd /tmp/
+dpkg-deb -b mkdeb/ ${cur_directory}/../release/deb/dmm.deb
+
+cd ${cur_directory}
diff --git a/scripts/generate_dmm_rpm.sh b/scripts/generate_dmm_rpm.sh
index 711f475..792c2a3 100755
--- a/scripts/generate_dmm_rpm.sh
+++ b/scripts/generate_dmm_rpm.sh
@@ -27,7 +27,7 @@ git archive --format=tar.gz -o ~/rpmbuild/SOURCES/${name}-${version}.tar.gz --pr
cd ~/rpmbuild/SOURCES
tar xzvf ${name}-${version}.tar.gz
-cp ${name}-${version}/scripts/dmm.spec ~/rpmbuild/SOURCES
+cp ${name}-${version}/pkg/rpm/dmm.spec ~/rpmbuild/SOURCES
echo "generate the rpm package"
#QA_RPATHS=$[ 0x0002 ] is to shield the warning about rpath when generating the rpm package
diff --git a/scripts/git/commit-msg-hook.py b/scripts/git/commit-msg-hook.py
new file mode 100755
index 0000000..719ff22
--- /dev/null
+++ b/scripts/git/commit-msg-hook.py
@@ -0,0 +1,136 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import sys
+
+
+# format: \033[type;fg;bgm
+#
+# fg bg color
+# -------------------------------------------
+# 30 40 black
+# 31 41 red
+# 32 42 green
+# 33 43 yellow
+# 34 44 blue
+# 35 45 purple
+# 36 46 cyan
+# 37 47 white
+#
+# type
+# -------------------------
+# 0 normal
+# 1 bold
+# 4 underline
+# 5 blink
+# 7 invert
+# 8 hide
+#
+# examples:
+# \033[1;31;40m <!--1-bold 31-red fg 40-black bg-->
+# \033[0m <!--back to normal-->
+
+
+STYLE = {
+ 'fore':
+ {
+ 'black' : 30,
+ 'red' : 31,
+ 'green' : 32,
+ 'yellow' : 33,
+ 'blue' : 34,
+ 'purple' : 35,
+ 'cyan' : 36,
+ 'white' : 37,
+ },
+
+ 'back':
+ {
+ 'black' : 40,
+ 'red' : 41,
+ 'green' : 42,
+ 'yellow' : 43,
+ 'blue' : 44,
+ 'purple' : 45,
+ 'cyan' : 46,
+ 'white' : 47,
+ },
+
+ 'mode':
+ {
+ 'normal' : 0,
+ 'bold' : 1,
+ 'underline' : 4,
+ 'blink' : 5,
+ 'invert' : 7,
+ 'hide' : 8,
+ },
+
+ 'default':
+ {
+ 'end': 0,
+ },
+}
+
+
+def style(string, mode='', fore='', back=''):
+
+ mode = '%s' % STYLE['mode'][mode] if STYLE['mode'].has_key(mode) else ''
+
+ fore = '%s' % STYLE['fore'][fore] if STYLE['fore'].has_key(fore) else ''
+
+ back = '%s' % STYLE['back'][back] if STYLE['back'].has_key(back) else ''
+
+ style = ';'.join([s for s in [mode, fore, back] if s])
+
+ style = '\033[%sm' % style if style else ''
+
+ end = '\033[%sm' % STYLE['default']['end'] if style else ''
+
+ return '%s%s%s' % (style, string, end)
+
+
+def check_subject(subject_line):
+ types = ['Feat', 'Fix', 'Refactor', 'Style', 'Docs', 'Test', 'Chore']
+
+ if subject_line.startswith(' '):
+ print style('Error: Subject line starts with whitespace\n', fore='red')
+ return 1
+
+ if len(subject_line) > 50:
+ print style('Error: Subject line should be limited to 50 chars\n', fore='red')
+ return 1
+
+ ll = subject_line.split(':')
+ if len(ll) < 2:
+ print style('Error: Subject line should have a type\n', fore='red')
+ return 1
+
+ type = ll[0]
+ if type not in types:
+ print style('Error: Subject line starts with unknown type\n', fore='red')
+ return 1
+
+ return 0
+
+
+contents = []
+ret = 0
+subject = True
+
+with open(sys.argv[1], 'r') as commit_msg:
+ contents = commit_msg.readlines()
+
+for line in contents:
+ dup = line.lstrip()
+ if dup.startswith('#'):
+ continue
+ if subject is True:
+ ret = check_subject(line)
+ subject = False
+ else:
+ if len(line) > 72:
+ print style('Error: Body line should be limited to 72 chars\n', fore='red')
+ ret = 1
+
+exit(ret)
diff --git a/scripts/git/commit-msg-template b/scripts/git/commit-msg-template
new file mode 100644
index 0000000..6d72af1
--- /dev/null
+++ b/scripts/git/commit-msg-template
@@ -0,0 +1,28 @@
+# <type>: (if applied, this commit will...) <subject> (Max 50 chars)
+# |<---- Using a Maximum Of 50 Characters ---->|
+
+
+# Explain why this change is being made
+# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
+
+# Provide links or keys to any relevant tickets, articles or other resources
+# Example: Github issue #23
+
+# --- COMMIT END ---
+# Type can be
+# Feat (new feature)
+# Fix (bug fix)
+# Refactor (refactoring production code)
+# Style (formatting, missing semi colons, etc; no code change)
+# Docs (changes to documentation)
+# Test (adding or refactoring tests; no production code change)
+# Chore (updating grunt tasks etc; no production code change)
+# --------------------
+# Remember to
+# Choose one of types above in subject line
+# Use the imperative mood in the subject line
+# Do not end the subject line with a period
+# Separate subject from body with a blank line
+# Use the body to explain what and why vs. how
+# Can use multiple lines with "-" for bullet points in body
+# --------------------