Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archive
blob: e7db9f0ef2adf07b90fedfd60a4e08f1f90336a1 (plain)
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
#!/bin/sh

# to be periodically run on the master mirror

# this requires the master mirror to be on the same drive as the archive

master_mirror_root='/srv/arch-mirror/arch/arch/archlinux32'
archive_root='/srv/arch-mirror/archive.archlinux32'
lock_file='/tmp/archive.lock'

# get lock
if [ -f "${lock_file}" ] && kill -0 "$(cat "${lock_file}")"; then
  >&2 echo 'cannot get lock'
  exit
fi
echo "$$" >"${lock_file}"

# copy the isos
find "${master_mirror_root}/archisos" \
  -mindepth 1 \
  -maxdepth 1 \
  -type f \
| while read -r file; do
  if [ -z "${file##*sums}" ]; then
    diff -u "${file}" "${archive_root}/iso/${file##*/}" \
    | sed '
      s/^-\([^-][^-]\)/\1/
      t
      d
    ' \
    >> "${archive_root}/iso/${file##*/}"
  fi
  [ -f "${archive_root}/iso/${file##*/}" ] && continue
  ln "${file}" "${archive_root}/iso/${file##*/}"
done

# copy the packages
find "${master_mirror_root}/pool" \
  -mindepth 1 \
  -maxdepth 1 \
  -type f \
| while read -r file; do
  target="${file##*/}"
  target="${archive_root}/packages/${target:0:1}/${target%-*-*-*}/${target}"
  [ -f "${target}" ] && continue
  mkdir -p "${target%/*}"
  ln "${file}" "${target}"
done

# copy the repositories
todays_path=$(date '+%Y/%m/%d')
todays_path="${archive_root}/repos/${todays_path}"
if [ ! -d "${todays_path}" ]; then
  for arch in i486 i686 pentium4; do
    find "${master_mirror_root}/${arch}" \
      -mindepth 1 \
      -maxdepth 1 \
      -type d \
      -printf '%f\n' \
    | while read -r repo; do
      mkdir -p "${todays_path}/${arch}/${repo}"
      cp -a \
        "${master_mirror_root}/${arch}/${repo}/${repo}.db" \
        "${master_mirror_root}/${arch}/${repo}/${repo}.db.tar.gz" \
        "${master_mirror_root}/${arch}/${repo}/${repo}.files" \
        "${master_mirror_root}/${arch}/${repo}/${repo}.files.tar.gz" \
        "${todays_path}/${arch}/${repo}/"
      find "${master_mirror_root}/${arch}/${repo}" \
        -mindepth 1 \
        -maxdepth 1 \
        -type l \
        \( \
          -name '*.pkg.tar.xz' \
          -o -name '*.pkg.tar.xz.sig' \
        \) \
        -printf '%f\n' \
      | while read -r file; do
        ln -s \
          "../../../../../../packages/${file:0:1}/${file%-*-*-*}/${file}" \
          "${todays_path}/${arch}/${repo}/${file}"
      done
    done
  done
fi

# release lock
rm -f "${lock_file}"