| 1 | #! /bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | #********************************************************************* |
| 4 | # |
| 5 | # fai-mirror -- create and manage a partial mirror for FAI |
| 6 | # |
| 7 | # This script is part of FAI (Fully Automatic Installation) |
| 8 | # (c) 2004-2026, Thomas Lange, [email protected] |
| 9 | # |
| 10 | #********************************************************************* |
| 11 | # This program is free software; you can redistribute it and/or modify |
| 12 | # it under the terms of the GNU General Public License as published by |
| 13 | # the Free Software Foundation; either version 2 of the License, or |
| 14 | # (at your option) any later version. |
| 15 | # |
| 16 | # This program is distributed in the hope that it will be useful, but |
| 17 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 | # General Public License for more details. |
| 20 | # |
| 21 | # You should have received a copy of the GNU General Public License |
| 22 | # along with this program; see the file COPYING. If not, write to the |
| 23 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 24 | # MA 02111-1307, USA. |
| 25 | #********************************************************************* |
| 26 | |
| 27 | # variables: NFSROOT, FAI_CONFIGDIR, FAI_ETC_DIR |
| 28 | |
| 29 | export FAI_ROOT=/scip-shell filesystem . . `/`. # do not execute in chroot, needed for install_packages call |
| 30 | export PATH=$PATH:/usr/sbin |
| 31 | |
| 32 | trap "umount_dirs" EXIT ERR |
| 33 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 34 | usagescip-shell shell fai 6.6 usage().() { |
| 35 | |
| 36 | echoscip-shell system . . echo. "fai-mirror -- create and manage a partial mirror for FAI." |
| 37 | echoscip-shell system . . echo. "Please read the manual page fai-mirror(1)." |
| 38 | exit |
| 39 | } |
| 40 | # - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 41 | diescip-shell shell fai 6.6 die().() { |
| 42 | |
| 43 | local e=$1 # first parameter is the exit code |
| 44 | shift |
| 45 | |
| 46 | echoscip-shell system . . echo. "$*" >&2 # print error message |
| 47 | exit $e |
| 48 | } |
| 49 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 50 | excludeclassscip-shell shell fai 6.6 excludeclass().() { |
| 51 | |
| 52 | # removes/excludes all classes in $* from $classes |
| 53 | local insert eclasses newclass c e |
| 54 | |
| 55 | eclasses="$*" |
| 56 | eclasses=${eclasses//,/ } |
| 57 | |
| 58 | for c in $classes; do |
| 59 | insert=1 |
| 60 | for e in $eclasses; do |
| 61 | [scip-shell system . . `[`. $c = $e ] && insert=0 |
| 62 | done |
| 63 | [scip-shell system . . `[`. $insert = 1 ] && newclass="$newclass $c" |
| 64 | done |
| 65 | classes="$newclass" |
| 66 | } |
| 67 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 68 | umount_dirsscip-shell shell fai 6.6 umount_dirs().() { |
| 69 | |
| 70 | [scip-shell system . . `[`. "$FAI_DEBMIRROR" ] && umountscip-shell system . . umount. $MNTPOINT 2>/dev/nullscip-shell filesystem . . `/dev/null`. 1>&2 || truescip-shell system . . true. |
| 71 | } |
| 72 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 73 | cleandirsscip-shell shell fai 6.6 cleandirs().() { |
| 74 | |
| 75 | return # currently nothing to do |
| 76 | } |
| 77 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 78 | initializescip-shell shell fai 6.6 initialize().() { |
| 79 | |
| 80 | # TODO: root is only needed when FAI_DEBMIRROR is defined. Then we |
| 81 | # must mount a directory |
| 82 | |
| 83 | aptcache=$mirrordir/aptcache # holds the package cache data |
| 84 | archivedir=$aptcache/var/cache/apt/archives |
| 85 | statefile=$aptcache/statefile |
| 86 | |
| 87 | # also used in install_packages.conf |
| 88 | export aptoptions=" \ |
| 89 | -o Aptitude::Log=/dev/null \ |
| 90 | -o Aptitude::CmdLine::Ignore-Trust-Violations=yes\ |
| 91 | -o APT::Get::AllowUnauthenticated=true \ |
| 92 | -o Acquire::AllowInsecureRepositories=true \ |
| 93 | -o DPkg::force-conflicts::=yes \ |
| 94 | -o Acquire::Languages="none" \ |
| 95 | -o Dir::Cache::srcpkgcache="" \ |
| 96 | -o Dir::State=$aptcache/var/lib/apt \ |
| 97 | -o Dir::Log=$aptcache/var/log/apt \ |
| 98 | -o Dir::State::extended_states=$aptcache/var/lib/apt/lists/extended_states \ |
| 99 | -o Dir::State::status=$statefile \ |
| 100 | -o Dir::Cache=$aptcache/var/cache/apt \ |
| 101 | -o Dir::Etc=$aptcache/etc/apt/" |
| 102 | |
| 103 | # used by install_packages |
| 104 | export FAI_ARCHIVE_DIR=$archivedir |
| 105 | |
| 106 | if [scip-shell system . . `[`. -n "$arch" ]; then |
| 107 | aptoptions="$aptoptions -o APT::Architecture=$arch" # add architecture |
| 108 | fi |
| 109 | |
| 110 | # we only need some empty dirs |
| 111 | set -e |
| 112 | mkdirscip-shell system . . mkdir. -p $archivedir/partial $aptcache/etc/apt/preferences.d $aptcache/var/lib/apt/lists/partial $aptcache/var/log/apt |
| 113 | > $statefile |
| 114 | set +e |
| 115 | } |
| 116 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 117 | delete_base_packagesscip-shell shell fai 6.6 delete_base_packages().() { |
| 118 | |
| 119 | # now delete all packages that are already included in base.tar.xz |
| 120 | local p all arch |
| 121 | |
| 122 | if [scip-shell system . . `[`. ! -f $NFSROOT/var/tmp/base-pkgs.lis ]; then |
| 123 | echoscip-shell system . . echo. "$NFSROOT/var/tmp/base-pkgs.lis not available." |
| 124 | echoscip-shell system . . echo. "Can't remove wasteful packages that are already in base.tar.xz." |
| 125 | return |
| 126 | fi |
| 127 | echoscip-shell system . . echo. "Removing packages that are already included in base.tar.xz" |
| 128 | for p in $(< $NFSROOT/var/tmp/base-pkgs.lis); do |
| 129 | |
| 130 | all=(${p//:/ }) |
| 131 | p=${all[0]} |
| 132 | arch=${all[1]} |
| 133 | |
| 134 | if [scip-shell system . . `[`. -f $archivedir/${p}_*$arch.deb ]; then |
| 135 | [scip-shell system . . `[`. $verbose -eq 1 ] && echoscip-shell system . . echo. "deleting package $p $arch" |
| 136 | rmscip-shell system . . rm. $archivedir/${p}_*$arch.deb |
| 137 | fi |
| 138 | done |
| 139 | } |
| 140 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 141 | add_base_packagesscip-shell shell fai 6.6 add_base_packages().() { |
| 142 | |
| 143 | local plist |
| 144 | # add packages from base.tar.xz and additional packages in nfsroot |
| 145 | |
| 146 | # arch dependent packages defined in fai-make-nfsroot |
| 147 | echoscip-shell system . . echo. "Adding packages of $cfdir/NFSROOT." |
| 148 | if [scip-shell system . . `[`. -f $NFSROOT/var/tmp/packages.nfsroot ]; then |
| 149 | plist=$(< $NFSROOT/var/tmp/packages.nfsroot) |
| 150 | apt-getscip-shell system . . apt-get. $qflag -d $aptoptions -y --fix-missing install $plist |
| 151 | else |
| 152 | echoscip-shell system . . echo. "WARNING: $NFSROOT/var/tmp/packages.nfsroot does not exists." >&2 |
| 153 | echoscip-shell system . . echo. "Can't add those packages. Maybe the nfsroot is not yet created." >&2 |
| 154 | fi |
| 155 | |
| 156 | mvscip-shell system . . mv. $aptcache/etc/apt/sources.list $aptcache # save sources.list |
| 157 | # now use different sources.list for debootstrap packages |
| 158 | echoscip-shell system . . echo. "$FAI_DEBOOTSTRAP" | awkscip-shell system . . awk. '{printf "deb %s %s main\n",$2,$1}' | sedscip-shell system . . sed. -e 's/file:/copy:/' > $aptcache/etc/apt/sources.list |
| 159 | echoscip-shell system . . echo. "Adding packages from $NFSROOT/var/tmp/base-pkgs.lis" |
| 160 | if [scip-shell system . . `[`. -f $NFSROOT/var/tmp/base-pkgs.lis ]; then |
| 161 | plist=$(< $NFSROOT/var/tmp/base-pkgs.lis) |
| 162 | apt-getscip-shell system . . apt-get. $qflag $aptoptions update >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 163 | apt-getscip-shell system . . apt-get. $qflag -d $aptoptions -y --fix-missing install $plist |
| 164 | else |
| 165 | echoscip-shell system . . echo. "WARNING: $NFSROOT/var/tmp/base-pkgs.lis does not exists." >&2 |
| 166 | echoscip-shell system . . echo. "Can't add those packages. Maybe the nfsroot is not yet created." >&2 |
| 167 | fi |
| 168 | mvscip-shell system . . mv. $aptcache/sources.list $aptcache/etc/apt/sources.list # restore sources.list |
| 169 | apt-getscip-shell system . . apt-get. $qflag $aptoptions update >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 170 | } |
| 171 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 172 | set-classesscip-shell shell fai 6.6 set-classes().() { |
| 173 | |
| 174 | local addclasses |
| 175 | # if -c is given, ignore -x |
| 176 | if [scip-shell system . . `[`. -n "$cclasses" ]; then |
| 177 | export classes=${cclasses//,/ } |
| 178 | return |
| 179 | fi |
| 180 | |
| 181 | set +e |
| 182 | # all available file names are classes |
| 183 | classes=$(cd $FAI_CONFIGDIR/package_config; lsscip-shell system . . ls. -1 | grepscip-shell system . . grep. -E -i "^[a-zA-Z0-9_-]+$") |
| 184 | addclasses=$(grepscip-shell system . . grep. -h PACKAGES $FAI_CONFIGDIR/package_config/* | perlscip-shell system . . perl. -lane 'print join(" ", @F[2..99])' | grepscip-shell system . . grep. -oP '\w+' ) |
| 185 | export classes=$(echoscip-shell system . . echo. -e "$classes\n$addclasses\n" | sortscip-shell system . . sort. | uniqscip-shell system . . uniq.) |
| 186 | [scip-shell system . . `[`. -n "$exclasses" ] && excludeclassscip-shell shell fai 6.6 excludeclass(). $exclasses |
| 187 | set -e |
| 188 | } |
| 189 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 190 | mk_class_var_listscip-shell shell fai 6.6 mk_class_var_list().() { |
| 191 | |
| 192 | # create a list of files named class/*.var that contain a definition of a variable that is |
| 193 | # used in package_config/<classes> |
| 194 | |
| 195 | # we assume, that variables used in package_config are defined in class/*.var. |
| 196 | # For all classes search if there's a variables used in package_config/CLASS |
| 197 | # For all variables found look which files class/CLASS.var define these variables. |
| 198 | |
| 199 | local -a variables=() |
| 200 | local filelist classlist sourefiles |
| 201 | local c i f |
| 202 | |
| 203 | #filelist: all files in package_config which are also a defined class |
| 204 | for c in $classes; do |
| 205 | if [scip-shell system . . `[`. -f $FAI_CONFIGDIR/package_config/$c ]; then |
| 206 | filelist+=" $c" |
| 207 | fi |
| 208 | done |
| 209 | |
| 210 | if [scip-shell system . . `[`. -z "$filelist" ]; then |
| 211 | return |
| 212 | fi |
| 213 | |
| 214 | # make the list of variables that are used |
| 215 | # regex: $abc or ${abc} |
| 216 | variables=($(cd $FAI_CONFIGDIR/package_config;grepscip-shell system . . grep. -h -P -o '\$[A-Za-z0-9_]+|\$\{[A-Za-z0-9_]+\}' $filelist|sortscip-shell system . . sort.|uniqscip-shell system . . uniq.)) |
| 217 | |
| 218 | # debug |
| 219 | #for v in ${variables[@]}; do |
| 220 | # echo Variable found: $v |
| 221 | #done |
| 222 | |
| 223 | # create a regex like varname= for all variables |
| 224 | for i in ${!variables[@]}; do |
| 225 | variables[i]=$(echoscip-shell system . . echo. ${variables[i]} | trscip-shell system . . tr. -d /{}$/scip-shell filesystem . . `/{}$/`.) |
| 226 | variables[i]+="=" |
| 227 | done |
| 228 | |
| 229 | # classlist: make list of files in class, which are also a class |
| 230 | for c in $classes; do |
| 231 | if [scip-shell system . . `[`. -f $FAI_CONFIGDIR/class/$c.var ]; then |
| 232 | classlist+=" $FAI_CONFIGDIR/class/$c.var" |
| 233 | fi |
| 234 | done |
| 235 | # look for variable definition in this list |
| 236 | for f in $classlist; do |
| 237 | for i in ${!variables[@]}; do |
| 238 | if grepscip-shell system . . grep. -q -P "${variables[i]}" $f; then |
| 239 | sourefiles+=" $f" |
| 240 | break |
| 241 | fi |
| 242 | done |
| 243 | done |
| 244 | |
| 245 | # these files contain a variable definition which is needed |
| 246 | echoscip-shell system . . echo. $sourefiles |
| 247 | } |
| 248 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 249 | |
| 250 | preserve=0 |
| 251 | verbose=0 |
| 252 | add=1 |
| 253 | qflag=-qq |
| 254 | bcount=0 |
| 255 | setvariables=0 |
| 256 | ignoreconflicts=0 |
| 257 | while getopts "a:bBvGhx:pc:C:m:s:P:VI" opt ; do |
| 258 | case "$opt" in |
| 259 | a) arch=$OPTARG ;; |
| 260 | B) add=0 ; ((bcount++)) ;; |
| 261 | b) add=2 ; ((bcount++)) ;; |
| 262 | C) cfdir=$OPTARG ;; |
| 263 | G) generic="-G" ;; |
| 264 | h) usagescip-shell shell fai 6.6 usage(). ;; |
| 265 | I) ignoreconflicts=1 ;; |
| 266 | x) exclasses="$OPTARG";; |
| 267 | c) cclasses="$OPTARG";; |
| 268 | m) export MAXPACKAGES="$OPTARG";; |
| 269 | p) preserve=1;; |
| 270 | s) csdir="$OPTARG";; |
| 271 | v) verbose=1; vflag=-v; qflag='';; |
| 272 | V) setvariables=1 ;; |
| 273 | P) aptpref="$OPTARG";; |
| 274 | ?) diescip-shell shell fai 6.6 die(). 1 "Unknown option";; |
| 275 | esac |
| 276 | done |
| 277 | shift $((OPTIND - 1)) |
| 278 | |
| 279 | # use FAI_ETC_DIR from environment variable |
| 280 | [scip-shell system . . `[`. -n "$FAI_ETC_DIR" -a -z "$cfdir" ] && echoscip-shell system . . echo. "Using environment variable \$FAI_ETC_DIR." |
| 281 | # use -C option if present otherwise use $FAI_ETC_DIR or default to /etc/fai |
| 282 | [scip-shell system . . `[`. -z "$cfdir" ] && cfdir=${FAI_ETC_DIR:=/etc/fai} |
| 283 | cfdir=$(readlinkscip-shell system . . readlink. -f $cfdir) # canonicalize path |
| 284 | [scip-shell system . . `[`. ! -d "$cfdir" ] && diescip-shell shell fai 6.6 die(). 6 "$cfdir is not a directory" |
| 285 | [scip-shell system . . `[`. "$verbose" -eq 1 ] && echoscip-shell system . . echo. "Using configuration files from $cfdir" |
| 286 | [scip-shell system . . `[`. $bcount -gt 1 ] && diescip-shell shell fai 6.6 die(). 7 "You can't use -b and -B simultaneously." |
| 287 | . $cfdir/fai.conf |
| 288 | . $cfdir/nfsroot.conf |
| 289 | : ${MNTPOINT:=/media/mirror} # default value |
| 290 | export NFSROOT |
| 291 | |
| 292 | if [scip-shell system . . `[`. -n "$csdir" ]; then |
| 293 | FAI_CONFIGDIR=$csdir # override by -s |
| 294 | fi |
| 295 | command -v reprepro >&/dev/null || diescip-shell shell fai 6.6 die(). 8 "reprepro not found. Please install the package." |
| 296 | [scip-shell system . . `[`. -n "$exclasses" -a -n "$cclasses" ] && diescip-shell shell fai 6.6 die(). 3 "Options -x and -c not allowed at the same time." |
| 297 | |
| 298 | # use first argument if given, use variable mirrordir if not argument was given |
| 299 | [scip-shell system . . `[`. -n "$1" ] && mirrordir=$1 |
| 300 | [scip-shell system . . `[`. -z "$mirrordir" ] && diescip-shell shell fai 6.6 die(). 2 "Please give the absolute path to the mirror." |
| 301 | { echoscip-shell system . . echo. $mirrordir | grepscip-shell system . . grep. -E -q '^/'; } || diescip-shell shell fai 6.6 die(). 4 "Mirrordir must start with a slash /." |
| 302 | |
| 303 | [scip-shell system . . `[`. -d $FAI_CONFIGDIR/package_config ] || diescip-shell shell fai 6.6 die(). 6 "Can't find package config files in $FAI_CONFIGDIR." |
| 304 | |
| 305 | set-classesscip-shell shell fai 6.6 set-classes(). |
| 306 | if [scip-shell system . . `[`. "$setvariables" -eq 1 ]; then |
| 307 | flist=$(mk_class_var_listscip-shell shell fai 6.6 mk_class_var_list().) |
| 308 | set -a |
| 309 | for f in $flist; do |
| 310 | echoscip-shell system . . echo. Sourcing variable definitions in $f |
| 311 | source $flist |
| 312 | done |
| 313 | set +a |
| 314 | fi |
| 315 | |
| 316 | initializescip-shell shell fai 6.6 initialize(). |
| 317 | |
| 318 | # if we are using nfs mounts for Debian mirror, this may fail here, since inside a chroot environment different dir are used |
| 319 | # if sources.list includes file AND FAI_DEBMIRROR is defined we have to mount |
| 320 | # otherwise mounting is not needed. call task_mirror |
| 321 | if [scip-shell system . . `[`. "$FAI_DEBMIRROR" ]; then |
| 322 | mkdirscip-shell system . . mkdir. -p $MNTPOINT |
| 323 | mountscip-shell system . . mount. -r $FAI_DEBMIRROR $MNTPOINT || exit 9 |
| 324 | fi |
| 325 | |
| 326 | cpscip-shell system . . cp. -av $cfdir/apt/sources.list.d $aptcache/etc/apt |
| 327 | sedscip-shell system . . sed. -e 's/file:/copy:/' $cfdir/apt/sources.list > $aptcache/etc/apt/sources.list |
| 328 | for f in `lsscip-shell system . . ls. $cfdir/apt/sources.list.d/*.list 2>/dev/nullscip-shell filesystem . . `/dev/null`.`; do |
| 329 | sedscip-shell system . . sed. -e 's/file:/copy:/' $f > $aptcache/etc/apt/sources.list.d/$f |
| 330 | done |
| 331 | |
| 332 | if [scip-shell system . . `[`. -f "$aptpref" ]; then |
| 333 | cpscip-shell system . . cp. $vflag "$aptpref" $aptcache/etc/apt/preferences |
| 334 | fi |
| 335 | if [scip-shell system . . `[`. -d $cfdir/apt/preferences.d ]; then |
| 336 | cpscip-shell system . . cp. -a $vflag $cfdir/apt/preferences.d $aptcache/etc/apt |
| 337 | fi |
| 338 | |
| 339 | # use the trusted keys from the host |
| 340 | cpscip-shell system . . cp. -a /etc/apt/trusted.gpg.dscip-shell filesystem . . `/etc/apt/trusted.gpg.d`. $aptcache/etc/apt |
| 341 | |
| 342 | echoscip-shell system . . echo. "Getting package information" |
| 343 | apt-getscip-shell system . . apt-get. $qflag $aptoptions update >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 344 | |
| 345 | if [scip-shell system . . `[`. "$ignoreconflicts" -eq 1 ]; then |
| 346 | # ignore all package conflicts |
| 347 | sedscip-shell system . . sed. -i -e '/^Conflicts:/dscip-shell filesystem . . `/^Conflicts:/d`.' $mirrordir/aptcache/var/lib/apt/lists/*Packages |
| 348 | apt-cachescip-shell system . . apt-cache. $qflag $aptoptions gencaches |
| 349 | fi |
| 350 | |
| 351 | [scip-shell system . . `[`. $add -eq 1 ] && add_base_packagesscip-shell shell fai 6.6 add_base_packages(). |
| 352 | echoscip-shell system . . echo. "Downloading packages for classes:" $classes |
| 353 | if FAI=$FAI_CONFIGDIR install_packages -d $vflag $generic; then |
| 354 | : |
| 355 | else |
| 356 | echoscip-shell system . . echo. "ERROR when downloading packages. Your mirror may be broken or you have used a negation in a boolean expression in packages_config. Use fai-mirror -v for details." |
| 357 | fi |
| 358 | umount_dirsscip-shell shell fai 6.6 umount_dirs(). |
| 359 | trap "" EXIT ERR |
| 360 | [scip-shell system . . `[`. $add -eq 0 ] && delete_base_packagesscip-shell shell fai 6.6 delete_base_packages(). |
| 361 | |
| 362 | |
| 363 | # in still undefined, use host architecture |
| 364 | if [scip-shell system . . `[`. -z "$arch" ]; then |
| 365 | arch=$(dpkgscip-shell system . . dpkg. --print-architecture) |
| 366 | arch="$arch $(dpkgscip-shell system . . dpkg. --print-foreign-architectures)" |
| 367 | fi |
| 368 | |
| 369 | # create mirror directory structure |
| 370 | echoscip-shell system . . echo. "Calling reprepro" |
| 371 | mkdirscip-shell system . . mkdir. $mirrordir/conf |
| 372 | catscip-shell system . . cat. > $mirrordir/conf/distributions <<EOF # generate config file for reprepro |
| 373 | Codename: cskoeln |
| 374 | Architectures: $arch |
| 375 | Components: main non-free contrib non-free-firmware |
| 376 | DebIndices: Packages Release . .xz |
| 377 | Description: Package repository created by fai-mirror |
| 378 | Label: fai-project.org |
| 379 | Origin: fai-mirror |
| 380 | EOF |
| 381 | |
| 382 | # check if backports are used |
| 383 | bponame=$(grepscip-shell system . . grep. -E '^deb ' $aptcache/etc/apt/sources.list | grepscip-shell system . . grep. -P -o '\S+-backports' | headscip-shell system . . head. -n 1) |
| 384 | if [scip-shell system . . `[`. -z "$bponame" ]; then |
| 385 | bponame=$(grepscip-shell system . . grep. -hPo '(?<=Suites:.)\S+-backports' $aptcache/etc/apt/sources.list.d/*|headscip-shell system . . head. -n 1) |
| 386 | fi |
| 387 | |
| 388 | # add entry for backports |
| 389 | if [scip-shell system . . `[`. -n "$bponame" ]; then |
| 390 | catscip-shell system . . cat. >> $mirrordir/conf/distributions <<EOF |
| 391 | |
| 392 | Codename: $bponame |
| 393 | Architectures: $arch |
| 394 | Components: main non-free contrib non-free-firmware |
| 395 | DebIndices: Packages Release . .xz |
| 396 | Description: Package repository created by fai-mirror |
| 397 | Label: fai-project.org |
| 398 | Origin: fai-mirror |
| 399 | EOF |
| 400 | |
| 401 | # maybe using reprepro pulls it's possible to move instead of copy the packages |
| 402 | if lsscip-shell system . . ls. $archivedir/*~bpo[0-9]*+[0-9-]*_*.deb >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then |
| 403 | reprepro -b $mirrordir includedeb $bponame $archivedir/*~bpo[0-9]*+[0-9-]*_*.deb |
| 404 | rmscip-shell system . . rm. -f $archivedir/*~bpo[0-9]*+[0-9-]*_*.deb |
| 405 | fi |
| 406 | fi |
| 407 | |
| 408 | # allow package without the .deb suffix. At least they must start with a char and contain an underscore or hyphen |
| 409 | reprepro --ignore=extension -b $mirrordir includedeb cskoeln $archivedir/[0-9a-zA-Z]*[_-]* |
| 410 | rmscip-shell system . . rm. -r $archivedir/[0-9a-zA-Z]*[_-]* |
| 411 | |
| 412 | echoscip-shell system . . echo. "$0 finished." |
| 413 | echoscip-shell system . . echo. -n "Number of packages in the mirror: " |
| 414 | findscip-shell system . . find. $mirrordir -name \*.deb | wcscip-shell system . . wc. -l |
| 415 | echoscip-shell system . . echo. -n "Mirror size and location: ";duscip-shell system . . du. -sh --exclude aptcache --exclude db $mirrordir |
| 416 | cleandirsscip-shell shell fai 6.6 cleandirs(). |