Commit 46b0d40da9b5f9051e3022033e499b892276d680

Authored by Bram Veldhoen
1 parent e0d9b455

Enable creation of rpm.

Showing 2 changed files with 45 additions and 24 deletions
CMakeLists.txt
... ... @@ -168,16 +168,29 @@ install(FILES ${INC_REDOX_WRAPPER} DESTINATION include)
168 168 # Create system package (make package)
169 169 # ---------------------------------------------------------
170 170  
171   -# build a CPack driven installer package
  171 +# Determine build architecture
  172 +execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE)
  173 +message("Building for ${ARCHITECTURE}")
  174 +
  175 +# build CPack driven installer packages
172 176 include(InstallRequiredSystemLibraries)
173 177 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "C++11 client for Redis")
174 178 set(CPACK_PACKAGE_VENDOR "Hayk Martirosyan")
175   -set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Hayk Martirosyan <hayk.mart@gmail.com>")
176 179 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
177 180 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
178 181 #set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libgcc1 (>= 1:3.4.2-12)")
179 182 set(CPACK_PACKAGE_VERSION_MAJOR "${REDOX_VERSION_MAJOR}")
180 183 set(CPACK_PACKAGE_VERSION_MINOR "${REDOX_VERSION_MINOR}")
181 184 set(CPACK_PACKAGE_VERSION_PATCH "${REDOX_VERSION_PATCH}")
182   -set(CPACK_GENERATOR "DEB")
  185 +set(CPACK_PACKAGE_VERSION_RELEASE "1") # Increase this if a failed build was published
  186 +set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CPACK_PACKAGE_VERSION_RELEASE}")
  187 +set(CPACK_SYSTEM_NAME "${ARCHITECTURE}")
  188 +set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}.${ARCHITECTURE}")
  189 +# Debian specific fields
  190 +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Hayk Martirosyan <hayk.mart@gmail.com>")
  191 +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${ARCHITECTURE}")
  192 +# RPM specific fields
  193 +set(CPACK_RPM_PACKAGE_ARCHITECTURE "${ARCHITECTURE}")
  194 +# Select CPack generators
  195 +set(CPACK_GENERATOR "DEB" "RPM")
183 196 include(CPack)
... ...
README.md
... ... @@ -51,18 +51,18 @@ Here is the simplest possible redox program:
51 51  
52 52 #include <iostream>
53 53 #include <redox.hpp>
54   -
  54 +
55 55 using namespace std;
56 56 using namespace redox;
57   -
  57 +
58 58 int main(int argc, char* argv[]) {
59   -
  59 +
60 60 Redox rdx;
61 61 if(!rdx.connect("localhost", 6379)) return 1;
62   -
  62 +
63 63 rdx.set("hello", "world!");
64 64 cout << "Hello, " << rdx.get("hello") << endl;
65   -
  65 +
66 66 rdx.disconnect();
67 67 return 0;
68 68 }
... ... @@ -74,7 +74,7 @@ Compile and run:
74 74 Hello, world!
75 75  
76 76 This example is synchronous, in the sense that the commands don't return until
77   -a reply is received from the server.
  77 +a reply is received from the server.
78 78  
79 79 #### Asynchronous commands
80 80 In a high-performance application, we don't want to wait for a reply, but instead
... ... @@ -110,20 +110,20 @@ the callback returns.
110 110 Here is a simple example of running `GET hello` asynchronously ten times:
111 111  
112 112 Redox rdx;
113   -
  113 +
114 114 // Block until connected, localhost by default
115 115 if(!rdx.connect()) return 1;
116   -
  116 +
117 117 auto got_reply = [](Command<string>& c) {
118 118 if(!c.ok()) return;
119 119 cout << c.cmd() << ": " << c.reply() << endl;
120 120 };
121   -
  121 +
122 122 for(int i = 0; i < 10; i++) rdx.command<string>({"GET", "hello"}, got_reply);
123   -
  123 +
124 124 // Do useful work
125 125 this_thread::sleep_for(chrono::milliseconds(10));
126   -
  126 +
