Take the 2-minute tour ×

Has anyone made anything (even just a script) to automatically download, untar, and make projects off of SourceForge in Linux? How could I do that?

I am using Ubuntu 12.10, specifically.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

The standard workflow for installing from source is to download the package, decompress it run the included configure script, compile and install. So, for those cases where the package you want to install follows the standard method, you can do this:

#!/usr/bin/env bash

## Make a new empty directory ($$ is the script's PID)
echo "Creating directory $$"
mkdir $$
cd $$
## get the file name 
tar=$(basename "$1" | grep -Po "[^?]*(?=[?$])") 
## Download the file
wget $1 --output-document $tar
## Check if it is a gzipped or bzipped tar 
file=$(find . -type f);
istgz=$(echo $file | grep "tar\.gz\|tgz")
istbz=$(echo $file | grep "tar\.bz\|tbz")

## Extract the archive
if [ $istbz ]; then
    tar xjf $file;
    ok=$? ## $? is the last command's exit status
elif [ $istgz ]; then
    tar xzf $file
## If things did not go OK, complain
    echo "Something went wrong, perhaps the filetype is not recognized"
    exit 1;
## If things went OK, install
if [ $ok = 0 ]; then
    ## Look for a configure script and cd into wherever it is
    conf=$(find . -name configure -executable)
    if [ $conf ]; then
        dir=$(dirname $conf);
        cd $dir;
        ## run the configure script, make and install
        ./configure &&  make && sudo make install && echo "Succesfully installed, installation directory was $$"
        echo "No configure script found, exiting."

Save this script as, for example, sforge.sh, make it executable (chmod a+x sforge.sh) and run it with the URL of the sourceforge package you want to install. Make sure you use the direct link and remove any references to mirrors. In this example, I am downloading conky, when I click on the "direct download" link from sourceforge, the URL is


I only want the first part (in bold) or the name of the file will be weird, so I will use:

sforge.sh http://downloads.sourceforge.net/project/conky/conky/1.9.0/conky-1.9.0.tar.bz2


This script will only work for those packages that follow the normal layout. It needs to be a tarred bz2 or gzip file and it expects a configure script and a Makefile. Many packages will not have these and the script will not work. It should be OK for many if not most cases though.

share|improve this answer
This is along the lines of what I wanted. It had some errors though due to find getting too many things. I wanted this to be able to run in my home directory, so I am tweaking it a bit first. –  Melodic Apr 28 '13 at 22:35
Ah, yes sorry, I forgot to mention that this really should be run in an empty directory created for the purpose. Remember that some packages will extract everything in the current directory while others will create a new one. Expanding any archive in your $HOME is usually a bad idea since files can end up all over the place. –  terdon Apr 28 '13 at 22:36
@Melodic careful, as I said that will depend on whether the tar creates a new folder or not. I really recommend you always do this in an empty directory as per the updated script. –  terdon Apr 28 '13 at 22:39
@Melodic done, clever use of basename by the way. –  terdon Apr 28 '13 at 22:47
Added a custom keyboard shortcut in Ubuntu to call this with the clipboard using xsel: gnome-terminal -e "bash -c '<SCRIPT-LOCATION>/sforge.sh $(xsel -o -b)'" It also works with $(xclip -o -selection c) in place of xsel. Now I just right-click, copy-link-to-clipboard, and press ctrl+super+D and everything else is done for me! :D –  Melodic Apr 29 '13 at 0:38

There are a couple of tools that can help with that: Jordan Sissel's fpm and Bernd Ahlers fpm-cookery. The first being able to conveniently build packages from source code in a very simple manner, the second providing a way to automate this workflow.

I won't go into details, as the projects are very well documented and there are working recipes for different kinds of code.

share|improve this answer

If I understood your question right, then there is no such generic tool for "auto-build" all projects. Every project has its own specific steps to checking dependencies, downloading source, compiling & installing. If someone can build a certain application manually, he/she could write an auto-build script for that certain app, then share the script to the public for everyone's convenience.

Additionally, you can try to use ArchLinux, its AUR package manager is functioning in a similar way e.g. getting source code tarballs, installing dependencies, compiling, and installing. If one want to create such a package, read the AUR User Guidelines.

share|improve this answer

Your Answer


