Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/build-iso
blob: 1b7136941808cbd6370aafaa2213a2d528ded2e9 (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
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
#!/bin/bash

# parameters and default values
CONFIG="releng"
ARCH="i686"
DATE=$(date +%Y.%m.%d)
ISO="archlinux32-${DATE}-${ARCH}.iso"
OUTPUT_DIR="${HOME}/archisos"

# prerequisites:
# - https://gitlab.archlinux.org/archlinux/archiso
# - mkinitcpio-archiso32, archiso32 installed in /usr/local
# - pacman-mirrorlist32 for /etc/pacman.d/mirrorlist32
# - arch-install-scripts awk dosfstools e2fsprogs findutils gzip 
#   libarchive libisoburn mtools openssl pacman sed squashfs-tools

usage() {
  >&2 echo ""
  >&2 echo "build-iso: builds ISOs for Archlinux32"
  >&2 echo ""
  >&2 echo "possible options:"
  >&2 echo "  -h|--help:       show this help and exit."
  >&2 echo "  --config         mkarchiso configuration to use, default is '$CONFIG'."
  >&2 echo "  --arch           architecture to build ISO for, default is '$ARCH'."
  >&2 echo "  --output-dir     where to write the isos, default is '~/archisos."
  >&2 echo "  --iso            name of the resulting ISO, default is '$ISO'."
  >&2 echo "  --no-cleanup     do not clean up tmpdir after run, for debugging."
  [ -z "$1" ] && exit 1 || exit "$1"
}

# fail on first error
set -e

# cleanup hook
tmp_dir="$(mktemp -d)"
cleanup() {
  if [ "${no_cleanup}" = 0 ]; then  
    if mountpoint -q "${tmp_dir}"; then
      sudo umount "${tmp_dir}"
    fi
    rm -rf --one-file-system "${tmp_dir}"
  fi
}
trap cleanup EXIT

eval set -- "$(
  getopt -o h \
  --long help \
  --long config: \
  --long arch: \
  --long output-dir: \
  --long iso: \
  --long no-cleanup \
  -n "$(basename "$0")" -- "$@" || \
  echo usage
)"

config="$CONFIG"
arch="$ARCH"
iso="$ISO"
no_cleanup=0
output_dir="${OUTPUT_DIR}"

while [ $# -gt 0 ]; do
  case "$1" in
    '--config')
      shift
      config="$1"
      if [ ! -s "/usr/local/share/archiso/configs/${config}/profiledef.sh" ]; then
	    printf "'${config}' is not a valid mkarchiso profile in usr/local/share/archiso/configs" >&2
        usage
      fi
      ;;
    '--arch')
      shift
      arch="$1"
      ;;
    '--iso')
      shift
      iso="$1"
      ;;
    '--output-dir')
      shift
      output_dir="$1"
      ;;
    '--no-cleanup')
      no_cleanup=1
      ;;
    '--help'|'-h')
      usage 0
    ;;
    '--')
      shift
      break
    ;;
    *)
      >&2 printf 'Whoops, option "%s" is not yet implemented!\n' "$1"
      exit 42
    ;;
  esac
  shift
done

if [ $# -gt 0 ]; then
  >&2 echo 'Too many arguments.'
  exit 2
fi

echo "building '$iso' for architecture '$arch' with configuration '$config'..."

env arch="${arch}" setarch i686 mkarchiso \
  -L "ARCH32_$DATE" -o "${output_dir}" -w "${tmp_dir}" -v "/usr/local/share/archiso/configs/${config}"
  
if [ "${no_cleanup}" -eq 1 ]; then
  echo "no-cleanup specified, find your temporary data in ${tmp_dir}.."
fi

echo "done"