From 2187ddb66ba19a65c993c7df5f1eb4c8bf274c4c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 10 Aug 2016 18:36:01 +0100 Subject: [PATCH] init: Set the hostname to 'stage3.fedoraproject.org'. Also, add 'hostname' program to the stage3 chroot. --- .gitignore | 1 + Makefile | 19 +++++++++++++++ hostname-rh.patch | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ init.sh | 3 +++ 4 files changed, 92 insertions(+) create mode 100644 hostname-rh.patch diff --git a/.gitignore b/.gitignore index a8fab17..48aae81 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ stamp-* /gmp-6.1.1/ /grep-2.25/ /gzip-1.8/ +/hostname/ /less-481/ /make-4.1/ /mpc-1.0.3/ diff --git a/Makefile b/Makefile index b137fd1..fd5968a 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,7 @@ DIFFUTILS_VERSION = 3.4 FINDUTILS_VERSION = 4.6.0 SED_VERSION = 4.2 PATCH_VERSION = 2.7.5 +HOSTNAME_VERSION = 3.15 all: stage1 stage2 stage3 stage4 @@ -297,6 +298,7 @@ stage3: stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux \ stage3-chroot/usr/bin/find \ stage3-chroot/usr/bin/sed \ stage3-chroot/usr/bin/patch \ + stage3-chroot/usr/bin/hostname \ stage3-chroot/usr/bin/rpm \ stage3-chroot/init \ stage3-disk.img @@ -832,6 +834,23 @@ patch-$(PATCH_VERSION).tar.gz: wget -O $@-t https://ftp.gnu.org/gnu/patch/patch-$(PATCH_VERSION).tar.gz mv $@-t $@ +# Cross-compile hostname. +stage3-chroot/usr/bin/hostname: hostname-$(HOSTNAME_VERSION).tar.gz + rm -rf hostname-$(HOSTNAME_VERSION) + tar -zxf $^ + cd hostname && patch -p1 < ../hostname-rh.patch + cd hostname && \ + PATH=$(ROOT)/fixed-gcc:$$PATH \ + make \ + CC=riscv64-unknown-linux-gnu-gcc \ + CFLAGS="-O2 -g" + cd hostname && make install BASEDIR=$(ROOT)/stage3-chroot + +hostname-$(HOSTNAME_VERSION).tar.gz: + rm -f $@ $@-t + wget -O $@-t http://ftp.de.debian.org/debian/pool/main/h/hostname/hostname_$(HOSTNAME_VERSION).tar.gz + mv $@-t $@ + # Cross-compile RPM / rpmbuild. # We build this from a git commit, with a few hacks to the configure # script. diff --git a/hostname-rh.patch b/hostname-rh.patch new file mode 100644 index 0000000..d56ae59 --- /dev/null +++ b/hostname-rh.patch @@ -0,0 +1,69 @@ +diff -up hostname/Makefile.rh hostname/Makefile +--- hostname/Makefile.rh 2013-11-04 10:12:59.670379153 +0100 ++++ hostname/Makefile 2013-11-04 10:15:04.957314495 +0100 +@@ -10,21 +10,17 @@ OBJS=hostname.o + + hostname: $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) -lnsl +- ln -fs hostname dnsdomainname +- ln -fs hostname domainname +- ln -fs hostname ypdomainname +- ln -fs hostname nisdomainname + + install: hostname + install -d ${BASEDIR}$(MANDIR)/man1 +- install -o root -g root -m 0644 hostname.1 ${BASEDIR}$(MANDIR)/man1 ++ install -m 0644 hostname.1 ${BASEDIR}$(MANDIR)/man1 + ln -fs hostname.1 ${BASEDIR}$(MANDIR)/man1/dnsdomainname.1 + ln -fs hostname.1 ${BASEDIR}$(MANDIR)/man1/domainname.1 + ln -fs hostname.1 ${BASEDIR}$(MANDIR)/man1/ypdomainname.1 + ln -fs hostname.1 ${BASEDIR}$(MANDIR)/man1/nisdomainname.1 + + install -d ${BASEDIR}$(BINDIR) +- install -o root -g root -m 0755 hostname ${BASEDIR}$(BINDIR) ++ install -m 0755 hostname ${BASEDIR}$(BINDIR) + ln -fs hostname ${BASEDIR}$(BINDIR)/dnsdomainname + ln -fs hostname ${BASEDIR}$(BINDIR)/domainname + ln -fs hostname ${BASEDIR}$(BINDIR)/nisdomainname +diff -up hostname/hostname.1.rh hostname/hostname.1 +--- hostname/hostname.1.rh 2013-11-03 15:24:23.000000000 +0100 ++++ hostname/hostname.1 2013-11-04 10:12:59.670379153 +0100 +@@ -80,6 +80,28 @@ complete FQDN of the system is returned + .B "THE FQDN" + below). + ++.LP ++The function ++.BR gethostname(2) ++is used to get the hostname. When the ++.BR "hostname \-a, \-d, \-f or \-i" ++is called will ++.BR gethostbyname(3) ++be called. The difference in ++.BR gethostname(2) ++and ++.BR gethostbyname(3) ++is that ++.BR gethostbyname(3) ++is network aware, so it consults ++.IR /etc/nsswitch.conf ++and ++.IR /etc/host.conf ++to decide whether to read information in ++.IR /etc/hostname ++or ++.IR /etc/hosts ++ + .SS "SET NAME" + When called with one argument or with the + .B \-\-file +@@ -105,8 +127,7 @@ command (see + .B "THE FQDN" + below). + .LP +-The host name is usually set once at system startup in +-.I /etc/init.d/hostname.sh ++The host name is usually set once at system startup + (normally by reading the contents of a file which contains + the host name, e.g. + .IR /etc/hostname ). diff --git a/init.sh b/init.sh index e76c1e8..4a105fc 100755 --- a/init.sh +++ b/init.sh @@ -18,6 +18,9 @@ ldconfig /usr/lib64 /usr/lib /lib64 /lib # There is no hardware clock, just ensure the date is not miles out. date `date -r /usr/bin +%m%d%H%M%Y` +hostname stage3 +echo stage3.fedoraproject.org > /etc/hostname + echo echo "Welcome to the Fedora/RISC-V stage3 disk image" echo "https://fedoraproject.org/wiki/Architectures/RISC-V" -- 1.8.3.1