Skip to content

Commit

Permalink
Multiple queries on CLI + Reuse of loaded data + Full code refactorin…
Browse files Browse the repository at this point in the history
…g (full python API) + RPM compiles q to binary

Included changes:
pick 8b4342d Refactored q to expose objects, and added a python package wrapper
pick b0d28b1 Internalized exception handling into the q main object
pick faf3904 Added reuse of loaded data + stdin injection to module API + tests
pick 08cf2bb Allow different input params for each loaded file + loading file manually + fixed modeling of query encoding + tests
pick 3a7fffd Separation of populate phases
pick 92d0bb6 Provide table structure as part of responses + merge _populate method versions
pick d04a24c Multiple queries on CLI + load data from string API + finer details in table structure response + tests
pick d90c392 modified non existent file error msg + fixed response bug in table_structure when there are errors
pick 5908a75 Fixed bug in str of the response
pick a9dcc74 New RPM creation which matches commit hash to version, and compiles q
pick 90fd18a Fixed permissions for new RPM.
  • Loading branch information
harelba committed Dec 11, 2014
1 parent 9e31efe commit 2147ccc
Show file tree
Hide file tree
Showing 8 changed files with 1,304 additions and 452 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
q.spec
q.1
*.pyc
2 changes: 2 additions & 0 deletions bin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env python

1,208 changes: 812 additions & 396 deletions bin/q

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions bin/qtextasdata.py
49 changes: 13 additions & 36 deletions dist/create-rpm
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#!/bin/bash

# Works for x86_64, need to see how to compile for multiple architectures

#
# Simplistic RPM creation logic. See q.spec.template for actual spec
#
# Version number should be provided as input in the command line
# Commit tag and Version number should be provided as input in the command line
#
# requires:
# * installation of ronn
# * installation of rpmbuild
# * pyinstaller needs to be installed
#
# Output rpm is generated inside build/rpm/RPMS/noarch/
#

