1
0

pschdir(1)

This commit is contained in:
dtb 2023-09-12 21:57:25 -04:00
parent 2eb1e26e8e
commit 51198e1ca2
3 changed files with 63 additions and 0 deletions

View File

@ -57,6 +57,10 @@ dist/grammy.tmp/weather.com.png: dist/grammy.tmp
dist/ifpublic: dist/ifpublic:
cp ifpublic/ifpublic dist/ cp ifpublic/ifpublic dist/
dist/pschdir:
$(MAKE) -C pschdir
cp pschdir/pschdir dist/pschdir
dist/spacer.bin: dist/spacer.bin:
# creates an 8GB empty file # creates an 8GB empty file
# that way when the alarm bells go off you can delete it to save a # that way when the alarm bells go off you can delete it to save a
@ -97,6 +101,14 @@ $(PREFIX)/bin/bspwm:
git clone https://github.com/baskerville/bspwm.git $(PREFIX)/src/bspwm git clone https://github.com/baskerville/bspwm.git $(PREFIX)/src/bspwm
$(MAKE) -C $(PREFIX)/src/bspwm install $(MAKE) -C $(PREFIX)/src/bspwm install
# Installs the Python script without documentation because I'm lazy and don't
# wanna run the upstream Makefile and then deal with filtering out the Python
# stuff (which is specific to 3.6 which is a little outdated).
# depends on apk:git apk:python
$(PREFIX)/bin/git-filter-repo:
git clone https://github.com/newren/git-filter-repo.git $(PREFIX)/src/git-filter-repo
$(INSTALL) -Dm0755 $(PREFIX)/src/git-filter-repo/git-filter-repo $(PREFIX)/bin/git-filter-repo
# nmap 7.80 is the last Free nmap release # nmap 7.80 is the last Free nmap release
# depends on apk:linux-headers # depends on apk:linux-headers
# had to # ln -s /bin/gmake /usr/local/bin/make # had to # ln -s /bin/gmake /usr/local/bin/make
@ -134,6 +146,14 @@ $(PREFIX)/bin/scrot:
sh -c 'cd $(PREFIX)/src/scrot && ./autogen.sh && ./configure MAKE=$(MAKE) PREFIX=$(PREFIX)' sh -c 'cd $(PREFIX)/src/scrot && ./autogen.sh && ./configure MAKE=$(MAKE) PREFIX=$(PREFIX)'
$(MAKE) -C $(PREFIX)/src/scrot install $(MAKE) -C $(PREFIX)/src/scrot install
# depends on
# apk:sudo
$(PREFIX)/src/wiringpi:
git clone https://github.com/WiringPi/WiringPi.git $(PREFIX)/src/wiringpi
git -C $(PREFIX)/src/wiringpi checkout final_official_2.50
sed -i .tmp -e /^sudo/d $(PREFIX)/src/wiringpi/build
sh -c 'cd $(PREFIX)/src/wiringpi; sudo=sudo ./build'
$(PREFIX)/bin/xdo: $(PREFIX)/bin/xdo:
git clone https://github.com/baskerville/xdo.git $(PREFIX)/src/xdo git clone https://github.com/baskerville/xdo.git $(PREFIX)/src/xdo
$(MAKE) -C $(PREFIX)/src/xdo install $(MAKE) -C $(PREFIX)/src/xdo install

2
pschdir/Makefile Normal file
View File

@ -0,0 +1,2 @@
pschdir: pschdir.c
$(CC) $(CFLAGS) -o pschdir pschdir.c

41
pschdir/pschdir.c Normal file
View File

@ -0,0 +1,41 @@
#include <errno.h> /* EACCESS, ELOOP, ENAMETOOLONG, ENOENT, ENOTDIR, errno */
#include <stdio.h> /* fprintf(3) */
#include <stdlib.h> /* stderr */
#include <sysexits.h> /* EX_OSERR, EX_NOPERM, EX_NOINPUT, EX_UNAVAILABLE,
* EX_USAGE */
#include <unistd.h> /* chdir(2) */
static char *program_name = "pschdir";
int main(int argc, char *argv[]){
if(argc < 3){
fprintf(stderr,
"Usage: %s [directory] [command (argument...)]\n",
argv[0] == NULL ? program_name : argv[0]);
return EX_USAGE;
}
if(chdir(argv[1]) != 0){
fprintf(stderr, "%s: %s: ", argv[0], argv[1]);
switch(errno){
case EACCES:
fprintf(stderr, "Access to directory denied.\n");
return EX_NOPERM;
case ELOOP:
fprintf(stderr, "Symbolic link loop.\n");
return EX_UNAVAILABLE;
case ENAMETOOLONG:
fprintf(stderr, "Name too long.\n");
return EX_OSERR;
case ENOENT:
fprintf(stderr, "Not found.\n");
return EX_NOINPUT;
case ENOTDIR:
fprintf(stderr, "Not a directory.\n");
return EX_NOINPUT;
}
}
execvp(argv[2], argv + 2);
}