127 127 rdx.disconnect(); // Block until disconnected
128 128  
129 129 The `.command()` method returns immediately, so this program doesn't wait for a reply
... ... @@ -132,7 +132,7 @@ shut down after we get all replies, we could do something like this:
132 132  
133 133 Redox rdx;
134 134 if(!rdx.connect()) return 1;
135   -
  135 +
136 136 int total = 10; // Number of commands to run
137 137 atomic_int count(0); // Number of replies expected
138 138 auto got_reply = [&](Command<string>& c) {
... ... @@ -140,11 +140,11 @@ shut down after we get all replies, we could do something like this:
140 140 if(c.ok()) cout << c.cmd() << " #" << count << ": " << c.reply() << endl;
141 141 if(count == total) rdx.stop(); // Signal to shut down
142 142 };
143   -
  143 +
144 144 for(int i = 0; i < total; i++) rdx.command<string>({"GET", "hello"}, got_reply);
145   -
  145 +
146 146 // Do useful work
147   -
  147 +
148 148 rdx.wait(); // Block until shut down complete
149 149  
150 150 This example tracks of how how many replies are received and signals the Redox
... ... @@ -152,7 +152,7 @@ instance to stop once they all process. We use an `std::atomic_int` to be safe
152 152 because the callback is invoked from a separate thread. The `stop()` method
153 153 signals Redox to shut down its event loop and disconnect from Redis. The `wait()`
154 154 method blocks until `stop()` has been called and everything is brought down.
155   -The `disconnect()` method used earlier is just a call to `stop()` and then a
  155 +The `disconnect()` method used earlier is just a call to `stop()` and then a
156 156 call to `wait()`.
157 157  
158 158 #### Synchronous commands
... ... @@ -181,7 +181,7 @@ calls `c.free()`.
181 181 Command<string>& cmd = rdx.commandLoop<string>({"GET", "hello"}, [](Command<string>& c) {
182 182 if(c.ok()) cout << c.cmd() << ": " << c.reply() << endl;
183 183 }, 0.1);
184   -
  184 +
185 185 this_thread::sleep_for(chrono::seconds(1));
186 186 cmd.free();
187 187 rdx.disconnect();
... ... @@ -212,16 +212,16 @@ receives messages and provides subscribe/unsubscribe and psubscribe/punsubscribe
212 212  
213 213 Redox rdx; Subscriber sub;
214 214 if(!rdx.connect() || !sub.connect()) return 1;
215   -
  215 +
216 216 sub.subscribe("hello", [](const string& topic, const string& msg) {
217 217 cout << topic << ": " << msg << endl;
218 218 });
219   -
  219 +
220 220 for(int i = 0; i < 10; i++) {
221 221 rdx.publish("hello", "this is a pubsub message");
222 222 this_thread::sleep_for(chrono::milliseconds(500));
223 223 }
224   -
  224 +
225 225 sub.disconnect(); rdx.disconnect();
226 226  
227 227 #### strToVec and vecToStr
... ... @@ -251,7 +251,7 @@ a `WRONG_TYPE` or `NIL_REPLY` status.
251 251 * `<std::vector<std::string>>`: Arrays of Simple Strings or Bulk Strings (in received order)
252 252 * `<std::set<std::string>>`: Arrays of Simple Strings or Bulk Strings (in sorted order)
253 253 * `<std::unordered_set<std::string>>`: Arrays of Simple Strings or Bulk Strings (in no order)
254   -
  254 +
255 255 ## Installation
256 256 Instructions provided are for Ubuntu, but all components are platform-independent.
257 257  
... ... @@ -293,6 +293,14 @@ Redox documentation is generated using [doxygen](http://doxygen.org).
293 293  
294 294 The documentation can then be viewed in a browser at `docs/html/index.html`.
295 295  
  296 +#### Build RPM and DEB packages
  297 +Basic support to build RPMs and DEBs is in the build system. To build them, issue
  298 +the following commands:
  299 +
  300 + mkdir release && cd release
  301 + cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
  302 + make package
  303 +
296 304 ## Contributing
297 305 Redox is in its early stages and I am looking for feedback and contributors to make
298 306 it easier, faster, and more robust. Open issues on GitHub or message me directly.
... ...