~rainct/ubuntu-dev-tools/dev

8 by Luke Yelavich
* Added pbuilder-dist. Rename to feisty/gutsy/etc to use pbuilder with
1
#!/bin/sh
18.3.5 by Siegfried-Angel Gevatter Pujals (RainCT)
Complete the README file. Unify all script headers. Delete pbuilder-template (same as -dist). Change my mail address.
2
# Copyright (C) Jamin W. Collins <jcollins@asgardsrealm.net>
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
3
#                and Jordan Mantha <mantha@ubuntu.com>
4
# Copyright 2007 (C) Siegfried-A. Gevatter <siggi.gevatter@gmail.com>
5
# License: GPLv2 or later
18.3.5 by Siegfried-Angel Gevatter Pujals (RainCT)
Complete the README file. Unify all script headers. Delete pbuilder-template (same as -dist). Change my mail address.
6
#
7
# This script is a wrapper to use pbuilder with many different
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
8
# distributions / versions. (It was originally created because of
9
# bug #255165 in Debian.)
18.3.5 by Siegfried-Angel Gevatter Pujals (RainCT)
Complete the README file. Unify all script headers. Delete pbuilder-template (same as -dist). Change my mail address.
10
#
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
11
# If you want to use this copy of the script only for a single distribution
12
# / version, rename it to 'pbuilder-dapper', 'pbuilder-feisty', 'pbuilder-gutsy', 
18.3.8 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: filename related improvements. Updated AUTHORS, and sorted them A-Z. Updated debian/copyright and fixed a problem there (some scripts don't have the 'or later' clause).
13
# or whatever it is. If you have an amd64, you can also use names like
14
# 'pbuilder-feisty-i386', etc.
18.3.5 by Siegfried-Angel Gevatter Pujals (RainCT)
Complete the README file. Unify all script headers. Delete pbuilder-template (same as -dist). Change my mail address.
15
#
16
# The only variable you really might need to change is BASE_DIR, if you
17
# don't want pbuilder stuff in your home directory.
18
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
19
# Base directory where pbuilder will put all the files it creates
18.3.5 by Siegfried-Angel Gevatter Pujals (RainCT)
Complete the README file. Unify all script headers. Delete pbuilder-template (same as -dist). Change my mail address.
20
BASE_DIR="$HOME/pbuilder"
8 by Luke Yelavich
* Added pbuilder-dist. Rename to feisty/gutsy/etc to use pbuilder with
21
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
22
# Enable additional repositories by default? (universe and multiverse in Ubuntu,
23
# contrib and non-free in Debian.)
24
EXTRACOMP=1
25
18.3.12 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: fixed another problem when working with more than one architecture. Added an option to store the last log. Added an option to use the same cache directory for .deb's as apt-get when possible.
26
# Save the log of the last operation in a dot-file? ('.lastlog' in BASE_DIR)
27
SAVELOG=0
28
29
# Allow this script to use /var/cache/apt/archives/ when possible
30
SYSCACHE=1
31
32
33
################################
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
34
18.3.11 by Siegfried-Angel Gevatter Pujals (RainCT)
(pbuilder-dist: improved architecture detection, thanks to geser.)
35
ARCH=`dpkg-architecture -qDEB_HOST_ARCH`
18.3.12 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: fixed another problem when working with more than one architecture. Added an option to store the last log. Added an option to use the same cache directory for .deb's as apt-get when possible.
36
SYSDIST=`lsb_release -cs`
18.3.7 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: Implemented architecture choosing for amd64.
37
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
38
help()
39
{
40
        echo "Insufficient number of arguments."
18.3.12 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: fixed another problem when working with more than one architecture. Added an option to store the last log. Added an option to use the same cache directory for .deb's as apt-get when possible.
41
        echo "Usage: $0 "$( [ "$1" != 'show-dist-flag' ] || echo "<distribution> " )$( [ $ARCH != "amd64" ] || echo "[i386|amd64] " )"[mainonly|allcomp] [withlog|nolog] <operation>"
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
42
        exit 1
43
}
44
18.3.8 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: filename related improvements. Updated AUTHORS, and sorted them A-Z. Updated debian/copyright and fixed a problem there (some scripts don't have the 'or later' clause).
45
if [ ! -z `echo \`basename $0\` | grep -- '-'`  ] && [ `basename $0` != 'pbuilder-dist' ]
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
46
then
47
    if [ $# -lt 1 ]
48
    then
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
49
        help
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
50
    fi
18.3.8 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: filename related improvements. Updated AUTHORS, and sorted them A-Z. Updated debian/copyright and fixed a problem there (some scripts don't have the 'or later' clause).
51
    
52
    BINARCH=`basename $0 | cut -f3 -d '-'`
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
53
    DISTRIBUTION=`basename $0 | cut -f2 -d '-'`
54
else
55
    if [ $# -lt 2 ]
56
    then
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
57
        help show-dist-flag
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
58
    fi
59
    
60
    DISTRIBUTION=$1
18.3.7 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: Implemented architecture choosing for amd64.
61
    shift 1
62
fi
63
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
64
18.3.7 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: Implemented architecture choosing for amd64.
65
if [ $1 = "i386" ]  || [ $1 = "amd64" ]
66
then
18.3.12 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: fixed another problem when working with more than one architecture. Added an option to store the last log. Added an option to use the same cache directory for .deb's as apt-get when possible.
67
    if [ $ARCH = "amd64" ]; then
18.3.7 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: Implemented architecture choosing for amd64.
68
        BINARCH=$1
69
    else
70
        echo "Warning: Architecture switching is not supported on your system; ignoring argument."
71
    fi
72
    
73
    shift 1
74
fi
75
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
76
18.3.12 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: fixed another problem when working with more than one architecture. Added an option to store the last log. Added an option to use the same cache directory for .deb's as apt-get when possible.
77
if [ $1 = "mainonly" ]; then
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
78
    EXTRACOMP=0
79
    shift 1
18.3.12 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: fixed another problem when working with more than one architecture. Added an option to store the last log. Added an option to use the same cache directory for .deb's as apt-get when possible.
80
elif [ $1 = "allcomp" ]; then
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
81
    EXTRACOMP=1
82
    shift 1
83
fi
84
85
18.3.12 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: fixed another problem when working with more than one architecture. Added an option to store the last log. Added an option to use the same cache directory for .deb's as apt-get when possible.
86
if [ $1 = "withlog" ]; then
87
    SAVELOG=0
88
    shift 1
89
elif [ $1 = "nolog" ]; then
90
    SAVELOG=1
91
    shift 1
92
fi
93
94
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
95
distdata()
96
{
97
    if [ "$1" = "debian" ]
98
    then
99
        # Set Debian specific data
100
        ARCHIVE="http://ftp.debian.org"
101
        COMPONENTS="main"$( [ $EXTRACOMP = 0 ] || echo " contrib non-free" )
102
    else
103
        # Set Ubuntu specific data
104
        ARCHIVE="http://archive.ubuntu.com/ubuntu"
105
        COMPONENTS="main restricted"$( [ $EXTRACOMP = 0 ] || echo " universe multiverse" )
106
    fi
107
}
108
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
109
110
case $DISTRIBUTION in
111
    #warty|hoary|breezy)
112
    dapper|edgy|feisty|gutsy)
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
113
        distdata ubuntu
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
114
        ;;
115
    
116
    oldstable|sarge|stable|etch|testing|lenny|unstable|sid|experimental)
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
117
        distdata debian
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
118
        ;;
119
    
120
    *)
121
        echo "Warning: Unknown distribution «$DISTRIBUTION»."
122
        echo -n "Continue [y/N]? "
123
        read continue
124
        
125
        if [ "$continue" != 'y' ] && [ "$continue" != 'Y' ]
126
        then
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
127
            echo "Aborting..."
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
128
            exit 1
129
        fi
130
        
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
131
        distdata
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
132
        ;;
133
esac
134
18.3.5 by Siegfried-Angel Gevatter Pujals (RainCT)
Complete the README file. Unify all script headers. Delete pbuilder-template (same as -dist). Change my mail address.
135
18.3.9 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: added an option to disable universe/multiverse
136
OPERATION=$1
137
8 by Luke Yelavich
* Added pbuilder-dist. Rename to feisty/gutsy/etc to use pbuilder with
138
case $OPERATION in
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
139
    create|update|build|clean|login|execute)
140
        ;;
141
    
142
    *)
