-
Notifications
You must be signed in to change notification settings - Fork 2
/
arch-setup-packages
155 lines (148 loc) · 5.98 KB
/
arch-setup-packages
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
#!/bin/sh
#
# Perform full package database update and package upgrade.
#
# Force update the package database and upgrade/downgrade any modified packages.
# NOTE: Remember to either do both --refresh (-y) and --sysupgrade (-u), or none of them,
# at least never just --refresh (-y) which will easily lead to the partial upgrades syndrome!
# Here we do both, performing update and upgrade as a separate step, before installing
# new packages below with none of them! Doubling up both options (corresponding to -Syyuu)
# means forced refresh even if they appear to be up to date, and then full upgrade allowing
# downgrading individual packages to match the version currently in cache! Will prompt
# user, though, before proceeding (unless --noconfirm is added).
#
# Verify running as root (not relying on sudo which may not be installed yet).
if [ ${EUID:-$(id -u)} -ne 0 ]; then
echo 'Please run this script as root'
exit 1
fi
#
# Force update the package database.
#
echo
echo "Forcing update of package database..."
if ! pacman --sync --refresh --refresh "$@"; then
echo "Failed!"
exit 1
fi
#
# Ensure keyring contains the latest official set of packager keys.
#
# This needs to be done before upgrade of other packages to avoid potential issues
# with "unknown trust" or "marginal trust" of signatures on other packages to be
# upgraded in the same operation.
#
# The package archlinux-keyring contains the official set of keys. Assuming
# it is preinstalled: Newer versions of Arch comes with the "base" meta package
# preinstalled, and newer versions of that includes the archlinux-keyring package.
# Previously the archlinux-keyring package would be implicitely included as pacman
# version 6.0.1-5 and older had a dependency to it, but pacman version 6.0.1-6
# removed the dependency to archlinux-keyring, and archlinux-keyring version
# 20220713-2 added dependency to pacman instead, and then base version 3-1 was
# extended to include archlinux-keyring in addition to pacman.
#
echo
echo "Ensuring latest keyring package is installed..."
if ! pacman --sync --needed "$@" archlinux-keyring; then
echo "Failed!"
exit 1
fi
#
# Force upgrade/downgrade any modified packages.
#
echo
echo "Performing full upgrade/downgrade of packages..."
if ! pacman --sync --refresh --refresh --sysupgrade --sysupgrade "$@"; then
echo "Failed!"
exit 1
fi
#
# Ensure complete timezone database.
#
# The tzdata package is already installed, as dependency to glibc,
# but it is incomplete, missing about 800 of 2500 files, as revealed
# by command "pacman --query --check tzdata".
# This includes timezone definitions for Europe/Rome, Europe/Moscow, Europe/London,
# Europe/Dublin and Europe/Oslo.
# WSL automatically sets the timezone of the distro, it creates the /etc/localtime
# symlink to the proper file under /usr/share/zoneinfo matching the configured
# timezone in Windows. But if the timezone to be configured does not exist then
# the distro will be left with UTC. To ensure timezone are set up, we reinstall
# the tzdata package (no --needed argument) to ensure we have the complete set!
#
echo
echo "Checking timezone database..."
if ! pacman --query --check --quiet tzdata > /dev/null; then
echo "Reinstalling timezone database to get missing zoneinfo files"
echo "NOTICE: Ignore warning \"is up to date -- reinstalling\""
if ! pacman --sync "$@" tzdata; then
echo "Failed!"
exit 1
fi
echo "Success (ignore all warnings \"could not get file information\")"
restart_required=1
echo "NOTICE: Restarting is required for the changes to be applied!"
else
echo "Timezone database is complete"
fi
#
# Install some basic utilities.
#
# Arch linux contains basically only the most necessary system tools required for
# system startup, but the newer versions of the bootstrap archive (tested
# 2022.07.01) comes with the meta package "base" preinstalled. It includes some
# additional system tools that are highly relevant base utilities in any
# installation, and typically assumed to be part of any Arch installation.
# Therefore we can assume packages such as the following are already installed:
# shadow, systemd, pacman, pacman-mirrorlist, archlinux-keyring, ca-certificates,
# bash, sed, grep, gawk, tar, gzip, bzip2, xz, zlib, openssl, curl, iputils,
# iproute2, procps-ng.
#
# Here we install some additional tools which cannot be assumed to be included
# in a clean minimal installation, such as sudo, unzip, wget, nano.
#
# Previously the bootstrap archive did not include the "base" package, e.g.
# version 2021.02.01 included: pacman, pacman-mirrorlist, ca-certificates, bash,
# openssl, curl, gawk, bzip2, xz and zlib, but it did not include sudo, sed, grep,
# tar, gzip, unzip, wget, nano, iputils, iproute2, procps-ng. Also the "base" was
# previously a package group and not a meta package, and it included more packages.
# The base package group could then be installed to get tar, gzip, sed, shadow,
# systemd, grep, iputils (with ping command), procps-ng (with ps command) etc.
# (some overlap with preinstalled). To leave a slimmer installation this script
# did not install the base package, but only some of the individual packages found
# to be needed.
#
# NOTE: Remember to either do both --refresh (-y) and --sysupgrade (-u), or none of them,
# at least never --refresh (-y) which will easily lead to the partial upgrades syndrome!
# Here we do none, update and upgrade was performed as a separate step above, so now
# we can just install packages according to the current package database.
#
echo
echo "Installing basic packages..."
if ! pacman --sync --needed "$@" \
`# Packages included in meta package "base" which is preinstalled on newer bootstrap images (TODO: Remove)` \
sed \
grep \
tar \
gzip \
iputils \
iproute2 \
procps-ng \
`# Packages not preinstalled` \
sudo \
unzip \
wget \
nano
then
echo "Failed!"
exit 1
fi
#
# Cleanup package cache.
#
echo
echo "Cleanup package cache..."
if ! pacman --sync --clean "$@"; then
echo "Failed!"
exit 1
fi