002e000b71feda23e08494fe12edc10e90b308b5
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 33-aptsetup
1 #!/bin/bash
2 # Filename:      /etc/grml/fai/config/scripts/GRMLBASE/33-aptsetup
3 # Purpose:       configure Debian package management of live-system
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2 or any later version.
7 ################################################################################
8
9 set -e
10
11 if [ -L "$target"/etc/apt/sources.list ] ; then
12    echo "Note: $target/etc/apt/sources.list seems to be the old sources.list setup."
13    echo "|->   Not modifying anything. If you want to switch to the new setup just"
14    echo "\`->   remove symlink $target/etc/apt/sources.list"
15    exit 0
16 fi
17
18 # remove leftover from /etc/grml/fai/config/hooks/instsoft.GRMLBASE:
19 rm -f $target/etc/apt/sources.list.d/grml-live.list
20
21 # restore original grml sources.list file (temporarly moved via
22 # /etc/grml/fai/config/hooks/instsoft.GRMLBASE):
23 if [ -r $target/etc/apt/sources.list.d/grml.unused ] ; then
24    mv $target/etc/apt/sources.list.d/grml.unused $target/etc/apt/sources.list.d/grml.list
25 fi
26 if [ -r $target/etc/apt/sources.list.d/debian.unused ] ; then
27    mv $target/etc/apt/sources.list.d/debian.unused $target/etc/apt/sources.list.d/debian.list
28 fi
29
30 GRML_SOURCES_LIST="$target/etc/apt/sources.list.d/grml.list"
31 DEBIAN_SOURCES_LIST="$target/etc/apt/sources.list.d/debian.list"
32
33 [ -d $target/etc/apt/sources.list.d ] || mkdir $target/etc/apt/sources.list.d
34
35 # remove any existing sources.list and inform user about the new
36 # /etc/apt/sources.list.d/ setup:
37 cat > $target/etc/apt/sources.list << EOF
38 ##### IMPORTANT NOTE ##############################################
39 # The configuration file /etc/apt/sources.list has been split
40 # into structured files in /etc/apt/sources.list.d/ - check out:
41 #
42 #  /etc/apt/sources.list.d/grml.list   for the grml related repositories
43 #  /etc/apt/sources.list.d/debian.list for official Debian repositories
44 #
45 # If you're looking for the "old" /etc/apt/sources.list file or
46 # need some further repositories please take a look at the file
47 # /etc/apt/sources.list.grml
48 ##### IMPORTANT NOTE ##############################################
49 EOF
50
51 # retrieve build information ($SUITE):
52 if [ -r $target/etc/grml_live_version ] ; then
53   . $target/etc/grml_live_version
54 fi
55
56 # if we stil do not know which Debian suite we are building assume "stable"
57 [ -n "$SUITE" ] || SUITE="stable"
58
59 # configure official Debian repositories:
60 cat > "$DEBIAN_SOURCES_LIST" << EOF
61 # official debian repository (mirror selected via geo-ip):
62   deb     http://cdn.debian.net/debian/ $SUITE main contrib non-free
63 #  deb-src http://cdn.debian.net/debian/ $SUITE main contrib non-free
64
65 # official debian repository:
66 #  deb     http://ftp.debian.org/debian/ sid main contrib non-free
67 #  deb-src http://ftp.debian.org/debian/ sid main contrib non-free
68
69 # official debian DE repository:
70 #  deb     http://ftp.de.debian.org/debian/ sid main contrib non-free
71 #  deb-src http://ftp.de.debian.org/debian/ sid main contrib non-free
72
73 # official debian AT repository:
74 #  deb     http://ftp.at.debian.org/debian/ sid main contrib non-free
75 #  deb-src http://ftp.at.debian.org/debian/ sid main contrib non-free
76 EOF
77
78 # configure grml-stable repository:
79 cat > "$GRML_SOURCES_LIST" << EOF
80 # stable grml repository:
81   deb     http://deb.grml.org/ grml-stable  main
82 #  deb-src http://deb.grml.org/ grml-stable  main
83 EOF
84
85 ENABLE_GRML_TESTING=false
86 # if we have a devel-version or a daily snapshot enable grml-testing by default:
87 if [ -n "$GRML_NAME" -o -n "$RELEASENAME" ] ; then
88    if echo "$GRML_NAME" "$RELEASENAME" | grep -e devel -e autobuild 1>/dev/null ; then
89       ENABLE_GRML_TESTING=true
90    fi
91 fi
92
93 if $ENABLE_GRML_TESTING ; then
94   cat >> "$GRML_SOURCES_LIST" << EOF
95 # testing/developer grml repository:
96   deb     http://deb.grml.org/ grml-testing main
97 #  deb-src http://deb.grml.org/ grml-testing main
98 EOF
99 else # no devel/daily build:
100   cat >> "$GRML_SOURCES_LIST" << EOF
101 # testing/developer grml repository:
102 #  deb     http://deb.grml.org/ grml-testing main
103 #  deb-src http://deb.grml.org/ grml-testing main
104 EOF
105 fi
106
107 ## END OF FILE #################################################################
108 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3