143
        echo "Unrecognized argument. Please use one of those:"
144
        echo "    create"
145
        echo "    update"
146
        echo "    build"
147
        echo "    clean"
148
        echo "    login"
149
        echo "    execute"
150
        exit 1
151
        ;;
8 by Luke Yelavich
* Added pbuilder-dist. Rename to feisty/gutsy/etc to use pbuilder with
152
esac
18.3.5 by Siegfried-Angel Gevatter Pujals (RainCT)
Complete the README file. Unify all script headers. Delete pbuilder-template (same as -dist). Change my mail address.
153
18.3.12 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: fixed another problem when working with more than one architecture. Added an option to store the last log. Added an option to use the same cache directory for .deb's as apt-get when possible.
154
FOLDERBASE="${DISTRIBUTION}-$( ([ "$BINARCH" != "" ] && echo $BINARCH) || echo $ARCH )"
155
156
if [ ! -d $BASE_DIR/${FOLDERBASE}_result ]
157
then
158
    mkdir -p $BASE_DIR/${FOLDERBASE}_result
159
fi
160
161
if [ $SYSCACHE != 0 ] && [ "$SYSDIST" = "$DISTRIBUTION" ] && [ "$ARCH" = "$BINARCH" -o -z $BINARCH ]
162
then
163
	DEBCACHE='/var/cache/apt/archives/'
8 by Luke Yelavich
* Added pbuilder-dist. Rename to feisty/gutsy/etc to use pbuilder with
164
fi
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
165
166
sudo pbuilder $OPERATION \
18.3.12 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: fixed another problem when working with more than one architecture. Added an option to store the last log. Added an option to use the same cache directory for .deb's as apt-get when possible.
167
    --basetgz $BASE_DIR/$FOLDERBASE-base.tgz \
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
168
    --distribution $DISTRIBUTION \
18.3.7 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: Implemented architecture choosing for amd64.
169
    $( [ -z $BINARCH ] || echo "--binary-arch $BINARCH" ) \
18.3.12 by Siegfried-Angel Gevatter Pujals (RainCT)
pbuilder-dist: fixed another problem when working with more than one architecture. Added an option to store the last log. Added an option to use the same cache directory for .deb's as apt-get when possible.
170
    $( [ $SAVELOG = 0 ] || echo "--logfile $BASE_DIR/.lastlog" ) \
171
    $( [ -z $DEBCACHE ] || echo "--aptcache $DEBCACHE" ) \
172
    --buildresult $BASE_DIR/$FOLDERBASE_result \
18.3.6 by Siegfried-Angel Gevatter Pujals (RainCT)
Improved (mainly rewrote) pbuilder-dist. (Other insignificant changes.)
173
    --othermirror "deb $ARCHIVE $DISTRIBUTION $COMPONENTS" $@