View | Details | Raw Unified | Return to bug 8840
Collapse All | Expand All

(-)a/install_misc/ubuntu-packages.sh (+153 lines)
Line 0 Link Here
1
#!/bin/bash
2
3
# Copyright 2012 Universidad Nacional de Cordoba
4
# Written by Tomas Cohen Arazi
5
#            Mark Tompsett
6
#
7
# This file is part of Koha.
8
#
9
# Koha is free software; you can redistribute it and/or modify it under the
10
# terms of the GNU General Public License as published by the Free Software
11
# Foundation; either version 2 of the License, or (at your option) any later
12
# version.
13
#
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License along
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22
usage() {
23
    local scriptname=$(basename $0)
24
    cat <<EOF
25
$scriptname
26
27
Query for missing dependencies. Print the install command for them if specified.
28
29
Usage:
30
$scriptname -c
31
$scriptname -i
32
$scriptname -h
33
34
    -r  | --report             Report the status of Koha's dependencies
35
    -ic | --install-command    Display the install command for the missing dependencies
36
    -h  | --help               Display this help message
37
EOF
38
}
39
40
# Check if the package is installed
41
packageInstalled() {
42
  local package=$1
43
   if dpkg -s $package 2>1&>  /dev/null ; then
44
      return 0
45
   else
46
      return 1
47
   fi
48
}
49
50
51
# Get the installed package version
52
getPackageVersion() {
53
  local package=$1
54
  dpkg-query -W $package | cut -f2
55
}
56
57
# Loop over parameters
58
while (( "$#" )); do
59
    case $1 in
60
        -c | --check )
61
            CHECK=yes
62
            ;;
63
        -ic | --install-command )
64
            INSTALLCMD=yes
65
            ;;
66
        -h | --help)
67
            HELP=yes
68
            ;;
69
        * )
70
            usage
71
            exit 1
72
    esac
73
    shift
74
done
75
76
if [ "$HELP" = "yes" ]; then
77
    usage
78
    exit 0
79
fi
80
81
# Determine what directory this script is in, the packages files
82
# should be in the same path.
83
DIR=`dirname $0`
84
85
# Determine the Ubuntu release
86
UBUNTU_RELEASE=`lsb_release -r | cut -f2 -d'	'`
87
UBUNTU_PACKAGES_FILE=$DIR/ubuntu.$UBUNTU_RELEASE.packages
88
89
# Check for the release-specific packages file. Default to the general one
90
# but warn the user about LTS releases recommended
91
if [ ! -e $UBUNTU_PACKAGES_FILE ]; then
92
    UBUNTU_PACKAGES_FILE=$DIR/ubuntu.packages
93
    
94
    echo "# There's no packages file for your distro/release"
95
    echo "# WARNING! We strongly recommend an LTS release."
96
fi
97
98
echo "# Using the $UBUNTU_PACKAGES_FILE file as source"
99
100
# We where asked to print the packages list and current versions (if any)
101
UBUNTU_PACKAGES=`awk '{print $1}' $UBUNTU_PACKAGES_FILE | grep -v '^\s*#' | grep -v '^\s*$'`
102
103
MISSING_PACKAGES=""
104
105
if [ "$CHECK" != "yes" ]; then
106
    # Comment for skiping the dots if needed ....
107
    echo -n "#"
108
fi
109
110
for PACKAGE in $UBUNTU_PACKAGES
111
do
112
    # Test if the package is installed
113
    PACKAGE_INSTALLED=""
114
    if packageInstalled $PACKAGE ; then
115
      PACKAGE_INSTALLED=1
116
    else
117
      # Not installed, accumulate for output
118
      MISSING_PACKAGES="$MISSING_PACKAGES $PACKAGE"
119
    fi
120
121
    if [ "$CHECK" = "yes" ]; then
122
        if [ $PACKAGE_INSTALLED ]; then
123
            PACKAGE_VERSION=`getPackageVersion $PACKAGE`
124
        else
125
            PACKAGE_VERSION="none"
126
        fi
127
        echo -e "$PACKAGE\t=\t$PACKAGE_VERSION"
128
    else
129
        # Echo a dot for the impatient
130
        echo -n "."
131
    fi
132
133
done
134
135
if [ "$CHECK" != "yes" ]; then
136
    # newline
137
    echo 
138
fi
139
140
141
if [ "$INSTALLCMD" = "yes" ]; then
142
143
    cat <<EOF
144
# Copy and paste the following command to install all Koha's dependencies on your system:
145
# Note: this command will run with admin privileges. Make sure your user has sudo rights
146
EOF
147
148
    echo -e "\tsudo apt-get install $MISSING_PACKAGES"
149
150
fi
151
152
153
exit 0
(-)a/install_misc/ubuntu-pkg-check.sh (-28 lines)
Lines 1-27 Link Here
1
#!/bin/sh
2
3
# determine what directory this script is in, because the packages files
4
# should be there too.
5
DIR=`dirname $0`
6
7
#determine which vbersion of ubuntu
8
VERSION=`lsb_release -r | cut -f2 -d'	'`
9
UBUNTU_PACKAGES=$DIR/ubuntu.$VERSION.packages
10
11
# sanity checks
12
if [ ! -e $UBUNTU_PACKAGES ]; then
13
   echo "WARNING! We strongly recommend an LTS release."
14
   UBUNTU_PACKAGES=$DIR/ubuntu.packages
15
fi
16
echo "Using the $UBUNTU_PACKAGES file."
17
18
# main
19
UBUNTU_PACKAGES_LIST=`awk '{print $1}' $UBUNTU_PACKAGES | grep -v '^\s*#' | grep -v '^\s*$'`
20
for F in $UBUNTU_PACKAGES_LIST; do
21
   UBUNTU_PKG_POLICY=`apt-cache policy $F 2> /dev/null | grep "Installed:"`
22
   if [ "${#UBUNTU_PKG_POLICY}" -eq "0" ]; then
23
      UBUNTU_PKG_POLICY="Installed: \(none\)\*"
24
   fi
25
   UBUNTU_PKG_VERSION=`echo $UBUNTU_PKG_POLICY | awk '{print $2}'`
26
   echo "$F = $UBUNTU_PKG_VERSION"
27
done
28
- 

Return to bug 8840