This is a discussion on Package building with SlackBuilds: "stripping"? within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> On Tue, 10 Jan 2006 08:46:06 +0100, Niki Kovacs <mickey@mouse.com> wrote: >Writing a SlackBuild script is far less work ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| On Tue, 10 Jan 2006 08:46:06 +0100, Niki Kovacs <mickey@mouse.com> wrote: >Writing a SlackBuild script is far less work than expected. Once you built a >template, you can copy/paste most of it to any new script in a matter of >minutes. Try to clean up the old crap: eg case instead of multi-line elif? > >I'm very much interested by your wget code snippet for retrieving the >fastest download location. Could you send one to me please? I'll include it >in the scripts, because I think it's basically a good idea, and makes >package building from the scripts much easier. This is where some modules be handy, eg 'source lib_slackbuild'? for common repetitive stuff like wget might save some of the repetitive repetition found in repetitive slackbuilds repeating ;-/ Groan... Cheers, Grant. -- So this it it. We're going to die. |
| ||||
| Niki Kovacs <mickey@mouse.com> wrote: > I'm very much interested by your wget code snippet for retrieving the > fastest download location. Could you send one to me please? This is what it looks like in the Makefiles: A rule file looks something like this: -8<--------------------------------------------- DESCRIPTION = library for mp3 id3 tags SRC_PKG = id3lib-3.8.3.tar.gz URL_DIR += http://heanet.dl.sourceforge.net/sourceforge/easytag/ URL_DIR += http://puzzle.dl.sourceforge.net/sourceforge/easytag/ URL_DIR += http://switch.dl.sourceforge.net/sourceforge/easytag/ .... -8<--------------------------------------------- Below I use $(word 2 ... to get the server names out of the URLs. The slashes are replaced with spaces so they look something like "http: puzzle.dl.sourceforge.net sourceforge easytag", that makes the sever become word 2. Then I call the shell with ping, grep, awk and sort to sort the servers. I also use tee to log the sorted servers to /tmp/dummy as a temporary debug logfile. -8<--------------------------------------------- # Find out the name of the servers that has the file # The sort function is only to make sure that all are unique. SERVERS := $(sort $(foreach URL,$(URL_DIR),$(word 2,$(subst /, ,$(URL))))) ifeq ($(words $(SERVERS)),1) SORTED_URL_DIR = $(sort $(URL_DIR)) else SORTED_SERVERS = $(shell ($(foreach SERVER, $(SERVERS), \ (ping -c1 -W1 $(SERVER) | \ (grep min/avg/max || echo 1 2 3 4000) | \ awk '{print $$4}' | \ awk -F / '{print $$1 " $(SERVER)"}' ) & ) \ true) | sort -n | awk '{print $$2}' | tee \ /tmp/dummy) SORTED_URL_DIR = $(foreach SERVER, $(SORTED_SERVERS), \ $(shell echo $(sort $(URL_DIR)) | xargs -n1 | \ grep $(SERVER))) endif # If MD5SUM is set we will check the md5sum, otherwise we can only hope # that the downloaded file is OK. ifeq ($(words $(MD5SUM)),1) MD5CMD = echo "$(MD5SUM) $(SOURCE_FILE)" | md5sum -c else MD5CMD = true endif -8<--------------------------------------------- And finally, this is the rule to download a file. If the rule file contains a custom download method that method is used. This way it could also be possible to download sources in strange ways like with cvs. Otherwise, wget is used until it succeeds. -8<--------------------------------------------- $(SOURCE_FILE): $(filter-out $(wildcard $(SOURCE_DIR)), $(SOURCE_DIR)) ifdef DOWNLOAD_METHOD $(DOWNLOAD_METHOD) else $(foreach URL_PATH, $(SORTED_URL_DIR), \ (wget -q -P $(SOURCE_DIR) $(URL_PATH)/$(SRC_PKG) && \ $(MD5CMD)) \ || ($(RM) $@ ; false) ||) \ false endif -8<--------------------------------------------- And this is what it looks like "in action": $ make easytag download (wget -q -P source http://kent.dl.sourceforge.net/sourc...ag-1.1.tar.bz2 && true) || (rm -f source/easytag-1.1.tar.bz2 ; false) || (wget -q -P source http://puzzle.dl.sourceforge.net/sou...ag-1.1.tar.bz2 && true) || (rm -f source/easytag-1.1.tar.bz2 ; false) || (wget -q -P source http://citkit.dl.sourceforge.net/sou...ag-1.1.tar.bz2 && true) || (rm -f source/easytag-1.1.tar.bz2 ; false) || (wget -q -P source http://heanet.dl.sourceforge.net/sou...ag-1.1.tar.bz2 && true) || (rm -f source/easytag-1.1.tar.bz2 ; false) || (wget -q -P source http://switch.dl.sourceforge.net/sou...ag-1.1.tar.bz2 && true) || (rm -f source/easytag-1.1.tar.bz2 ; false) || (wget -q -P source http://surfnet.dl.sourceforge.net/so...ag-1.1.tar.bz2 && true) || (rm -f source/easytag-1.1.tar.bz2 ; false) || (wget -q -P source http://mesh.dl.sourceforge.net/sourc...ag-1.1.tar.bz2 && true) || (rm -f source/easytag-1.1.tar.bz2 ; false) || (wget -q -P source http://easynews.dl.sourceforge.net/s...ag-1.1.tar.bz2 && true) || (rm -f source/easytag-1.1.tar.bz2 ; false) || (wget -q -P source http://keihanna.dl.sourceforge.net/s...ag-1.1.tar.bz2 && true) || (rm -f source/easytag-1.1.tar.bz2 ; false) || (wget -q -P source http://jaist.dl.sourceforge.net/sour...ag-1.1.tar.bz2 && true) || (rm -f source/easytag-1.1.tar.bz2 ; false) || (wget -q -P source http://nchc.dl.sourceforge.net/sourc...ag-1.1.tar.bz2 && true) || (rm -f source/easytag-1.1.tar.bz2 ; false) || (wget -q -P source http://optusnet.dl.sourceforge.net/s...ag-1.1.tar.bz2 && true) || (rm -f source/easytag-1.1.tar.bz2 ; false) || (wget -q -P source http://internap.dl.sourceforge.net/s...ag-1.1.tar.bz2 && true) || (rm -f source/easytag-1.1.tar.bz2 ; false) || (wget -q -P source http://peterhost.dl.sourceforge.net/...ag-1.1.tar.bz2 && true) || (rm -f source/easytag-1.1.tar.bz2 ; false) || \ false The above command got wrapped of corse, but I think you get the idea. Above, "true" is only a placeholder for the md5sum command that would be used if the rule file contained an md5sum of the source archive. regards Henrik -- The address in the header is only to prevent spam. My real address is: hc7(at)uthyres.com Examples of addresses which go to spammers: root@variousus.net root@localhost |