pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Windows 10/11 MSYS2 UCRT64 bootstrap



I haven't had pkgsrc on Windows, since Interix on XP. Interix is still
available for Windows < 10, MSYS2 is not. None of the OS distros I use
can agree on a packaging system, so I have pkgsrc on all of them...
except Windows! My 8-core 1.4Ghz 128GB Sun T5120 dual-boots either
Tribblix or NetBSD (zfsroot either way on a pair of drives), and pkgsrc
still works on my SGI Indy that's going on 30, not that I've built
anything on it lately, and I've been pkgsrc-on-solaris for 20 years.

I'm working with a fresh installation of Windows 10 Pro Workstation
bootcamp'd on a 10-core 3ghz 128GB (64GB video) iMac Pro. I don't have a
C:\Users directory, it's C:\export\home, C:\home symlinks to it. I have
MSYS2 installed on C:\ and I've renamed "administrator" "root" for
compatibility (home = C:\root), but on Windows you can have user=foo
group=bar be the "500" account; all that matters is, "is the logged-in
user actually root." I'm working on a proper is_root() for NT*.

MINGW64_NT1*)
	root_sid="$(reg query HKU |awk -F'\' '{print $2}' |tr -s
	[:space:] ',' |rev |sed 's/.*,005-//' |awk -F',' '{print $1}'
	|sed 's/./005-/' |rev)"

# C:\>reg query
# "HKU\S-1-5-21-##########-#########-##########-500\Volatile
# Environment" /v USERNAME |tr -s [:space:] ',' |cut -d , -f 6
# root

	root_user=`whoami`
	is_root() { 
		if [ ${root_user}==root ]; then
			return 0
		fi
		return 1
	}
	unprivileged=no
	root_group=None
	opsys=`uname -o`
	machine_arch=`uname -m`
	# only used for unprivileged builds.
	groupsprog='id -ng'
	;;

Cygwin and Interix use id -nG | grep -q 'Administrators' for isroot(),
but this is bad practice. Windows has wcim.exe for this, unfortunately
that only works from cmd.exe, not powershell, let alone bash or sh. So
reg query it is, but on non-MS shells it won't introspect so we can't
just get a SID or username. Cross-shell compatibility is a surprising
challenge given that they're all using the same .exe commands; e.g.
bash gives a warning on "reg query HKU |tr \\/ |cut -d / -f2" while
powershell fails with:

/usr/bin/tr: missing operand after '\\\\/'
Two strings must be given when translating.

That code isn't portable between MS shells with env=env, lol. Would be
a useful tool for the kit, just change all backslashes to frontslashes.
MS cli's give horrific multi-line output with plenty of hidden chars
and whitespace padding, clearly written by folks who don't use cli's.
Although, wcim.exe --csv is possible. In this toolchain, ls -l always
returns group=None for everything. Here's my everyday MS PATH:

C:\Windows\System32;C:\Windows\System32\Wbem;C:\Windows\System32\
WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program
Files\PuTTY;C:\export\home\me\.local\bin;C:\export\home\me\AppData\
Local\Microsoft\WindowsApps;C:\opt\bin;C:\usr\bin;C:\usr\local\bin

C:\> wmic useraccount where name="%USERNAME%" get sid |awk '{print
$NF}' FS=- |tr -dc '0-9'
500

For this build, I've set the UCRT64 shell.ini to path_type=strict, and
added the directory for "reg.exe":

/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:
/Windows/System32

There are no other bins on this system, yet. I have figured out how to
install the MINGW64 toolchain under /usr/local, which I need to build
fpc, and ghc/cabal so I can build Lazarus and DARCS and xmonad; I tell
ghcup that msys2 is /usr/local, and to put /ghcup and /cabal under /usr
to make it all work... but I digress. Make sure you set
winsymlinks:nativestrict before you do:

