Summary:ASTERISK-15607: [patch] make sounds doesn't download but make install does
Reporter:Walter Doekes (wdoekes)Labels:
Date Opened:2010-02-11 05:07:01.000-0600Date Closed:2011-06-07 14:10:17
Versions:Frequency of
Environment:Attachments:( 0) astsvn16807-make-sounds.diff
I regularly update an asterisk, using:

$ cd new-asterisk
$ make
$ sudo /etc/init.d/asterisk stop
$ cd old-asterisk
$ sudo make uninstall
$ cd new-asterisk
$ sudo make install
$ sudo /etc/init.d/asterisk start

That looks perfectly fine, except that the new-asterisk does not have the sounds yet. So I can sit and wait for the sounds to download while the asterisk is down and phones fail to register (or worse, call).

****** STEPS TO REPRODUCE ******

$ sudo make install
$ rm sounds/asterisk*gsm*tar.gz
$ sudo make sounds
[does nothing]
$ sudo make install
[downloads sounds/asterisk*gsm*tar.gz]

I can get the sounds to download early if I specify a bogus path for ASTDATADIR:

$ make sounds ASTDATADIR=/tmp/abc
[downloads sounds/asterisk*gsm*tar.gz]


So, why doesn't it download on make sounds:

asterisk-core-%.tar.gz: have_download
   if test ! -f $@ && test ! -f $(SOUNDS_DIR)/.$(subst .tar.gz,,$@) ; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$@;fi

The second condition is met. On make install, the following is also fired:

$(SOUNDS_DIR)/.asterisk-core-sounds-en-%: have_download
   @PACKAGE=$(subst $(SOUNDS_DIR)/.asterisk,asterisk,$@).tar.gz; \
   if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
   if test ! -f $${PACKAGE}; then exit 1; fi; \
   rm -f $(subst -$(CORE_SOUNDS_VERSION),,$@)-* && \
   (cd $(SOUNDS_DIR)/en; cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xof -) && \
   touch $@

I don't believe you want it to fire, because $(SOUNDS_DIR)/.asterisk-core-sounds-en-* actually does exist.
But a you can see, it does:

$ make -C sounds /var/lib/asterisk/sounds/.asterisk-core-sounds-en-gsm-1.4.17 ASTTOPDIR=.. ASTDATADIR=/var/lib/asterisk --debug
Reading makefiles...
Updating goal targets....
  File `have_download' does not exist.
 Must remake target `have_download'.
make: Entering directory `/home/walter/src/asterisk-svn/sounds'
 Successfully remade target file `have_download'.
Prerequisite `have_download' of target `/var/lib/asterisk/sounds/.asterisk-core-sounds-en-gsm-1.4.17' does not exist.
Must remake target `/var/lib/asterisk/sounds/.asterisk-core-sounds-en-gsm-1.4.17'.
rm: cannot remove `/var/lib/asterisk/sounds/.asterisk-core-sounds-en-gsm-1.4.17': Permission denied
make: *** [/var/lib/asterisk/sounds/.asterisk-core-sounds-en-gsm-1.4.17] Error 1
make: Leaving directory `/home/walter/src/asterisk-svn/sounds'

My temporary fix would be to skip the -f $(SOUNDS_DIR)/.$(subst .tar.gz,,$@) check on asterisk-core-%.tar.gz as per the attached patch. This way I can run `make sounds' after make and be certain that the `make install` doesn't take minutes.

The better fix would obviously be to ensure that $(SOUNDS_DIR)/.asterisk-core-sounds-en-% doesn't fire, but I'm not sure how to go about that.

Walter Doekes
Comments:By: Tilghman Lesher (tilghman) 2010-02-24 15:32:16.000-0600

Actually, there's no need to stop asterisk while you uninstall the old and install the new.  You can do that while Asterisk is running just fine.

By: Walter Doekes (wdoekes) 2010-02-24 16:35:51.000-0600

Well yes, that will probably work in most, if not all cases.

It does however, not feel entirely safe for reasons like:
- make uninstall could remove critical parts of the filesystem currently in use by asterisk (e.g. spool directories) (I'm not saying it does, but I don't think you're guaranteeing it doesn't either)
- during and after make install you'll be running an old binary with newer (reloadable, from disk) modules in place

By: Tilghman Lesher (tilghman) 2010-02-24 17:07:30.000-0600

Whether it feels safe or not, it's perfectly fine.