summaryrefslogtreecommitdiffstats
path: root/build_tools/larch7/larch-setup
blob: 5b440a748c8f581c4a868104056a4ed3a4cc6ee0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#! /bin/bash
#
# larch-setup
#
# Author: Michael Towers <gradgrind[at]online[dot]de>
#
# This file is part of the larch project.
#
#    larch is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    larch is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with larch; if not, write to the Free Software Foundation, Inc.,
#    51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
#----------------------------------------------------------------------------
# 2010.04.11

REPO="ftp://ftp.berlios.de/pub/larch/larch7.2/i686"
#REPO=file://$( readlink -f larchrepo )

if [ "$1" = "-h" ]; then
    echo "larch-setup -h"
    echo "        # Display this information."
    echo "larch-setup"
    echo "        # Set up a larch build environment in the current directory."
    echo
    echo "This script unpacks larch, so that it"
    echo "can be run from this directory, without installing."
    echo "It also generates appropriate symlinks."
    echo
    echo "TODO:"
    echo "If there is no pacman in the PATH, a package containing a"
    echo "pacman binary and the libraries and configuration files it needs"
    echo "will be downloaded from the larch site and unpacked in the"

    echo" larch/run directory."
    echo "Also repo-add is extracted there and a pacman.conf is generated in"
    echo "the current directory, presenting a dialog for choosing the package"
    echo "server."
    echo "You can use an existing pacman.conf by placing this in the current"
    echo "directory."
    echo
    exit
fi

# Get path to this directory, via the location of this script
fullpath="$( readlink -f $0 )"
scriptdir="$( dirname ${fullpath} )"

# Just in case ...
cd ${scriptdir}

if [ -d larch0 ]; then
    echo "ERROR: larch0 directory exists already"
    exit 1
fi

fetch ()
{
    if [ -n "$( echo ${REPO} | grep "file://" )" ]; then
        base="$( echo ${REPO} | sed "s|file://||" )"
        cp ${base}/$1 .
    else
        wget ${REPO}/$1
    fi
}

rm -f *.pkg.tar.gz
rm -rf db
mkdir db
cd db
fetch larch.db.tar.gz
tar -xzf larch.db.tar.gz
cd ${scriptdir}
d=$( ls db | grep "^larch-7" )
larchpak=$( grep -A 1 -e "%FILENAME%" db/${d}/desc | grep -v "%" )
fetch ${larchpak}
#d=$( ls db | grep "^uipi-" )
#larchpak=$( grep -A 1 -e "%FILENAME%" db/${d}/desc | grep -v "%" )
#fetch ${larchpak}

rm -rf tmp
mkdir tmp
tar -xzf larch-7*.pkg.tar.gz -C tmp

if [ "$1" != "-p" ]; then
    d=$( ls db | grep "^larch-profiles-" )
    larchpak=$( grep -A 1 -e "%FILENAME%" db/${d}/desc | grep -v "%" )
    fetch ${larchpak}
    tar -xzf larch-profiles-*.pkg.tar.gz -C tmp
fi

rm -rf db
mv tmp/opt/apps/larch larch0
#tar -xzf uipi-*.pkg.tar.gz -C tmp
#mv tmp/usr/bin/quip larch0
#mv tmp/usr/lib/python*/site-packages/uipi.py larch0/modules

for s in $( ls tmp/usr/bin ); do
    p=$( readlink tmp/usr/bin/${s} )
    d=$( dirname ${p} )
    ln -s larch0/$( basename ${d} )/$( basename ${p}) ${s}
done
rm -rf tmp

# Check that pacman is available.
if ! which pacman &>/dev/null; then
    # Fetch the pacman package from the larch site
    fetch pacman-allin.tar.gz
    if ! [ -f pacman-allin.tar.gz ]; then
        echo "ERROR: couldn't fetch pacman package"
        exit 1
    fi
   # Extract the package
    tar -xzf pacman-allin.tar.gz
    cp -a pacman-allin/* larch0
    rm -rf pacman-allin
fi