# pacman -S base-devel gcc
# cd /usr/pkgsrc/pkgtools/bootstrap-mk-files/files/mods
# cp Cygwin.sys.mk Msys.sys.mk
# cp Cygwin.bsd.lib.mk Msys.bsd.lib.mk
# cd ../../../../bootstrap
# ./testbootstrap --prefer-pkgsrc --abi 64
===> bootstrap command: ./bootstrap --prefix=/usr/pkgsrc/bootstrap/pkg
--sysconfdir=/usr/pkgsrc/bootstrap/pkg/etc
--pkgdbdir=/usr/pkgsrc/bootstrap/.db --ignore-user-check
===> bootstrap started: Fri Mar 22 23:42:23 MDT 2024
Working directory is: /usr/pkgsrc/bootstrap/work
===> running:/usr/bin/sed -e 's|@DEFAULT_INSTALL_MODE@|'0755'|'
/usr/pkgsrc/sysutils/install-sh/files/install-sh.in >
/usr/pkgsrc/bootstrap/work/bin/install-sh 
===> running: /usr/bin/chmod +x
/usr/pkgsrc/bootstrap/work/bin/install-sh
===> Creating default mk.conf in /usr/pkgsrc/bootstrap/work
===> running: /usr/bin/sh/usr/pkgsrc/bootstrap/work/bin/install-sh 
-d -o root -g None /usr/pkgsrc/bootstrap/work/sbin
===> running: /usr/bin/sh /usr/pkgsrc/bootstrap/work/bin/install-sh 
-d -o root -g None /usr/pkgsrc/bootstrap/work/share/mk
===> Bootstrapping mk-files
===> running: (cd /usr/pkgsrc/pkgtools/bootstrap-mk-files/files && env
CP=/usr/bin/cp OPSYS=Msys MK_DST=/usr/pkgsrc/bootstrap/work/share/mk
ROOT_GROUP=None ROOT_USER=root SED=/usr/bin/sed
SYSCONFDIR=/usr/pkgsrc/bootstrap/pkg/etc /usr/bin/sh ./bootstrap.sh)
===> Bootstrapping bmake
===> running: /usr/bin/sh /usr/pkgsrc/bootstrap/work/bin/install-sh -d
-o root -g 197121 /usr/pkgsrc/bootstrap/work/bmake
===> running: (cd /usr/pkgsrc/bootstrap/work/bmake && /usr/bin/sh
configure --prefix=/usr/pkgsrc/bootstrap/work
--with-default-sys-path=/usr/pkgsrc/bootstrap/work/share/mk
--with-machine-arch=x86_64 )
configure: loading site script /etc/config.site
checking for gcc... gcc
...
===> Bootstrapping pkgtools
===> running: /usr/bin/sh /usr/pkgsrc/bootstrap/work/bin/install-sh -d
-o username -g 197121 /usr/pkgsrc/bootstrap/work/libarchive
===> running: (cd /usr/pkgsrc/bootstrap/work/libarchive; env
CONFIG_SHELL=/usr/bin/sh /usr/bin/sh ./configure  --enable-static
--disable-shared --disable-bsdcat --disable-bsdtar --disable-bsdcpio
--disable-bsdunzip --disable-posix-regex-lib --disable-xattr
--disable-maintainer-mode --disable-acl --without-zlib --without-bz2lib
--without-iconv --without-lzma --without-lzo2 --without-lz4
--without-nettle --without-openssl --without-xml2 --without-expat
--without-zstd
MAKE=/usr/pkgsrc/bootstrap/work/bin/bmake &&
/usr/pkgsrc/bootstrap/work/bin/bmake  -j1)
configure: loading site script /etc/config.site 
checking for a BSD-compatible install...
/usr/bin/install -c checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether /usr/pkgsrc/bootstrap/work/bin/bmake sets $(MAKE)...
yes
checking whether /usr/pkgsrc/bootstrap/work/bin/bmake supports
nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles...
no
checking whether /usr/pkgsrc/bootstrap/work/bin/bmake supports nested
variables... (cached) yes
checking build system type... x86_64-w64-mingw32
checking host system type... x86_64-w64-mingw32
./configure: line 4094: -D__MINGW_USE_VC2005_COMPAT: command not found
checking for gcc... gcc
...
bmake: stopped in /usr/pkgsrc/bootstrap/work/libarchive
===> exited with status 2
aborted.

I'm stuck where to set CPPFLAGS="-D__USE_MINGW_ANSI_STDIO=1" but I
think that might do the trick.

-Eric



Home | Main Index | Thread Index | Old Index