Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need a simple working Makefile for postfix .db files

94 views
Skip to first unread message

Bit Twister

unread,
Jul 7, 2016, 12:08:36 PM7/7/16
to
Everything tried so far gets me

# make all
make: Nothing to be done for 'all'.

All my google/manual reading has not helped me so far.

I want postmap to compile a .db file for each of the SOURCES.

[root@wb postfix]# touch aliases generic sasl_passwd sender_relay
[root@wb postfix]# dir | grep 'Jul 7 11:'
-rw-r--r-- 1 root root 2265 Jul 7 11:03 aliases
-rw-r--r-- 1 root root 11059 Jul 7 11:03 generic
-rw------- 1 root root 444 Jul 7 11:03 sasl_passwd
-rw------- 1 root root 210 Jul 7 11:03 sender_relay
[root@wb postfix]# make
make: Nothing to be done for 'all'.


$ cat /etc/postfix/Makefile
SOURCES = aliases generic sasl_passwd sender_relay
OBJECTS = $(SOURCES:=.db)

$(TARGET) : $(OBJECTS)
@postmap $@ < $<

all: $(SOURCES)

%.db : %
@postmap $@ < $<
#********** end /etc/postfix/Makefile **********************

Carlos E.R.

unread,
Jul 7, 2016, 4:05:10 PM7/7/16
to
On 2016-07-07 18:08, Bit Twister wrote:
> Everything tried so far gets me
>
> # make all

I use this:

all: access.db relay_ccerts.db sasl_passwd.db \
transport.db canonical.db relocated.db \
ehlo_discard_words.db sender_relayhost.db \
generic.db sender_canonical.db virtual.db

transport.db: transport
postmap transport

sender_relayhost.db: sender_relayhost
postmap sender_relayhost

virtual.db: virtual
postmap virtual

generic.db: generic
postmap generic

canonical.db: canonical
postmap canonical

sender_canonical.db: sender_canonical
postmap sender_canonical

sasl_passwd.db: sasl_passwd
postmap sasl_passwd

/etc/aliases.db: /etc/aliases
postalias /etc/aliases

access.db: access
postmap access

relocated.db: relocated
postmap relocated

ehlo_discard_words.db: ehlo_discard_words
postmap ehlo_discard_words


--
Cheers, Carlos.

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

Bit Twister

unread,
Jul 7, 2016, 4:55:55 PM7/7/16
to
On Thu, 7 Jul 2016 22:00:55 +0200, Carlos E.R. wrote:
> On 2016-07-07 18:08, Bit Twister wrote:
>> Everything tried so far gets me
>>
>> # make all
>
> I use this:

Yes, I did manage to hard code everything and get it to work.
What I want to do is automate the Makefile. :)

Here is the current attempt at automation.
I have linked all the text files to same_name.txt just to get
something working.

# dir *.txt
lrwxrwxrwx 1 root root 7 Jul 7 11:49 aliases.txt -> aliases
lrwxrwxrwx 1 root root 7 Jul 7 11:50 generic.txt -> generic
lrwxrwxrwx 1 root root 11 Jul 7 11:50 sasl_passwd.txt -> sasl_passwd
lrwxrwxrwx 1 root root 12 Jul 7 11:50 sender_relay.txt -> sender_relay

dir *.db
-rw-r--r-- 1 root root 12288 Jul 6 14:36 aliases.db
-rw-r--r-- 1 root root 12288 Jul 6 14:36 generic.db
-rw------- 1 root root 12288 Jul 6 14:36 sasl_passwd.db
-rw------- 1 root root 12288 Jul 6 14:36 sender_relay.db

# make all
make: Nothing to be done for 'all'.

# cat Makefile
src := $(lwildcard *.txt)
obj = $(src:.txt=.db)

all: $(obj)

%.db: %.txt
@postmap $@ < $<
#*************** end Makefile *************************

Richard Kettlewell

unread,
Jul 7, 2016, 5:02:12 PM7/7/16
to
Bit Twister <BitTw...@mouse-potato.com> writes:
> [root@wb postfix]# touch aliases generic sasl_passwd sender_relay
> [root@wb postfix]# dir | grep 'Jul 7 11:'
> -rw-r--r-- 1 root root 2265 Jul 7 11:03 aliases
> -rw-r--r-- 1 root root 11059 Jul 7 11:03 generic
> -rw------- 1 root root 444 Jul 7 11:03 sasl_passwd
> -rw------- 1 root root 210 Jul 7 11:03 sender_relay
> [root@wb postfix]# make
> make: Nothing to be done for 'all'.
>
>
> $ cat /etc/postfix/Makefile
> SOURCES = aliases generic sasl_passwd sender_relay
> OBJECTS = $(SOURCES:=.db)
>
> $(TARGET) : $(OBJECTS)
> @postmap $@ < $<
>
> all: $(SOURCES)

Your first target depends on aliases, generic, sasl_passwd and
sender_relay. Since all these exist, it does nothing.

