about summary refs log tree commit diff stats
path: root/core/scripts/install-core.sh
blob: 078aa3bb2a076fd8f931919347084788cab487de (plain) (blame)
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/bin/bash

CHROOT="/mnt"
PORT_PKG="${CHROOT}/media/crux"
INSTALL_OPT=0

#echo "1.1.8. Install Handbook\n"
#cp ${PORT_PKG}/handbook.txt $CHROOT/root/

ConfirmOrExit()
{
    while true
    do
        echo -n "Please confirm (y or n) :"
        read CONFIRM
        case $CONFIRM in
            y|Y|YES|yes|Yes) break ;;
            n|N|no|NO|No)
                echo "Aborting - you entered $CONFIRM"
                exit
                ;;
            *) echo "Please enter only y or n"
        esac
    done
    echo "You entered $CONFIRM. Continuing ..."
}


install_core() {

    mkdir -p ${CHROOT}/var/lib/pkg
    touch ${CHROOT}/var/lib/pkg/db

    CORE_LS="${DATA_DIR}/core.pkg"

    if [ ! -f ${CORE_LS} ]; then
        CORE_LS=${CHROOT}/core.pkg
        echo "1.1.4 Create core.pkg and install pkgadd"
        for p in ${PORT_PKG}/core/*;
        do
            echo $(basename $p) >> ${CORE_LS};
        done
    fi

    # it is required a degree in astrophysics in order to figure out how to extract a file to a target folder
    bsdtar -C ${CHROOT} -xf "${PORT_PKG}/core/pkgutils#5.40.7-1.pkg.tar.xz" usr/bin/pkgadd
    mv ${CHROOT}/usr/bin/pkgadd ${CHROOT}
    chmod +x ${CHROOT}/pkgadd

    echo "1.1.4 File core.pkg complete, review list of packages before continue... [PRESS ENTER]"
    read PAUSE
    vim ${CORE_LS}

    echo "1.1.4 Starting install"

    #cd $CHROOT
    while read line; do
        pkg=${PORT_PKG}/core/${line}
        echo "Installing ${pkg}"
        #${CHROOT}/pkgadd -f -r ${CHROOT} ${pkg}
        ${CHROOT}/pkgadd -f -r ${CHROOT} ${pkg}
    done < ${CORE_LS}

    rm ${CHROOT}/pkgadd

    if [ -f ${CHROOT}/core.pkg ]; then
        rm ${CHROOT}/core.pkg;
    fi
}

install_packages() {
    echo "Installing ${PORT_PKG}/opt/fakeroot"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/fakeroot#*
    echo "Installing ${PORT_PKG}/opt/dbus"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/dbus#*
    echo "Installing ${PORT_PKG}/opt/expat"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/expat#*
    echo "Installing ${PORT_PKG}/opt/libnl"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/libnl#*
    echo "Installing ${PORT_PKG}/opt/libpng"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/libpng#*
    echo "Installing ${PORT_PKG}/opt/freetype"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/freetype#*
    echo "Installing ${PORT_PKG}/opt/libffi"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/libffi#*
    echo "Installing ${PORT_PKG}/opt/sqlite3"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/sqlite3#*
    echo "Installing ${PORT_PKG}/opt/python"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/python#*
    echo "Installing ${PORT_PKG}/opt/glib"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/glib#*
    echo "Installing ${PORT_PKG}/opt/grub2"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/grub2#*
    echo "Installing ${PORT_PKG}/opt/grub2-efi"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/grub2-efi#*
    echo "Installing ${PORT_PKG}/opt/wireless-tools"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/wireless-tools#*
    echo "Installing ${PORT_PKG}/opt/wpa_supplicant"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/wpa_supplicant#*
    echo "Installing ${PORT_PKG}/opt/lvm2"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/lvm2#*
    echo "Installing ${PORT_PKG}/opt/mdadm"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/mdadm#*
    echo "Installing ${PORT_PKG}/opt/efivar"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/efivar#*
    echo "Installing ${PORT_PKG}/opt/efibootmgr"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/efibootmgr#*
    echo "Installing ${PORT_PKG}/opt/dosfstools"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/dosfstools#*
    echo "Installing ${PORT_PKG}/opt/parted"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/parted#*
    echo "Installing ${PORT_PKG}/opt/libgcrypt"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/libgcrypt#*
    echo "Installing ${PORT_PKG}/opt/cryptsetup"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/cryptsetup#*
    echo "Installing ${PORT_PKG}/opt/popt"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/popt#*
    echo "Installing ${PORT_PKG}/opt/libgpg-error"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/libgpg-error#*
    echo "Installing ${PORT_PKG}/opt/libevent"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/libevent#*
    echo "Installing ${PORT_PKG}/opt/libtirpc"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/libtirpc#*
    echo "Installing ${PORT_PKG}/opt/git"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/git#*
    echo "Installing ${PORT_PKG}/opt/tmux"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/tmux#*
    echo "Installing ${PORT_PKG}/opt/prt-utils"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/prt-utils#*
}

print_data() {
    echo "1.1.4 Paths to packages and target:"
    echo "chroot: ${CHROOT}"
    echo "packages dir: ${PORT_PKG}"
    echo "install optional: ${INSTALL_OPT}"
}

print_help() {
	echo "usage: install-core [options]"
	echo "options:"
	echo "  -r,   --chroot              default chroot is /mnt"
	echo "  -p,   --packages            packages directory /mnt/media/crux"
	echo "  -o,   --optional            install extra packages"
	echo "  -h,   --help                print help and exit"
}

while [ "$1" ]; do
            case $1 in
                    -r|--chroot)
                        CHROOT=$2
                        shift ;;
                    -p|--packages)
                        PORT_PKG=$2
                        shift ;;
                    -o|--optional)
                        INSTALL_OPT=1
                        ;;
                    -h|--help)
                        print_help
                        exit 0 ;;
                    *)
                        echo "setup-iso: invalid option $1"
                        print_help
                        exit 1 ;;
            esac
            shift
done

print_data
ConfirmOrExit
install_core
echo "=========[ core installed ]==========="

if [[ $INSTALL_OPT -eq 1 ]];
then
    install_packages
    echo "=========[ extra packages installed ]==========="
fi