Browse Source

postgresql: import from oldpackages, add myself as maintainer, add license information, update to v9.0.17

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Jo-Philipp Wich 10 years ago
parent
commit
022ce86177

+ 254
- 0
libs/postgresql/Makefile View File

@@ -0,0 +1,254 @@
1
+#
2
+# Copyright (C) 2006-2014 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=postgresql
11
+PKG_VERSION:=9.0.17
12
+PKG_RELEASE:=1
13
+PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
14
+PKG_LICENSE:=PostgreSQL
15
+
16
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
17
+PKG_SOURCE_URL:=\
18
+	http://ftp9.us.postgresql.org/pub/mirrors/postgresql/source/v$(PKG_VERSION) \
19
+	http://ftp.be.postgresql.org/postgresql/source/v$(PKG_VERSION) \
20
+	ftp://ftp-archives.postgresql.org/pub/source/v$(PKG_VERSION)
21
+PKG_MD5SUM:=46bf3ef3761c091fb0d2e25012c1709e
22
+PKG_BUILD_PARALLEL:=1
23
+PKG_USE_MIPS16:=0
24
+PKG_FIXUP:=autoreconf
25
+
26
+include $(INCLUDE_DIR)/package.mk
27
+
28
+define Package/libpq
29
+  SECTION:=libs
30
+  CATEGORY:=Libraries
31
+  DEPENDS:=+zlib +libreadline +libpthread +libncurses +shadow-su
32
+  TITLE:=PostgreSQL client library
33
+  URL:=http://www.postgresql.org/
34
+  SUBMENU:=database
35
+endef
36
+
37
+define Package/libpq/description
38
+PostgreSQL client library.
39
+endef
40
+
41
+define Package/pgsql-cli
42
+  SECTION:=utils
43
+  CATEGORY:=Utilities
44
+  DEPENDS:=+libpq
45
+  TITLE:=Command Line Interface (CLI) to PostgreSQL databases
46
+  URL:=http://www.postgresql.org/
47
+  SUBMENU:=database
48
+endef
49
+
50
+define Package/pgsql-cli/description
51
+Command Line Interface (CLI) to PostgreSQL databases.
52
+endef
53
+
54
+define Package/pgsql-server
55
+  SECTION:=utils
56
+  CATEGORY:=Utilities
57
+  DEPENDS:=+libpq
58
+  TITLE:=PostgreSQL databases Server
59
+  URL:=http://www.postgresql.org/
60
+  SUBMENU:=database
61
+endef
62
+
63
+define Package/pgsql-server/description
64
+PostgreSQL databases Server.
65
+endef
66
+
67
+# Need a native ecpg ,pg_config, and zic for build
68
+define Build/Configure
69
+	(cd $(PKG_BUILD_DIR); rm -f config.cache; \
70
+		./configure \
71
+			--prefix=/usr \
72
+			--exec-prefix=/usr \
73
+			--bindir=/usr/bin \
74
+			--datadir=/usr/share \
75
+			--includedir=/usr/include \
76
+			--infodir=/usr/share/info \
77
+			--libdir=/usr/lib \
78
+			--libexecdir=/usr/lib \
79
+			--localstatedir=/var \
80
+			--mandir=/usr/share/man \
81
+			--sbindir=/usr/sbin \
82
+			--sysconfdir=/etc \
83
+			$(DISABLE_NLS) \
84
+			--enable-shared \
85
+			--enable-static \
86
+			--disable-integer-datetimes \
87
+			--disable-rpath \
88
+			--without-java \
89
+			--without-krb4 \
90
+			--without-krb5 \
91
+			--without-openssl \
92
+			--without-pam \
93
+			--without-perl \
94
+			--without-python \
95
+			--without-readline \
96
+			--without-rendezvous \
97
+			--without-tcl \
98
+			--without-tk \
99
+			--with-zlib="yes" \
100
+			--enable-depend \
101
+			--with-system-timezone=/tmp \
102
+	);
103
+	$(MAKE) -C $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc CC="$(HOSTCC)" CFLAGS+="-I../../libpq"
104
+	mv $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg \
105
+		$(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg.host
106
+	$(MAKE) -C $(PKG_BUILD_DIR)/src/timezone CC="$(HOSTCC)"
107
+	mv $(PKG_BUILD_DIR)/src/timezone/zic $(PKG_BUILD_DIR)/host-zic
108
+	$(INSTALL_DIR) $(STAGING_DIR)/host/bin/
109
+	$(CP) $(PKG_BUILD_DIR)/host-zic $(STAGING_DIR)/host/bin/zic
110
+	$(MAKE) -C $(PKG_BUILD_DIR)/src/bin/pg_config CC="$(HOSTCC)"
111
+	mv $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config \
112
+		$(PKG_BUILD_DIR)/src/bin/pg_config/pg_config.host
113
+	$(MAKE) -C $(PKG_BUILD_DIR) distclean
114
+
115
+	(cd $(PKG_BUILD_DIR); rm -f config.cache; \
116
+		$(TARGET_CONFIGURE_OPTS) \
117
+		CFLAGS="$(TARGET_CFLAGS)" \
118
+		CPPFLAGS="$$$$CPPFLAGS $(TARGET_CPPFLAGS)" \
119
+		LDFLAGS="$(TARGET_LDFLAGS)" \
120
+		./configure \
121
+			--target=$(GNU_TARGET_NAME) \
122
+			--host=$(GNU_TARGET_NAME) \
123
+			--build=$(GNU_HOST_NAME) \
124
+			--program-prefix="" \
125
+			--program-suffix="" \
126
+			--prefix=/usr \
127
+			--exec-prefix=/usr \
128
+			--bindir=/usr/bin \
129
+			--datadir=/usr/share \
130
+			--includedir=/usr/include \
131
+			--infodir=/usr/share/info \
132
+			--libdir=/usr/lib \
133
+			--libexecdir=/usr/lib \
134
+			--localstatedir=/var \
135
+			--mandir=/usr/share/man \
136
+			--sbindir=/usr/sbin \
137
+			--sysconfdir=/etc \
138
+			$(DISABLE_NLS) \
139
+			$(DISABLE_LARGEFILE) \
140
+			--enable-shared \
141
+			--enable-static \
142
+			--disable-integer-datetimes \
143
+			--disable-rpath \
144
+			--without-java \
145
+			--without-krb4 \
146
+			--without-krb5 \
147
+			--without-openssl \
148
+			--without-pam \
149
+			--without-perl \
150
+			--without-python \
151
+			--without-rendezvous \
152
+			--without-tcl \
153
+			--without-tk \
154
+			--with-zlib="yes" \
155
+			--enable-depend \
156
+			$(if $(CONFIG_TARGET_avr32),--disable-spinlocks) \
157
+	);
158
+	$(SED) 's@ECPG = ../../preproc/ecpg@ECPG = ../../preproc/ecpg.host@' $(PKG_BUILD_DIR)/src/interfaces/ecpg/test/Makefile.regress
159
+endef
160
+
161
+TARGET_CFLAGS += $(FPIC) -lpthread
162
+
163
+# because PROFILE means something else in the project Makefile
164
+unexport PROFILE
165
+
166
+define Build/Compile
167
+	+$(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" \
168
+		DESTDIR="$(PKG_INSTALL_DIR)" \
169
+		all
170
+	+$(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" \
171
+		DESTDIR="$(PKG_INSTALL_DIR)" \
172
+		install
173
+endef
174
+
175
+define Package/libpq/install
176
+	$(INSTALL_DIR) $(1)/usr/lib
177
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.so.* $(1)/usr/lib/
178
+endef
179
+
180
+define Package/pgsql-cli/install
181
+	$(INSTALL_DIR) $(1)/usr/bin
182
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/psql $(1)/usr/bin/
183
+endef
184
+
185
+define Package/pgsql-server/install
186
+	$(INSTALL_DIR) $(1)/usr/bin
187
+	$(INSTALL_DIR) $(1)/usr/share/postgresql
188
+	$(INSTALL_DIR) $(1)/usr/lib
189
+	$(INSTALL_DIR) $(1)/etc/init.d
190
+	$(INSTALL_DIR) $(1)/etc/config
191
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin
192
+	ln -sf postgres $(1)/usr/bin/postmaster
193
+
194
+	$(INSTALL_BIN) ./files/postgresql.init $(1)/etc/init.d/postgresql
195
+
196
+	$(CP) -r $(PKG_INSTALL_DIR)/usr/share/postgresql/* \
197
+		$(1)/usr/share/postgresql
198
+
199
+	$(INSTALL_DATA) ./files/postgresql.config $(1)/etc/config/postgresql
200
+
201
+	$(CP) -r \
202
+		$(PKG_INSTALL_DIR)/usr/lib/postgresql \
203
+		$(1)/usr/lib
204
+endef
205
+
206
+define Package/pgsql-server/conffiles
207
+/etc/config/postgresql
208
+endef
209
+
210
+define Package/pgsql-server/postinst
211
+#!/bin/sh
212
+grep -q '^postgres:' /etc/passwd && exit 0
213
+group=$$(grep '^postgres:' /etc/group | cut -f3 -d:)
214
+if [ -z "$${group}" ] ; then
215
+	group=1000
216
+	tst=$$(cat /etc/group | grep ":$${group}:")
217
+	while [ -n "$${tst}" ] ; do
218
+		group=$$(($${group}+1))
219
+		tst=$$(cat /etc/group | grep ":$${group}:")
220
+	done
221
+	echo "postgres:x:$${group}:" >>/etc/group
222
+fi
223
+
224
+user=$$(cat /etc/passwd | grep "^postgres:")
225
+if [ -z "$${user}" ] ; then
226
+	num="$${group}"
227
+	tst=$$(cat /etc/passwd | grep ":.*:$${num}:")
228
+	while [ -n "$${tst}" ] ; do
229
+		num=$$(($${num}+1))
230
+		tst=$$(cat /etc/passwd | grep ":.*:$${num}:")
231
+	done
232
+	echo "postgres:*:$${num}:$${group}:PostgreSQL administrator:/tmp:/bin/ash" >>/etc/passwd
233
+fi
234
+endef
235
+
236
+define Build/InstallDev
237
+	$(INSTALL_DIR) $(1)/usr/bin
238
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config.host $(1)/usr/bin/pg_config
239
+	$(INSTALL_DIR) $(1)/usr/include
240
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/libpq $(1)/usr/include/
241
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/libpq-fe.h $(1)/usr/include/
242
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config.h $(1)/usr/include/
243
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config_manual.h $(1)/usr/include/
244
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/postgres_ext.h $(1)/usr/include/
245
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/postgresql $(1)/usr/include/
246
+	$(INSTALL_DIR) $(1)/usr/lib
247
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.{a,so*} $(1)/usr/lib/
248
+	$(CP) $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg.host $(1)/usr/bin/ecpg
249
+	$(CP) $(PKG_BUILD_DIR)/host-zic $(1)/usr/bin/zic
250
+endef
251
+
252
+$(eval $(call BuildPackage,libpq))
253
+$(eval $(call BuildPackage,pgsql-cli))
254
+$(eval $(call BuildPackage,pgsql-server))

+ 5
- 0
libs/postgresql/files/postgresql.config View File

@@ -0,0 +1,5 @@
1
+config postgresql config
2
+	option PGUSER	postgres
3
+	option PGDATA	/var/postgresql/data
4
+	option PGLOG	/var/postgresql/data/postgresql.log
5
+	option PG_CTL	/usr/bin/pg_ctl

+ 93
- 0
libs/postgresql/files/postgresql.init View File

@@ -0,0 +1,93 @@
1
+#!/bin/sh /etc/rc.common
2
+# Copyright (C) 2006 OpenWrt.org
3
+START=50
4
+
5
+EXTRA_COMMANDS="status reload"
6
+
7
+config_load "postgresql"
8
+config_get pgdata config PGDATA
9
+config_get pguser config PGUSER
10
+config_get pgctl config PG_CTL
11
+config_get pglog config PGLOG
12
+
13
+start() {
14
+    if [ ! -e /usr/bin/su ]; then
15
+        echo "The su command is requred to run postgres"
16
+        exit 1
17
+    fi
18
+
19
+    if [ ! -d ${pgdata} ]; then
20
+        echo "Create the data directory (${pgdata}) and try again"
21
+        exit 1
22
+    fi
23
+
24
+    echo "starting postgres..."
25
+    # make sure localhost (without a dot) is in /etc/hosts
26
+    grep -q 'localhost$' /etc/hosts || echo '127.0.0.1 localhost' >> /etc/hosts
27
+
28
+    # for whatever reason, /dev/null gets wrong perms
29
+    chmod a+w /dev/null
30
+
31
+    if [ -f ${pgdata}/postmaster.pid ]; then
32
+        rm ${pgdata}/postmaster.pid
33
+    fi
34
+
35
+    config_get pgopts config PGOPTS
36
+    if [ -n "${pgopts}" ]; then
37
+        pgopts="-o ${pgopts}"
38
+    fi
39
+    /usr/bin/su ${pguser} -c "/usr/bin/postmaster -D '${pgdata}' &" >> ${pglog} 2>&1
40
+
41
+    while :
42
+    do
43
+        cnt=$((${cnt} + 1))
44
+        if [ -f "${pgdata}/postmaster.pid" ]; then
45
+            ret=0
46
+            break
47
+        fi
48
+
49
+        if [ ${cnt} -eq 30 ]; then
50
+            echo "Postgres failed to start.  See ${pglog} for details"
51
+            ret=1
52
+            break
53
+        fi
54
+        sleep 1
55
+    done
56
+
57
+    echo "ok"
58
+    return ${ret}
59
+}
60
+
61
+stop() {
62
+    echo "stopping postgres..."
63
+    /usr/bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}' -s -m fast"
64
+    ret=$?
65
+    if [ -f ${pgdata}/postmaster.pid ]; then
66
+        rm ${pgdata}/postmaster.pid
67
+    fi
68
+    echo "ok"
69
+    return ${ret}
70
+}
71
+
72
+restart() {
73
+    echo "restarting postgres..."
74
+    /usr/bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}' -s -m fast -w"
75
+    if [ -f ${pgdata}/postmaster.pid ]; then
76
+        rm ${pgdata}/postmaster.pid
77
+    fi
78
+    /usr/bin/su ${pguser} -c "/usr/bin/postmaster -D '${pgdata}' &" >> ${pglog} 2>&1
79
+    echo "ok"
80
+    return $?
81
+}
82
+
83
+reload() {
84
+    echo "reloading postgres..."
85
+    /usr/bin/su ${pguser} -c "${pgctl} reload -D '${pgdata}' -s"
86
+    echo "ok"
87
+}
88
+
89
+status() {
90
+    echo "status postgres..."
91
+    /usr/bin/su ${pguser} -c "${pgctl} status -D '${pgdata}'"
92
+    echo "ok"
93
+}

+ 10
- 0
libs/postgresql/patches/200-ranlib.patch View File

@@ -0,0 +1,10 @@
1
+--- a/src/port/Makefile
2
++++ b/src/port/Makefile
3
+@@ -53,6 +53,7 @@ uninstall:
4
+ 
5
+ libpgport.a: $(OBJS)
6
+ 	$(AR) $(AROPT) $@ $^
7
++	$(RANLIB) libpgport.a
8
+ 
9
+ # thread.o needs PTHREAD_CFLAGS (but thread_srv.o does not)
10
+ thread.o: thread.c

+ 13
- 0
libs/postgresql/patches/800-busybox-default-pager.patch View File

@@ -0,0 +1,13 @@
1
+--- a/src/bin/psql/print.h
2
++++ b/src/bin/psql/print.h
3
+@@ -171,10 +171,6 @@ extern void printQuery(const PGresult *r
4
+ extern void setDecimalLocale(void);
5
+ extern const printTextFormat *get_line_style(const printTableOpt *opt);
6
+ 
7
+-#ifndef __CYGWIN__
8
+-#define DEFAULT_PAGER "more"
9
+-#else
10
+ #define DEFAULT_PAGER "less"
11
+-#endif
12
+ 
13
+ #endif   /* PRINT_H */