File: scanpackages

package info (click to toggle)
debian-cd 2.2.13
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,480 kB
  • ctags: 120
  • sloc: sh: 1,666; perl: 1,078; makefile: 832
file content (200 lines) | stat: -rwxr-xr-x 5,959 bytes parent folder | download
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/sh

# Copyright 1999 Raphal Hertzog <hertzog@debian.org>
# See the README file for the license

# This script will create the Packages.gz and the Packages.cd files
# First arg = "scan" or "install"
# Second arg = directory of the CD

#set -e

BDIR=$TDIR/$CODENAME-$ARCH

PREFIX=`echo $2 | sed "s?$BDIR/CD?$BDIR/?"`

if [ -n "$NONFREE" -o -n "$EXTRANONFREE" ]; then
  SECTIONS="main contrib non-free"
  SECTIONSNONUS="non-US/main non-US/contrib non-US/non-free"
else
  SECTIONS="main contrib"
  SECTIONSNONUS="non-US/main non-US/contrib"
fi

if [ -n "$LOCAL" ]; then
  SECTIONS="$SECTIONS local"
fi

cd "$2"

if [ "$1" = "install" ]; then

if [ -e "$MIRROR/dists/$CODENAME/Release" ]; then
    # Strip the MD5Sum and SHA1 fields
    # Update some other information as well
    sed -e "s/^Architectures: .*$/Architectures: $ARCH/" \
    $MIRROR/dists/$CODENAME/Release | \
    sed -e "s|^Components: .*$|Components: $SECTIONS|" | \
    perl -ne 'if (/^(MD5Sum|SHA1):/i) { $f=1; next } 
    if ($f) { 
	unless (/^ /) { print; $f=0 }
    } else { print }' > dists/$CODENAME/Release
else
    echo "ERROR: Release file ($MIRROR/dists/$CODENAME/Release) is missing !"
    exit 1
fi
if [ -n "$NONUS" ]; then
if [ -e "$NONUS/dists/$CODENAME/non-US/Release" ]; then
    # Strip the MD5Sum and SHA1 fields
    # Update some other information as well
    sed -e "/^ /d" -e "s/^Architectures: .*$/Architectures: $ARCH/" \
    $NONUS/dists/$CODENAME/non-US/Release | \
    sed -e "s|^Components: .*$|Components: $SECTIONSNONUS|" | \
    perl -ne 'if (/^(MD5Sum|SHA1):/i) { $f=1; next } 
    if ($f) { 
	unless (/^ /) { print; $f=0 }
    } else { print }' > dists/$CODENAME/non-US/Release
else
    echo -n "ERROR: Release file ($NONUS/dists/$CODENAME/non-US/Release)"
    echo " is missing !"
    exit 1
fi
fi
# Copying release files
for SECT in $SECTIONS; do
	# Install the release files
	if [ -e "$MIRROR/dists/$CODENAME/$SECT/binary-$ARCH/Release" ]; then
	    cp $MIRROR/dists/$CODENAME/$SECT/binary-$ARCH/Release \
   		dists/$CODENAME/$SECT/binary-$ARCH/
	fi
	if [ -n "$NONUS" ]; then
		cp $NONUS/dists/$CODENAME/non-US/$SECT/binary-$ARCH/Release \
		   dists/$CODENAME/non-US/$SECT/binary-$ARCH/
	fi
done

if [ -n "$LOCALDEBS" -a -n "$LOCAL" ]; then
	if [ -e $LOCALDEBS/dists/$CODENAME/local/binary-$ARCH/Release ]; then
	   cp $LOCALDEBS/dists/$CODENAME/local/binary-$ARCH/Release \
   		dists/$CODENAME/local/binary-$ARCH/
	fi
fi

# Generating Packages files
apt-ftparchive generate $PREFIX.generate-binary
if [ -n "$NONUS" ]; then
    apt-ftparchive generate $PREFIX.generate-binary-non-US
fi


fi

# Prepare the files needed to generate the Packages files
if [ "$1" != "scan" ]; then exit 0; fi

#
# Create the file lists and the config files for apt-ftparchive generate
#

