Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,25 @@ jobs:
run: |
tar xzf try-dist.tgz/try-*.tgz --strip-components=1
rm -r try-dist.tgz
./configure
./configure --disable-utils
make all
sudo make install

- name: Run tests with shell fallbacks
run: |
! which try-summary
! which try-commit
scripts/run_tests.sh

- name: Clean up build
run: |
sudo make clean

- name: Install utilities
run: |
autoconf
./configure
make all
sudo make install

- name: Run tests with utilities
Expand Down Expand Up @@ -116,17 +124,25 @@ jobs:
- name: Configure and build utilities
run: |
autoconf
./configure
./configure --disable-utils
make all
sudo make install

- name: Run tests with shell fallbacks
run: |
! which try-summary
! which try-commit
scripts/run_tests.sh

- name: Clean up build
run: |
sudo make clean

- name: Install utilities
run: |
autoconf
./configure
make all
sudo make install

- name: Run tests with utilities
Expand Down
8 changes: 6 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ INSTALL=@INSTALL@
DISTDIR=@PACKAGE_TARNAME@-@PACKAGE_VERSION@
DISTTGZ=$(DISTDIR).tgz

TARGETS=$(if $(findstring yes,@enable_utils@),utils/try-summary utils/try-commit) man/try.1.gz
TARGETS=utils/make-socket $(if $(findstring yes,@enable_utils@),utils/try-summary utils/try-commit) man/try.1.gz

all: $(TARGETS)

install: $(TARGETS)
$(INSTALL) -d $(bindir)
$(INSTALL) -m 755 try $(bindir)
$(INSTALL) -m 755 utils/make-socket $(bindir)
ifeq (@enable_utils@, yes)
$(INSTALL) -m 755 utils/try-summary $(bindir)
$(INSTALL) -m 755 utils/try-commit $(bindir)
Expand Down Expand Up @@ -58,7 +59,10 @@ utils/try-summary: utils/ignores.o utils/try-summary.o
utils/try-commit: utils/ignores.o utils/try-commit.o
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -g $^

test: try $(if $(findstring yes,@enable_utils@),utils/try-summary utils/try-commit)
utils/make-socket: utils/make-socket.o
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -g $^

test: try $(if $(findstring yes,@enable_utils@),utils/try-summary utils/try-commit) utils/make-socket
scripts/run_tests.sh

lint:
Expand Down
25 changes: 25 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ Vagrant.configure("2") do |config|
sudo apt-get update
sudo apt-get install -y git expect curl attr pandoc gcc make autoconf mergerfs
sudo chown -R vagrant:vagrant try
sudo modprobe overlay
cd try
autoconf && ./configure --disable-utils && make
sudo make install
scripts/run_tests.sh

sudo make clean

autoconf && ./configure && make
sudo make install
which try-commit || exit 2
Expand Down Expand Up @@ -78,10 +83,15 @@ Vagrant.configure("2") do |config|
# This is intentional, if we moved try to lv1 it'd work since itself does not contain a nested mount
sudo mv /home/vagrant/try /mnt/lv0
sudo chown -R vagrant:vagrant /mnt/lv0/try
sudo modprobe overlay

cd /mnt/lv0/try
autoconf && ./configure --disable-utils && make
sudo make install
scripts/run_tests.sh

sudo make clean

autoconf && ./configure && make
sudo make install
which try-commit || exit 2
Expand All @@ -97,6 +107,7 @@ Vagrant.configure("2") do |config|
sudo apt-get update
sudo apt-get install -y curl attr pandoc gcc make autoconf mergerfs zsh
sudo chown -R vagrant:vagrant try
sudo modprobe overlay
cd try


Expand Down Expand Up @@ -149,8 +160,15 @@ Vagrant.configure("2") do |config|
wget https://github.com/trapexit/mergerfs/releases/download/2.40.2/mergerfs-2.40.2-1.el9.x86_64.rpm
sudo rpm -i mergerfs-2.40.2-1.el9.x86_64.rpm
sudo chown -R vagrant:vagrant try
sudo modprobe overlay
cd try

autoconf && ./configure --disable-utils && make
sudo make install
TRY_TOP=$(pwd) scripts/run_tests.sh

sudo make clean