--
http://www.greenend.org.uk/rjk/

Bit Twister

unread,
Jul 7, 2016, 5:03:59 PM7/7/16
to
On Thu, 7 Jul 2016 20:55:54 -0000 (UTC), Bit Twister wrote:
>
> Yes, I did manage to hard code everything and get it to work.
> What I want to do is automate the Makefile. :)
>
> Here is the current attempt at automation.
> I have linked all the text files to same_name.txt just to get
> something working.

> # cat Makefile
> src := $(lwildcard *.txt)

Well frap. Noting like posting code to see the mistake(s).
bad> src := $(lwildcard *.txt)
better src := $(wildcard *.txt)

Now I am getting .db.db instead of .db :(

# make
postmap: warning: generic.db, line 1: expected format: key whitespace value
postmap: warning: generic.db, line 1: expected format: key whitespace value
postmap: warning: sender_relay.db, line 0: expected format: key whitespace value
postmap: warning: sasl_passwd.db, line 0: expected format: key whitespace value
[root@wb postfix]# dir *.db*
-rw-r--r-- 1 root root 12288 Jul 6 14:36 aliases.db
-rw-r--r-- 1 root root 12288 Jul 6 14:36 generic.db
-rw-r--r-- 1 root root 12288 Jul 7 16:02 generic.db.db
-rw------- 1 root root 12288 Jul 6 14:36 sasl_passwd.db
-rw------- 1 root root 12288 Jul 7 16:02 sasl_passwd.db.db
-rw------- 1 root root 12288 Jul 6 14:36 sender_relay.db
-rw------- 1 root root 12288 Jul 7 16:02 sender_relay.db.db

Bit Twister

unread,
Jul 7, 2016, 5:52:12 PM7/7/16
to
On Thu, 7 Jul 2016 21:03:58 -0000 (UTC), Bit Twister wrote:

Well, I had to get rid of the .txt links and whatnot. Going to have to
define actual files in src.

The last hurdle is getting the ifeq statement to run.
getting "invalid syntax in conditional. Stop."



src = aliases generic sasl_passwd sender_relay
obj = $(src:=.db)

all: $(obj)

%.db: %
ifeq ($< aliases)
postalias aliases
else
@postmap $<
endif

Bit Twister

unread,
Jul 7, 2016, 7:47:01 PM7/7/16
to
On Thu, 7 Jul 2016 21:52:11 -0000 (UTC), Bit Twister wrote:
> On Thu, 7 Jul 2016 21:03:58 -0000 (UTC), Bit Twister wrote:
> The last hurdle is getting the ifeq statement to work

[root@wb postfix]# make
:aliases: :aliases.db:
postmap: warning: aliases, line 18: record is in "key: value" format;
is this an alias file?


The above shows that "ifeq ($<,aliases)" is not working as desired.
Any suggestions anyone?


********** start of /etc/postfix/Makefile **********************
src = generic sasl_passwd sender_relay aliases
obj = $(src:=.db)

all: $(obj)
@ls -al *.db*

%.db: %
ifeq ($<,aliases)
@postalias $<
else
@echo :$<: :$@:
@postmap $<
endif
********** end of /etc/postfix/Makefile **********************

Bit Twister

unread,
Jul 8, 2016, 8:50:57 PM7/8/16
to
On Thu, 7 Jul 2016 23:47:00 -0000 (UTC), Bit Twister wrote:

This is simplest I could get running.
cat /etc/postfix/Makefile
#********** start of /etc/postfix/Makefile **********************
src = aliases generic sasl_passwd sender_relay
obj = $(src:=.db)

all: $(obj)
@chmod 600 sasl_passwd*
@chmod 600 sender_relay*
@postfix reload
@ls -al *.db*

aliases.db: aliases
@postalias aliases

%.db: %
@postmap $<

reset:
@touch -t 200101010110.01 *.db
@ls -al *.db*

clean:
@rm -f *.db *~

restart:
systemctl stop postfix
sleep 3
systemctl start postfix

#********** end of /etc/postfix/Makefile **********************

HASM

unread,
Jul 9, 2016, 12:32:29 AM7/9/16
to

> #********** start of /etc/postfix/Makefile **********************
> src = aliases generic sasl_passwd sender_relay

Why not include transport and virtual?

> restart:
> systemctl stop postfix
> sleep 3
> systemctl start postfix

Why not
systemctl restart postfix?

-- HASM

Bit Twister

unread,
Jul 9, 2016, 12:45:16 AM7/9/16
to
On Fri, 08 Jul 2016 21:32:28 -0700, HASM wrote:
>
>> #********** start of /etc/postfix/Makefile **********************
>> src = aliases generic sasl_passwd sender_relay
>
> Why not include transport and virtual?

Not using them.

>
>> restart:
>> systemctl stop postfix
>> sleep 3
>> systemctl start postfix
>
> Why not
> systemctl restart postfix?

Does not seem to work reliablily.

0 new messages