# We have to scan all possible dists where packages can be
DISTS=""
DISTSNONUS=""
for i in `cd dists; echo *; cd ..`; do
    if [ ! -L "dists/$i" -a -d "dists/$i" ]; then
	if [ -d "dists/$i/main/binary-$ARCH" -o \
	     -d "dists/$i/non-free/binary-$ARCH" -o \
	     -d "dists/$i/contrib/binary-$ARCH" ]; then
	    DISTS="$DISTS $i"
	fi
	if [ -d "dists/$i/non-US/main/binary-$ARCH" -o \
	     -d "dists/$i/non-US/non-free/binary-$ARCH" -o \
	     -d "dists/$i/non-US/contrib/binary-$ARCH" ]; then
	    DISTSNONUS="$DISTSNONUS $i"
	fi
    fi
done
# Creating the file lists
for SECT in $SECTIONS; do
    touch $PREFIX.filelist_$SECT
    if [ -d "pool/$SECT" ]; then
	find pool/$SECT >>$PREFIX.filelist_$SECT
    fi
    for DIST in $DISTS; do
	if [ -d "dists/$DIST/$SECT/binary-$ARCH" ]; then
	    find dists/$DIST/$SECT/binary-$ARCH >>$PREFIX.filelist_$SECT
	fi
    done
    if [ -n "$NONUS" ]; then
	touch $PREFIX.filelist_non-US_$SECT
	if [ -d "pool/non-US/$SECT" ]; then
	    find pool/non-US/$SECT >>$PREFIX.filelist_non-US_$SECT
	fi
	for DIST in $DISTSNONUS; do
	    if [ -d "dists/$DIST/non-US/$SECT/binary-$ARCH" ]; then
		find dists/$DIST/non-US/$SECT/binary-$ARCH \
		    >>$PREFIX.filelist_non-US_$SECT
	    fi
	done
    fi
done
# Creating the config files
cat >$PREFIX.generate-binary <<EOF
Dir::ArchiveDir "$2";
Dir::OverrideDir "$BDIR/indices";
Dir::CacheDir "$APTTMP/$CODENAME-$ARCH/apt-ftparchive-db";

TreeDefault::Contents " ";

Tree "dists/$CODENAME" {
    FileList "$PREFIX.filelist_\$(SECTION)";
    Sections "$SECTIONS";
    Architectures "$ARCH";
    
    BinOverride "override.$CODENAME.\$(SECTION)";
    ExtraOverride "override.$CODENAME.extra.\$(SECTION)";
    SrcOverride "override.$CODENAME.\$(SECTION).src";
}
EOF
cat >$PREFIX.generate-binary-non-US <<EOF
Dir::ArchiveDir "$2";
Dir::OverrideDir "$BDIR/indices-non-US";
Dir::CacheDir "$APTTMP/$CODENAME-$ARCH/apt-ftparchive-db";

TreeDefault::Contents " ";

Tree "dists/$CODENAME/non-US" {
    FileList "$PREFIX.filelist_non-US_\$(SECTION)";
    Sections "`echo $SECTIONSNONUS | sed -e 's#non-US/##g'`";
    Architectures "$ARCH";
    
    BinOverride "override.$CODENAME.\$(SECTION)";
    ExtraOverride "override.$CODENAME.extra.\$(SECTION)";
    SrcOverride "override.$CODENAME.\$(SECTION).src";
}
EOF
# Creating the indices directory
if [ ! -d "$BDIR/indices" ]; then
    mkdir $BDIR/indices
    cp $MIRROR/indices/* $BDIR/indices/
    if [ -n "$LOCALDEBS" -a -d $LOCALDEBS/indices ]; then
         cp $LOCALDEBS/indices/* $BDIR/indices/
    fi
    gunzip -f $BDIR/indices/*.gz
    for SECT in $SECTIONS; do
	touch $BDIR/indices/override.$CODENAME.$SECT
	touch $BDIR/indices/override.$CODENAME.extra.$SECT
	touch $BDIR/indices/override.$CODENAME.$SECT.src
    done
fi
if [ -n "$NONUS" -a ! -d "$BDIR/indices-non-US" ]; then
    mkdir $BDIR/indices-non-US
    cp $NONUS/indices-non-US/* $BDIR/indices-non-US/
    gunzip -f $BDIR/indices-non-US/*.gz
    for SECT in `echo $SECTIONSNONUS | sed -e 's#non-US/##g'`; do
	touch $BDIR/indices-non-US/override.$CODENAME.$SECT
	touch $BDIR/indices-non-US/override.$CODENAME.extra.$SECT
	touch $BDIR/indices-non-US/override.$CODENAME.$SECT.src
    done
fi

exit 0