if [ $# -ne 1 ];
if [ $# -ne 2 ];
then
echo 'create-rpm <version>'
echo 'create-rpm <commit-hash> <version>'
exit 1
fi

Expand All @@ -27,50 +28,26 @@ base_folder=$(dirname $0)

pushd ${base_folder}

VERSION=$1
LOCAL=yes
COMMIT_HASH=$1
SHORT_HASH=${COMMIT_HASH:0:7}
VERSION=$2
REAL_PACKAGE_NAME=q
RPM_PACKAGE_NAME=q-text-as-data

FULL_NAME_FOLDER=${RPM_PACKAGE_NAME}-${VERSION}

rm -rf build/
rm -rf ${FULL_NAME_FOLDER}
rm -rf tmp.tar.gz

mkdir -p build/rpm
mkdir ${FULL_NAME_FOLDER}

if [ ! -e ${RPM_PACKAGE_NAME}.spec.template ];
then
echo "spec template does not exist. can't continue"
exit 1
fi

cat ${RPM_PACKAGE_NAME}.spec.template | sed "s/VERSION_PLACEHOLDER/$1/" > ${FULL_NAME_FOLDER}/${RPM_PACKAGE_NAME}.spec

if [ "$LOCAL" == "yes" ];
then
echo "Creating source codebase version ${VERSION} from local copy"
cp -r `ls -d1 ../* | egrep -v "dist|test"` ${FULL_NAME_FOLDER}/
else
echo "Creating source codebase version ${VERSION} from github archive"
wget -O tmp.tar.gz "https://github.com/harelba/${REAL_PACKAGE_NAME}/archive/${VERSION}.tar.gz"
tar xvzf tmp.tar.gz --strip-components=1 -C ${FULL_NAME_FOLDER}/
rm -f tmp.tar.gz
fi

ronn ${FULL_NAME_FOLDER}/doc/USAGE.markdown
rm -f ${FULL_NAME_FOLDER}/doc/USAGE.html
rm -rf ${FULL_NAME_FOLDER}/dist ${FULL_NAME_FOLDER}/test
rm -vf ~/rpmbuild/SOURCES/q-${COMMIT_HASH}.tar.gz

echo "Creating tar file"
TAR_FILE_NAME=${RPM_PACKAGE_NAME}-${VERSION}.tar.gz
tar cvfz ${TAR_FILE_NAME} ${FULL_NAME_FOLDER}/*
curl -o ~/rpmbuild/SOURCES/q-${COMMIT_HASH}.tar.gz -L -R "https://github.com/harelba/q/tarball/${COMMIT_HASH}"

rpmbuild --define "_topdir `pwd`/build/rpm" -ta ${TAR_FILE_NAME}
cat ${RPM_PACKAGE_NAME}.spec.template | sed "s/VERSION_PLACEHOLDER/$VERSION/g" | sed "s/COMMIT_HASH_PLACEHOLDER/${COMMIT_HASH}/g" | sed "s/SHORT_HASH_PLACEHOLDER/${SHORT_HASH}/g" > ~/rpmbuild/SPECS/${RPM_PACKAGE_NAME}.spec

rm -f ${TAR_FILE_NAME}
rm -rf ${FULL_NAME_FOLDER}
rpmbuild --noclean -v -bb ~/rpmbuild/SPECS/${RPM_PACKAGE_NAME}.spec

popd
5 changes: 5 additions & 0 deletions dist/pre-requisites
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

sudo apt-get install gem
sudo gem install ruby-ronn
pyinstaller
33 changes: 25 additions & 8 deletions dist/q-text-as-data.spec.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
%global _enable_debug_package 0
%global debug_package %{nil}
%global __os_install_post %{nil}

Name: q-text-as-data
Version: VERSION_PLACEHOLDER
Release: 1%{?dist}
Expand All @@ -6,31 +10,44 @@ Summary: q - Text as Data
Group: Applications/Text
License: GPLv3
URL: https://github.com/harelba/q
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
Source: q-COMMIT_HASH_PLACEHOLDER.tar.gz
BuildArch: x86_64

%description
q allows to perform SQL-like statements on tabular text data.


%prep
%setup
%setup -qn harelba-q-SHORT_HASH_PLACEHOLDER

%build
ls -ltr
pyinstaller -D --distpath=compiled-dist bin/q
ronn doc/USAGE.markdown

%install
rm -rf ${RPM_BUILD_ROOT}
rm -vrf ${RPM_BUILD_ROOT}/
export DONT_STRIP=1
install -d -m 0755 ${RPM_BUILD_ROOT}%{_bindir}
install -Dm 755 bin/q ${RPM_BUILD_ROOT}%{_bindir}/
install -Dm 755 bin/q ${RPM_BUILD_ROOT}%{_bindir}/
install -d -m 0755 ${RPM_BUILD_ROOT}%{_libdir}/q-text-as-data
install -Dm 0644 compiled-dist/q/* ${RPM_BUILD_ROOT}%{_libdir}/q-text-as-data/
ln -s %{_libdir}/q-text-as-data/q ${RPM_BUILD_ROOT}%{_bindir}/q
install -d -m 0755 ${RPM_BUILD_ROOT}%{_mandir}/man1/
install -m 0644 doc/USAGE ${RPM_BUILD_ROOT}%{_mandir}/man1/q.1
gzip ${RPM_BUILD_ROOT}%{_mandir}/man1/q.1

%files
%defattr(-,root,root,-)
%doc README.markdown doc/*
%{_bindir}/q
%doc README.markdown doc/AUTHORS doc/CHANGELOG.markdown doc/IMPLEMENTATION.markdown doc/INSTALL.markdown doc/LICENSE doc/RATIONALE.markdown doc/THANKS doc/USAGE.markdown
%attr(755,root,root) %{_bindir}/q
%attr(755,root,root) %{_libdir}/q-text-as-data/q
%{_libdir}/q-text-as-data
%doc %_mandir/man1/q.1.gz

%changelog
*Sat Nov 29 2014 Harel Ben-Attia <[email protected]> 1.5.0-1
- Changed to use compiled version of q
- Moved stuff from create-rpm script into the rpm spec itself
*Sat Jun 14 2014 Harel Ben-Attia <[email protected]> 1.4.0-1
- Changed RPM package name to q-text-as-data
- Fixed RPM creation logic after folder restructuring
Expand Down
Loading

0 comments on commit 2147ccc

Please sign in to comment.