* Back out r17946 and 17948 because it doesn't work. I've seen it
fail to update /etc twice now. It's also unnecessarily complex IMHO (see nix-dev). svn path=/nixos/trunk/; revision=18045
This commit is contained in:
parent
35c14bb11a
commit
11022e8d9f
|
@ -11,7 +11,6 @@ let
|
||||||
text = ''
|
text = ''
|
||||||
#### actionScripts snippet ${a} :
|
#### actionScripts snippet ${a} :
|
||||||
# ========================================
|
# ========================================
|
||||||
echo "executing activation snippet ${a} at $(${pkgs.coreutils}/bin/date)"
|
|
||||||
${v.text}
|
${v.text}
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
|
@ -124,14 +123,8 @@ let
|
||||||
# Set up Nix.
|
# Set up Nix.
|
||||||
mkdir -p /nix/etc/nix
|
mkdir -p /nix/etc/nix
|
||||||
ln -sfn /etc/nix.conf /nix/etc/nix/nix.conf
|
ln -sfn /etc/nix.conf /nix/etc/nix/nix.conf
|
||||||
stat /nix/store/ | \
|
chown root.nixbld /nix/store
|
||||||
egrep \
|
chmod 1775 /nix/store
|
||||||
'Access: [(]1775/[-drwxt]*[)] *Uid: [(][0-9 ]*/ *root[)] *Gid: [(][0-9 ]*/ *nixbld[)]' \
|
|
||||||
> /dev/null || {
|
|
||||||
|
|
||||||
chown root.nixbld /nix/store
|
|
||||||
chmod 1775 /nix/store
|
|
||||||
}
|
|
||||||
|
|
||||||
# Nix initialisation.
|
# Nix initialisation.
|
||||||
mkdir -m 0755 -p \
|
mkdir -m 0755 -p \
|
||||||
|
|
|
@ -42,9 +42,7 @@ let
|
||||||
# as you use, but with another kernel
|
# as you use, but with another kernel
|
||||||
# !!! fix this
|
# !!! fix this
|
||||||
children = map (x: ((import ../../../default.nix)
|
children = map (x: ((import ../../../default.nix)
|
||||||
{ configuration = x//{boot=((x.boot)//
|
{ configuration = x//{boot=((x.boot)//{grubDevice = "";});};}).system)
|
||||||
{loader=x.boot.loader//{grub=x.boot.loader.grub//
|
|
||||||
{device = "";};};});};}).system)
|
|
||||||
config.nesting.children;
|
config.nesting.children;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,6 @@ fi
|
||||||
# Ensure that the module tools can find the kernel modules.
|
# Ensure that the module tools can find the kernel modules.
|
||||||
export MODULE_DIR=@kernel@/lib/modules/
|
export MODULE_DIR=@kernel@/lib/modules/
|
||||||
|
|
||||||
echo "Running post-boot commands"
|
|
||||||
|
|
||||||
# Run any user-specified commands.
|
# Run any user-specified commands.
|
||||||
@shell@ @postBootCommands@
|
@shell@ @postBootCommands@
|
||||||
|
|
|
@ -41,8 +41,6 @@ let
|
||||||
|
|
||||||
builder = ./make-etc.sh;
|
builder = ./make-etc.sh;
|
||||||
|
|
||||||
inherit (pkgs) coreutils;
|
|
||||||
|
|
||||||
/* !!! Use toXML. */
|
/* !!! Use toXML. */
|
||||||
sources = map (x: x.source) config.environment.etc;
|
sources = map (x: x.source) config.environment.etc;
|
||||||
targets = map (x: x.target) config.environment.etc;
|
targets = map (x: x.target) config.environment.etc;
|
||||||
|
@ -63,15 +61,33 @@ in
|
||||||
etc = pkgs.lib.fullDepEntry ''
|
etc = pkgs.lib.fullDepEntry ''
|
||||||
# Set up the statically computed bits of /etc.
|
# Set up the statically computed bits of /etc.
|
||||||
echo "setting up /etc..."
|
echo "setting up /etc..."
|
||||||
if [ "$(readlink /etc/kill-etc)" != "${makeEtc}/bin/kill-etc" ]; then
|
staticEtc=/etc/static
|
||||||
/etc/kill-etc || true
|
rm -f $staticEtc
|
||||||
${makeEtc}/bin/fill-etc
|
ln -s ${makeEtc}/etc $staticEtc
|
||||||
echo -e "#! /bin/sh\n${makeEtc}/bin/kill-etc\n${makeEtc}/bin/fill-etc" > /etc/refill-etc
|
for i in $(cd $staticEtc && find * -type l); do
|
||||||
chmod 0755 /etc/refill-etc
|
mkdir -p /etc/$(dirname $i)
|
||||||
echo "/etc is set up"
|
rm -f /etc/$i
|
||||||
else
|
if test -e "$staticEtc/$i.mode"; then
|
||||||
echo "/etc unchanged"
|
# Create a regular file in /etc.
|
||||||
fi
|
cp $staticEtc/$i /etc/$i
|
||||||
|
chown 0.0 /etc/$i
|
||||||
|
chmod "$(cat "$staticEtc/$i.mode")" /etc/$i
|
||||||
|
else
|
||||||
|
# Create a symlink in /etc.
|
||||||
|
ln -s $staticEtc/$i /etc/$i
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Remove dangling symlinks that point to /etc/static. These are
|
||||||
|
# configuration files that existed in a previous configuration but not
|
||||||
|
# in the current one. For efficiency, don't look under /etc/nixos
|
||||||
|
# (where all the NixOS sources live).
|
||||||
|
for i in $(find /etc/ \( -path /etc/nixos -prune \) -o -type l); do
|
||||||
|
target=$(readlink "$i")
|
||||||
|
if test "''${target:0:''${#staticEtc}}" = "$staticEtc" -a ! -e "$i"; then
|
||||||
|
rm -f "$i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
'' [
|
'' [
|
||||||
"systemConfig"
|
"systemConfig"
|
||||||
"defaultPath" # path to cp, chmod, chown
|
"defaultPath" # path to cp, chmod, chown
|
||||||
|
|
|
@ -5,61 +5,6 @@ ensureDir $out/etc
|
||||||
sources_=($sources)
|
sources_=($sources)
|
||||||
targets_=($targets)
|
targets_=($targets)
|
||||||
modes_=($modes)
|
modes_=($modes)
|
||||||
|
|
||||||
cat <<EOF >> fill-etc.c
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
|
|
||||||
struct stat statBuffer;
|
|
||||||
|
|
||||||
void ensureDir(char* path) {
|
|
||||||
int i, j;
|
|
||||||
char pathBuffer[PATH_MAX];
|
|
||||||
statBuffer.st_mode = 0;
|
|
||||||
for (i=0; path[i]; i++) {
|
|
||||||
if (path[i]=='/') {
|
|
||||||
pathBuffer[i]=0;
|
|
||||||
mkdir(pathBuffer ,0755);
|
|
||||||
j = i;
|
|
||||||
}
|
|
||||||
pathBuffer[i]=path[i];
|
|
||||||
}
|
|
||||||
pathBuffer[j]=0;
|
|
||||||
if (stat(pathBuffer, &statBuffer) || ! (statBuffer.st_mode & S_IFDIR)) {
|
|
||||||
printf ("Path does not exist or not a directory: %s\n", path);
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void copyAndChmod(char* path, char* target, mode_t mode) {
|
|
||||||
int pid;
|
|
||||||
pid = fork();
|
|
||||||
if (! pid) {
|
|
||||||
execl("${coreutils}/bin/cp", "cp", path, target, NULL);
|
|
||||||
} else {
|
|
||||||
waitpid (pid, NULL, 0);
|
|
||||||
}
|
|
||||||
chmod (target, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main () {
|
|
||||||
/* generated code begins */
|
|
||||||
EOF
|
|
||||||
cat <<EOF >> kill-etc.c
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
int main () {
|
|
||||||
/* generated code begins */
|
|
||||||
EOF
|
|
||||||
|
|
||||||
for ((i = 0; i < ${#targets_[@]}; i++)); do
|
for ((i = 0; i < ${#targets_[@]}; i++)); do
|
||||||
ensureDir $out/etc/$(dirname ${targets_[$i]})
|
ensureDir $out/etc/$(dirname ${targets_[$i]})
|
||||||
if ! test -e $out/etc/${targets_[$i]}; then
|
if ! test -e $out/etc/${targets_[$i]}; then
|
||||||
|
@ -68,29 +13,10 @@ for ((i = 0; i < ${#targets_[@]}; i++)); do
|
||||||
echo "Duplicate entry ${targets_[$i]} -> ${sources_[$i]}"
|
echo "Duplicate entry ${targets_[$i]} -> ${sources_[$i]}"
|
||||||
if test "$(readlink $out/etc/${targets_[$i]})" != "${sources_[$i]}"; then
|
if test "$(readlink $out/etc/${targets_[$i]})" != "${sources_[$i]}"; then
|
||||||
echo "Mismatched duplicate entry $(readlink $out/etc/${targets_[$i]}) <-> ${sources_[$i]}"
|
echo "Mismatched duplicate entry $(readlink $out/etc/${targets_[$i]}) <-> ${sources_[$i]}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi;
|
fi;
|
||||||
echo "ensureDir(\"/etc/${targets_[$i]}\");" >> fill-etc.c
|
|
||||||
if test "${modes_[$i]}" != symlink; then
|
if test "${modes_[$i]}" != symlink; then
|
||||||
echo "${modes_[$i]}" > $out/etc/${targets_[$i]}.mode
|
echo "${modes_[$i]}" > $out/etc/${targets_[$i]}.mode
|
||||||
|
|
||||||
echo "copyAndChmod(\"$out/etc/${targets_[$i]}\",\"/etc/${targets_[$i]}\",${modes_[$i]});" >> fill-etc.c;
|
|
||||||
else
|
|
||||||
echo "symlink(\"$out/etc/${targets_[$i]}\",\"/etc/${targets_[$i]}\");" >> fill-etc.c;
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "unlink (\"/etc/${targets_[$i]}\");" >> kill-etc.c
|
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "symlink(\"$out/bin/kill-etc\",\"/etc/kill-etc\");" >> fill-etc.c
|
|
||||||
echo "unlink(\"/etc/kill-etc\");" >> kill-etc.c
|
|
||||||
echo " return 0; }" >> fill-etc.c
|
|
||||||
echo " return 0; }" >> kill-etc.c
|
|
||||||
ensureDir $out/bin
|
|
||||||
ensureDir $out/share/etc-scripts/src
|
|
||||||
gcc -Wall fill-etc.c -o $out/bin/fill-etc
|
|
||||||
gcc -Wall kill-etc.c -o $out/bin/kill-etc
|
|
||||||
cp fill-etc.c $out/share/etc-scripts/src
|
|
||||||
cp kill-etc.c $out/share/etc-scripts/src
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue