Project

General

Profile

« Previous | Next » 

Revision f318575f

Added by jahoti 3 months ago

Add target and install directory auto-detection

It's simplistic, yet (hopefully) good enough.

View differences:

configure
15 15

  
16 16
set -e
17 17

  
18
BROWSERPATH=''
18 19
SRCDIR=''
19 20
TARGET=''
20 21

  
......
27 28
	"UPDATE_URL"=*) UPDATE_URL="$(echo "$1" | cut -c 12-)";;
28 29
	--host=*)            TARGET="$(echo "$1" | cut -c 8-)";;
29 30
	--host)                             TARGET="$2"; shift;;
30
	mozilla | chromium)                    TARGET=$1;;
31
	
32
	# browsers
33
	chromium | chrome | google-chrome | mozilla |\
34
	firefox | librewolf | icecat | iceweasel | abrowser |\
35
	iceweasel-uxp | tor-browser)                 TARGET=$1;;
31 36
	*)                         echo Ignoring option "'$1'";;
32 37
    esac
33 38
    shift
......
36 41
# Autodetect srcdir
37 42
if [ "x$SRCDIR" = x ]; then
38 43
    SRCDIR=..
39
    if [ -f manifest.json -a -f write_makefile.sh]; then
44
    if [ -f manifest.json ] && [ -f write_makefile.sh]; then
40 45
	SRCDIR=.
41 46
    fi
42 47
fi
......
50 55
    exit 1
51 56
fi
52 57

  
53
# TODO: automate target detection
58
# Autodetect target
59
if [ "x$TARGET" = x ]; then
60
    echo Detecting target automatically.
61
    if [ -h /etc/alternatives/x-www-browser ]; then
62
	BROWSERPATH="$(realpath /etc/alternatives/x-www-browser)"
63
	TARGET="$(/etc/alternatives/x-www-browser --version 2> /dev/null |
64
	    tail -n 1 | awk '{ print $1 }' | tr [A-Z] [a-z])"
65
    else
66
    	echo Warning: could not find target automatically. >&2
67
    	echo Some make rules may fail. >&2
68
    fi
69
else
70
    BROWSERPATH="$(realpath "$(which $TARGET)")"
71
fi
54 72

  
55
# Standardize and check browser names
73
# Check and standardize target
56 74
case "$TARGET" in
57
    mozilla)                   TARGET=mozilla;;
58
    chromium)                 TARGET=chromium;;
59
    *) echo Invalid target "'$1'" >&2; exit 2;;
75
    mozilla | firefox | abrowser | icecat | iceweasel-uxp |\
76
    librewolf | iceweasel | gnu | tor-browser)   TARGET=mozilla;;
77
    chromium | chrome | google-chrome | google) TARGET=chromium;;
78
    "")                                                        ;;
79
    *)              echo Invalid target "'$TARGET'" >&2; exit 2;;
60 80
esac
61 81

  
82
# Autodetect DESTDIR (no check needed)
83
if [ "x$DESTDIR" = x ]; then
84
    echo Guessing installation directory.
85
    if [ -n "$BROWSERPATH" ] && [ -n "$TARGET" ]; then
86
	DESTDIR="$(dirname "$BROWSERPATH")" # TODO: a hack for Debian?
87
	if [ $TARGET = mozilla ]; then
88
	    DESTDIR="$DESTDIR"/browser
89
	fi
90
	DESTDIR="$DESTDIR"/extensions
91
    else
92
    	echo Warning: could not guess installation directory. >&2
93
    	echo Some make rules may fail. >&2
94
    fi
95
fi
96

  
62 97
# Write record.conf (LEAVE SRCDIR FIRST)
63 98
echo srcdir = "$SRCDIR" > record.conf
64 99
echo default_target = "$TARGET" >> record.conf

Also available in: Unified diff