autoconf && ./configure && make
sudo make install
which try-commit || exit 2
Expand All @@ -167,8 +185,15 @@ Vagrant.configure("2") do |config|
wget https://github.com/trapexit/mergerfs/releases/download/2.40.2/mergerfs-2.40.2-1.fc39.x86_64.rpm
sudo rpm -i mergerfs-2.40.2-1.fc39.x86_64.rpm
sudo chown -R vagrant:vagrant try
sudo modprobe overlay
cd try

autoconf && ./configure --disable-utils && make
sudo make install
TRY_TOP=$(pwd) scripts/run_tests.sh

sudo make clean

autoconf && ./configure && make
sudo make install
which try-commit || exit 2
Expand Down
22 changes: 11 additions & 11 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ AC_ARG_ENABLE([utils],
[don't compile C utilities for summarizing and committing changes (default is yes)])],
[enable_utils=${enableval}], [enable_utils=yes])


AC_REQUIRE_AUX_FILE([utils/make-socket.c])

# build tools
AC_PROG_CC

# CFLAGS AND CPPFLAGGS
AUTO_CFLAGS=""
AUTO_CPPFLAGS=""

if test "$enable_utils" = "yes"
then
AC_REQUIRE_AUX_FILE([utils/try-commit.c])

# build tools
AC_PROG_CC

# CFLAGS and CPPFLAGGS
if test -z "$CFLAGS"
then
AUTO_CFLAGS="-g -Wall -O2"
else
AUTO_CFLAGS=""
fi
AUTO_CPPFLAGS=""
AUTO_CPPFLAGS=""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go now, since we've set it unconditionally above.


CFLAGS=${CFLAGS-"$AUTO_CFLAGS"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines need to be moved up, so that we're actually setting CFLAGS and CPPFLAGS!

CPPFLAGS=${CPPFLAGS-"$AUTO_CPPFLAGS"}
Expand Down
1 change: 1 addition & 0 deletions package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ stdenv.mkDerivation {
install -Dt $out/bin try
install -Dt $out/bin utils/try-commit
install -Dt $out/bin utils/try-summary
install -Dt $out/bin utils/make-socket
wrapProgram $out/bin/try --prefix PATH : ${
lib.makeBinPath [
coreutils
Expand Down
2 changes: 1 addition & 1 deletion scripts/check_trycase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ check_file() {
lf="${lf%)}"

case "$cf" in
(file|dir|symlink|nonexist|opaque|whiteout);;
(file|dir|symlink|nonexist|opaque|whiteout|fifo|socket);;
(*) printf "ERROR: $1: invalid changed file: %s\n" "$cf"
: $((ERRORS += 1))
;;
Expand Down
87 changes: 87 additions & 0 deletions test/all-commit-cases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,90 @@ echo arrivederci >formerdir/it/file2 || fail
[ -L formerdir ] || fail
[ "$(readlink formerdir)" = "/this/is/a/broken/symlink" ] || fail
rm formerdir || fail

# // TRYCASE(fifo, file)

: $((COUNT += 1))

! [ -e newpipe ] || fail
"$TRY" -y "touch newpipe; echo new >newpipe"
[ -f newpipe ] || fail
[ "$(cat newpipe)" = "new" ] || fail
"$TRY" -y "rm newpipe; mkfifo newpipe"
[ -p newpipe ] || fail
rm newpipe

# // TRYCASE(fifo, dir)

: $((COUNT += 1))

! [ -e newpipe ] || fail
"$TRY" -y "mkdir newpipe"
[ -d newpipe ] || fail
"$TRY" -y "rm -r newpipe; mkfifo newpipe"
[ -p newpipe ] || fail
rm newpipe

# // TRYCASE(fifo, symlink)

: $((COUNT += 1))

! [ -e newpipe ] || fail
ln -s "$TRY" newpipe
[ -L newpipe ] || fail
"$TRY" -y "rm newpipe; mkfifo newpipe"
[ -p newpipe ] || fail
rm newpipe

# // TRYCASE(fifo, nonexist)

: $((COUNT += 1))

! [ -e newpipe ] || fail
"$TRY" -y "mkfifo newpipe"
[ -p newpipe ] || fail
rm newpipe

# // TRYCASE(socket, file)

: $((COUNT += 1))

! [ -e newsock ] || fail
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not test the declared case.

"$TRY" -y "touch newsock; echo hello> newsock"
[ -f newsock ] || fail
[ "$(cat newsock)" = "hello" ] || fail
"$TRY" -y "rm newsock; make-socket newsock"
[ -S newsock ] || fail
rm newsock

# // TRYCASE(socket, dir)

: $((COUNT += 1))

! [ -e newsock ] || fail
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not test the declared case.

"$TRY" -y "mkdir newsock"
[ -d newsock ] || fail
"$TRY" -y "rm -r newsock; make-socket newsock"
[ -S newsock ] || fail
rm newsock

# // TRYCASE(socket, symlink)

: $((COUNT += 1))

! [ -e newsock ] || fail
ln -s "$TRY" newsock
[ -L newsock ] || fail
"$TRY" -y "rm newsock; make-socket newsock"
! [ -e newlink ] || fail
[ -S newsock ] || fail
rm newsock

# // TRYCASE(socket, nonexist)

: $((COUNT += 1))

! [ -e newsock ]
"$TRY" -y "make-socket newsock"
[ -S newsock ] || fail
rm newsock
22 changes: 17 additions & 5 deletions try
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ set_TRY_SHELL() {
export TRY_SHELL
}


################################################################################
# Run a command (in `$@`) in an overlay (in `$SANDBOX_DIR`)
################################################################################
Expand Down Expand Up @@ -249,7 +248,7 @@ do
## NB $mountpoint is the local directory to mount
## $merger_dir is where we'll put its merger
"$UNION_HELPER" "$mountpoint" "$merger_dir" 2>>"$try_mount_log" ||
printf "%s: Warning: Failed mounting $mountpoint via $UNION_HELPER, see \"$try_mount_log\"\n" "$TRY_COMMAND" >&2
printf "%s: Warning: Failed mounting $mountpoint via $UNION_HELPER, see \"$try_mount_log\"\n" "$TRY_COMMAND" >&2
make_overlay "$SANDBOX_DIR" "$merger_dir" "$pure_mountpoint" 2>>"$try_mount_log" ||
printf "%s: Warning: Failed mounting $mountpoint as an overlay via $UNION_HELPER, see \"$try_mount_log\"\n" "$TRY_COMMAND" >&2
fi
Expand Down Expand Up @@ -458,7 +457,7 @@ find_upperdir_changes() {
sandbox_dir="$1"
ignore_file="$2"

find "$sandbox_dir/upperdir/" -type f -o \( -type c -size 0 \) -o -type d -o -type l | ignore_changes "$ignore_file"
find "$sandbox_dir/upperdir/" | ignore_changes "$ignore_file"
}

################################################################################
Expand Down Expand Up @@ -514,13 +513,12 @@ process_changes() {
echo "rd $local_file"
continue
fi

# must be a directory, but not opaque---leave it!
elif [ -c "$changed_file" ] && ! [ -s "$changed_file" ] && [ "$(stat -c %t,%T "$changed_file")" = "0,0" ]
then
# // TRYCASE(whiteout, *)
echo "de $local_file"
elif [ -f "$changed_file" ]
elif [ -f "$changed_file" ] || [ -p "$changed_file" ] || [ -S "$changed_file" ]
then
if [ -f "$changed_file" ] && getfattr --absolute-names -d "$changed_file" 2>/dev/null | grep -q -e "user.overlay.whiteout"
then
Expand All @@ -534,11 +532,25 @@ process_changes() {
# // TRYCASE(file, file)
# // TRYCASE(file, dir)
# // TRYCASE(file, symlink)
# // TRYCASE(fifo, file)
# // TRYCASE(fifo, dir)
# // TRYCASE(fifo, symlink)
# // TRYCASE(socket, file)
# // TRYCASE(socket, dir)
# // TRYCASE(socket, symlink)
echo "mo $local_file"
continue
else
# // TRYCASE(file, nonexist)
# // TRYCASE(fifo, nonexist)
# // TRYCASE(socket, nonexist)
echo "ad $local_file"
continue
fi
# // TRYCASE(fifo, *)
# // TRYCASE(socket, *)
echo "ad $local_file"
continue
fi
done <<EOF
$changed_files
Expand Down
Binary file added utils/make-socket
Binary file not shown.
Loading