diff options
author | Andrew Cady <d@jerkface.net> | 2020-10-12 13:08:14 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2020-10-12 13:08:14 -0400 |
commit | 757e35df1bc571cbe414b62cce1d6d3b0eca93b5 (patch) | |
tree | 448935636abdbf2ea582869c98d74f726fe282b4 | |
parent | 996c430fd798598e1ba4d492741fc2fadf1a3a1e (diff) |
hacks and fixes, features and fixtures, axes and fackses
-rw-r--r-- | fsmgr.hs | 17 | ||||
-rwxr-xr-x | selfstrap | 35 |
2 files changed, 37 insertions, 15 deletions
@@ -38,7 +38,7 @@ noParent (ParentImageConfigFile _) = False | |||
38 | noParent (SeededImage _ _) = False | 38 | noParent (SeededImage _ _) = False |
39 | 39 | ||
40 | dynamicNames :: FilePath -> FilePath | 40 | dynamicNames :: FilePath -> FilePath |
41 | dynamicNames = replace "$(karch)" uname . replace "$(debarch)" debarch | 41 | dynamicNames = replace "$(kver)" (snd uname) . replace "$(karch)" (fst uname) . replace "$(debarch)" debarch |
42 | 42 | ||
43 | chomp :: String -> String | 43 | chomp :: String -> String |
44 | chomp = takeWhile (/= '\n') | 44 | chomp = takeWhile (/= '\n') |
@@ -53,10 +53,10 @@ getDebianCodename = unsafePerformIO $ do | |||
53 | (Stdout codename) <- cmd "sh -c" [". /etc/os-release && printf '%s' \"$VERSION_CODENAME\""] | 53 | (Stdout codename) <- cmd "sh -c" [". /etc/os-release && printf '%s' \"$VERSION_CODENAME\""] |
54 | return codename | 54 | return codename |
55 | 55 | ||
56 | uname :: String | 56 | uname :: (String, String) |
57 | uname = unsafePerformIO $ do | 57 | uname = unsafePerformIO $ do |
58 | Stdout out <- cmd "uname -r" | 58 | Stdout out <- cmd "uname -r" |
59 | return $ last . wordsBy '-' . head . lines $ out | 59 | pure $ (reverse *** reverse . tail) . break (== '-') . reverse . head . lines $ out |
60 | 60 | ||
61 | data AptListCfg = | 61 | data AptListCfg = |
62 | AptListCfg | 62 | AptListCfg |
@@ -225,8 +225,13 @@ buildInitialImage :: DiskImageConfig -> FilePath -> FilePath -> Action () | |||
225 | buildInitialImage DiskImageConfig{..} mountpoint out = do | 225 | buildInitialImage DiskImageConfig{..} mountpoint out = do |
226 | case initialImage of | 226 | case initialImage of |
227 | ParentImageConfigFile f -> do | 227 | ParentImageConfigFile f -> do |
228 | let parent = "_build" </> f -<.> "btrfs" | 228 | let cwdParent = f -<.> "btrfs" |
229 | need [parent] | 229 | buildDirParent = "_build" </> cwdParent |
230 | parent <- liftIO (IO.doesFileExist cwdParent) >>= \case | ||
231 | True -> return cwdParent | ||
232 | False -> do | ||
233 | need [buildDirParent] | ||
234 | return buildDirParent | ||
230 | cmd_ "cp --reflink" [parent, out] | 235 | cmd_ "cp --reflink" [parent, out] |
231 | cmd_ "btrfstune -f -S0" [out] | 236 | cmd_ "btrfstune -f -S0" [out] |
232 | cmd_ "btrfstune -fu" [out] | 237 | cmd_ "btrfstune -fu" [out] |
@@ -437,7 +442,7 @@ cgroupChroot groupName mnt args = do | |||
437 | -- TODO: unshare hostname & set from /etc/hostname inside root | 442 | -- TODO: unshare hostname & set from /etc/hostname inside root |
438 | cmd_ (Cwd mnt) (WithStderr False) | 443 | cmd_ (Cwd mnt) (WithStderr False) |
439 | "unshare --ipc --uts --cgroup --mount --pid --fork chroot ." | 444 | "unshare --ipc --uts --cgroup --mount --pid --fork chroot ." |
440 | "sh -exc" ["mount -t proc proc /proc; mount -t devpts devpts /dev/pts; hostname -F /etc/hostname; exec \"$@\""] | 445 | "sh -exc" ["mount -t proc proc /proc; mount -t devpts devpts /dev/pts; if [ -e /etc/hostname ]; then hostname -F /etc/hostname; fi; exec \"$@\""] |
441 | "sh" args | 446 | "sh" args |
442 | 447 | ||
443 | earlyFail :: IO () | 448 | earlyFail :: IO () |
@@ -2,6 +2,7 @@ | |||
2 | debian_mirror=http://httpredir.debian.org/debian | 2 | debian_mirror=http://httpredir.debian.org/debian |
3 | debian_security_mirror=http://security.debian.org | 3 | debian_security_mirror=http://security.debian.org |
4 | EXTRA_PACKAGES='apt debian-archive-keyring locales' | 4 | EXTRA_PACKAGES='apt debian-archive-keyring locales' |
5 | REAL_DPKG=y | ||
5 | 6 | ||
6 | die() { printf 'Error: %s\n' "$*"; exit 1; } | 7 | die() { printf 'Error: %s\n' "$*"; exit 1; } |
7 | 8 | ||
@@ -35,7 +36,8 @@ while [ $# -gt 0 ]; do | |||
35 | EXTRA_PACKAGES="$EXTRA_PACKAGES $x" | 36 | EXTRA_PACKAGES="$EXTRA_PACKAGES $x" |
36 | shift ;; | 37 | shift ;; |
37 | --chroot) CHROOT_PROG=$2; shift ;; | 38 | --chroot) CHROOT_PROG=$2; shift ;; |
38 | --real-apt) REAL_APT_INSTALL=y ;; | 39 | --real-apt) REAL_APT_INSTALL=y |
40 | REAL_DPKG=y;; | ||
39 | --) shift; break ;; | 41 | --) shift; break ;; |
40 | *) usage 1 ;; | 42 | *) usage 1 ;; |
41 | esac | 43 | esac |
@@ -195,12 +197,22 @@ populate_rootfs() | |||
195 | write_sources_list() | 197 | write_sources_list() |
196 | { | 198 | { |
197 | local dest="$TARGET"/etc/apt/sources.list | 199 | local dest="$TARGET"/etc/apt/sources.list |
198 | [ -e "$dest" ] && return | 200 | [ ! "$REWRITE_SOURCES_LIST" -a -e "$dest" ] && return |
199 | printf '%s\n' \ | 201 | printf 'APT::Default-Release "%s";\n' "$target_release" > "$TARGET"/etc/apt/apt.conf.d/default-release |
200 | "deb ${debian_mirror} ${target_release} main contrib non-free" \ | 202 | ( |
201 | "deb ${debian_mirror} ${target_release}-backports main contrib non-free" \ | 203 | printf '%s\n' \ |
202 | "deb ${debian_security_mirror} ${target_release}/updates main contrib non-free" | | 204 | "deb ${debian_mirror} ${target_release} main contrib non-free" \ |
203 | column -t > "$dest" | 205 | "deb ${debian_mirror} ${target_release}-backports main contrib non-free" \ |
206 | "deb ${debian_security_mirror} ${target_release}/updates main contrib non-free" | ||
207 | if [ "$target_release" = stretch ] | ||
208 | then | ||
209 | printf '%s\n' \ | ||
210 | "deb ${debian_mirror} buster main contrib non-free" \ | ||
211 | "deb ${debian_mirror} buster-backports main contrib non-free" \ | ||
212 | "deb ${debian_security_mirror} buster/updates main contrib non-free" | ||
213 | |||
214 | fi | ||
215 | ) | column -t > "$dest" | ||
204 | } | 216 | } |
205 | 217 | ||
206 | parse_apt_simul_line() | 218 | parse_apt_simul_line() |
@@ -337,6 +349,7 @@ apt_extract() | |||
337 | 349 | ||
338 | dpkg_unpack_from_apt_actions() | 350 | dpkg_unpack_from_apt_actions() |
339 | { | 351 | { |
352 | set -- | ||
340 | while read line; do | 353 | while read line; do |
341 | 354 | ||
342 | parse_apt_simul_line "$line" || die "parse_apt_simul_line: unexpected output from apt-get: $line" | 355 | parse_apt_simul_line "$line" || die "parse_apt_simul_line: unexpected output from apt-get: $line" |
@@ -350,8 +363,8 @@ dpkg_unpack_from_apt_actions() | |||
350 | case "$action" in | 363 | case "$action" in |
351 | Inst) | 364 | Inst) |
352 | printf 'Unpacking %s\n' "${deb##*/}" >&2 | 365 | printf 'Unpacking %s\n' "${deb##*/}" >&2 |
353 | if [ "$REAL_APT_INSTALL" ]; then | 366 | if [ "$REAL_DPKG" ]; then |
354 | dpkg --extract "$deb" "$TARGET" || die 'dpkg' | 367 | set -- "$@" "$deb" |
355 | else | 368 | else |
356 | is_multiarch_same "$package" && multiarch=":$arch" || multiarch= | 369 | is_multiarch_same "$package" && multiarch=":$arch" || multiarch= |
357 | [ "$UNPACK_ONLY" ] && set_status=unpacked || set_status=installed | 370 | [ "$UNPACK_ONLY" ] && set_status=unpacked || set_status=installed |
@@ -363,6 +376,10 @@ dpkg_unpack_from_apt_actions() | |||
363 | *) die "dpkg_unpack_from_apt_actions: unknown apt simul action: $action" ;; | 376 | *) die "dpkg_unpack_from_apt_actions: unknown apt simul action: $action" ;; |
364 | esac | 377 | esac |
365 | done | 378 | done |
379 | if [ $# -gt 0 ]; then | ||
380 | dpkg --no-triggers --unpack --force-unsafe-io --root="$TARGET" "$deb" || die 'dpkg' | ||
381 | # dpkg --configure --pending --root="$TARGET" | ||
382 | fi | ||
366 | } | 383 | } |
367 | 384 | ||
368 | install_etc_passwd() | 385 | install_etc_passwd() |