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

(-)a/install_misc/ubuntu-packages.sh (+140 lines)
Line 0 Link Here
1
#!/bin/bash
2
3
# Copyright 2012 Universidad Nacional de Córdoba
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
usage() {
21
    local scriptname=$(basename $0)
22
    cat <<EOF
23
$scriptname
24
25
Query for missing dependencies. Install them if specified.
26
27
Usage:
28
$scriptname -c
29
$scriptname -i
30
$scriptname -h
31
32
    -c | --check      Query for missing dependencies
33
    -i | --install    Install the missing dependencies
34
    -h | --help       Display this help message
35
EOF
36
}
37
38
# Check if the package is installed
39
packageInstalled() {
40
  local package=$1
41
  return `dpkg -s $package 2>1&>  /dev/null`
42
}
43
44
45
# Get the installed package version
46
getPackageVersion() {
47
  local package=$1
48
  dpkg-query -W $package | cut -f2
49
}
50
51
# Loop over parameters
52
while [ $1 ]; do
53
    case $1 in
54
        -c | --check )
55
            shift
56
            CHECK=yes
57
            ;;
58
        -i | --install )
59
            shift
60
            INSTALL=yes
61
            ;;
62
        -h | --help)
63
            HELP=yes
64
            ;;
65
        * )
66
            usage
67
            exit 1
68
    esac
69
    shift
70
done
71
72
if [ "$HELP" = "yes" ]; then
73
    usage
74
    exit 0
75
fi
76
77
# Determine what directory this script is in, the packages files
78
# should be in the same path.
79
80
DIR=`dirname $0`
81
82
# Determine the Ubuntu release
83
UBUNTU_RELEASE=`lsb_release -r | cut -f2 -d'	'`
84
UBUNTU_PACKAGES=$DIR/ubuntu.$UBUNTU_RELEASE.packages
85
86
# Check for the release-specific packages file. Default to the general one
87
# but warn the user about LTS releases recommended
88
if [ ! -e $UBUNTU_PACKAGES ]; then
89
    UBUNTU_PACKAGES=$DIR/ubuntu.packages
90
    
91
    echo "There's no packages file for your distro/release"
92
    echo "WARNING! We strongly recommend an LTS release."
93
fi
94
95
echo "Using the $UBUNTU_PACKAGES file."
96
97
98
if [ "$CHECK" = "yes" ]; then
99
100
    # We where asked to print the packages list and current versions (if any)
101
102
    UBUNTU_PACKAGES_LIST=`awk '{print $1}' $UBUNTU_PACKAGES | grep -v '^\s*#' | grep -v '^\s*$'`
103
104
    for PACKAGE in $UBUNTU_PACKAGES_LIST
105
    do
106
      UBUNTU_PKG_POLICY=`packageInstalled $PACKAGE`
107
108
      if [ `packageInstalled $PACKAGE` ]; then
109
        UBUNTU_PKG_POLICY="Installed: (none)"
110
      else
111
        PACKAGE_VERSION=`getPackageVersion $PACKAGE`
112
        UBUNTU_PKG_POLICY="Installed: ($PACKAGE_VERSION)"
113
      fi
114
115
      UBUNTU_PKG_VERSION=`echo $UBUNTU_PKG_POLICY | awk '{print $2}'`
116
      echo "$PACKAGE = $UBUNTU_PKG_VERSION"
117
    done
118
fi
119
120
if [ "$INSTALL" = "yes" ]; then
121
122
    # We where asked to issue the apt-get command for the packages.
123
124
    UBUNTU_PACKAGES_LIST=`awk '{print $1}' $UBUNTU_PACKAGES | grep -v '^\s*#' | grep -v '^\s*$'`
125
126
    echo "Packages to be installed: "
127
    echo "$UBUNTU_PACKAGES_LIST"
128
    echo -n "Proceed (You'll be prompted to type your password)? (Y/n): "
129
130
    read answer
131
    if [ $answer ] && [ $answer != "Y" ] && [ $answer != "y" ]; then
132
        echo "Aborting"
133
        exit 1
134
    else
135
        sudo apt-get install $UBUNTU_PACKAGES_LIST
136
    fi
137
138
fi
139
140
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