misc/clifm: new port had been added (+)

Unlike most of the terminal file managers, CliFM replaces the
traditional curses interface by a simple command-line interface.
It is a file manager, but also a shell extension.

WWW: https://github.com/leo-arch/clifm
This commit is contained in:
Alexey Dokuchaev 2021-06-18 12:59:54 +00:00
parent f54936a1ad
commit 458c0053ef
6 changed files with 176 additions and 0 deletions

View File

@ -38,6 +38,7 @@
SUBDIR += cinnamon-translations
SUBDIR += cldr-emoji-annotation
SUBDIR += clex
SUBDIR += clifm
SUBDIR += cloc
SUBDIR += clpbar
SUBDIR += cmatrix

24
misc/clifm/Makefile Normal file
View File

@ -0,0 +1,24 @@
# Created by: Alexey Dokuchaev <danfe@FreeBSD.org>
PORTNAME= clifm
PORTVERSION= 1.1
DISTVERSIONPREFIX= v
CATEGORIES= misc
MAINTAINER= danfe@FreeBSD.org
COMMENT= Non-curses, KISS file manager for the terminal
LICENSE= GPLv2
USES= desktop-file-utils gettext-runtime gmake localbase readline
USE_GITHUB= yes
GH_ACCOUNT= leo-arch
ALL_TARGET= build
MAKE_ENV= INSTALLPREFIX=${STAGEDIR}${PREFIX}/bin \
DESKTOPPREFIX=${STAGEDIR}${PREFIX}/share
post-patch:
@${REINPLACE_CMD} -e '/^CFLAGS/s,=.*-march=native,+=,' \
${WRKSRC}/src/Makefile
.include <bsd.port.mk>

3
misc/clifm/distinfo Normal file
View File

@ -0,0 +1,3 @@
TIMESTAMP = 1622268275
SHA256 (leo-arch-clifm-v1.1_GH0.tar.gz) = e2be66e8000fc43f177e472045d9d30f44625e854d85b4cdf5aad8179d32d5af
SIZE (leo-arch-clifm-v1.1_GH0.tar.gz) = 7195392

View File

@ -0,0 +1,102 @@
--- src/misc.c.orig 2021-05-29 06:04:35 UTC
+++ src/misc.c
@@ -31,6 +31,10 @@
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
+#if defined(__FreeBSD__)
+#include <sys/mount.h>
+#include <sys/sysctl.h>
+#endif
#include <time.h>
#include <unistd.h>
#include <readline/readline.h>
@@ -255,9 +259,16 @@ new_instance(char *dir, int sudo)
}
/* Get absolute path of executable name of itself */
+#if defined(__linux__)
char *self = realpath("/proc/self/exe", NULL);
if (!self) {
+#elif defined(__FreeBSD__)
+ const int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
+ char *self = malloc(PATH_MAX);
+ size_t len = PATH_MAX;
+ if (!self || sysctl(mib, 4, self, &len, NULL, 0) == -1) {
+#endif
fprintf(stderr, "%s: %s\n", PROGRAM_NAME, strerror(errno));
return EXIT_FAILURE;
}
@@ -812,6 +823,7 @@ set_shell(char *str)
int
list_mountpoints(void)
{
+#if defined(__linux__)
FILE *mp_fp = fopen("/proc/mounts", "r");
if (!mp_fp) {
@@ -819,13 +831,15 @@ list_mountpoints(void)
PROGRAM_NAME, strerror(errno));
return EXIT_FAILURE;
}
+#endif
printf(_("%sMountpoints%s\n\n"), bold, df_c);
char **mountpoints = (char **)NULL;
size_t mp_n = 0;
- int exit_status = EXIT_SUCCESS;
+ int i, j, exit_status = EXIT_SUCCESS;
+#if defined(__linux__)
size_t line_size = 0;
char *line = (char *)NULL;
ssize_t line_len = 0;
@@ -870,6 +884,10 @@ list_mountpoints(void)
free(line);
line = (char *)NULL;
fclose(mp_fp);
+#elif defined(__FreeBSD__)
+ struct statfs *fslist;
+ mp_n = getmntinfo(&fslist, MNT_NOWAIT);
+#endif
/* This should never happen: There should always be a mountpoint,
* at least "/" */
@@ -877,6 +895,26 @@ list_mountpoints(void)
fputs(_("mp: There are no available mountpoints\n"), stdout);
return EXIT_SUCCESS;
}
+#if defined(__FreeBSD__)
+ for (i = j = 0; i < mp_n; i++) {
+ /* Do not list all mountpoints, but only those corresponding
+ * to a block device (/dev) */
+ if (strncmp(fslist[i].f_mntfromname, "/dev/", 5) == 0) {
+ printf("%s%u%s %s%s%s (%s)\n", el_c, j + 1, df_c,
+ (access(fslist[i].f_mntonname, R_OK | X_OK)
+ == 0) ? di_c : nd_c, fslist[i].f_mntonname,
+ df_c, fslist[i].f_mntfromname);
+ /* Store the mountpoint into an array */
+ mountpoints = (char **)xrealloc(mountpoints,
+ (j + 1) * sizeof(char *));
+ mountpoints[j++] = savestring(fslist[i].f_mntonname,
+ strlen(fslist[i].f_mntonname));
+ }
+ }
+ /* Update filesystem counter as it would be used to free() the
+ * mountpoints entries later (below) */
+ mp_n = j;
+#endif
putchar('\n');
/* Ask the user and chdir into the selected mountpoint */
@@ -922,7 +960,7 @@ list_mountpoints(void)
/* Free stuff and exit */
free(input);
- int i = (int)mp_n;
+ i = (int)mp_n;
while (--i >= 0)
free(mountpoints[i]);

13
misc/clifm/pkg-descr Normal file
View File

@ -0,0 +1,13 @@
Unlike most of the terminal file managers, CliFM replaces the traditional
curses interface by a simple command-line interface. It is a file manager,
but also a shell extension.
Search for files, copy, rename, and trash some of them, but, at the same
time, update/upgrade your system, add some cronjob, stop a service, and
run nano (or vi, or emacs, if you like).
Those familiar with the command-line will find in a file manager based on
it a desirable addition to its functionality. The command-line is still
there, never hidden.
WWW: https://github.com/leo-arch/clifm

33
misc/clifm/pkg-plist Normal file
View File

@ -0,0 +1,33 @@
bin/clifm
share/applications/clifm.desktop
share/bash-completion/completions/clifm
%%DATADIR%%/functions/cd_on_quit.sh
%%DATADIR%%/functions/file_picker.sh
%%DATADIR%%/functions/subshell_notice.sh
%%DATADIR%%/mimelist.cfm
%%DATADIR%%/plugins/BFG.sh
%%DATADIR%%/plugins/batch_create.sh
%%DATADIR%%/plugins/clip.sh
%%DATADIR%%/plugins/colors.sh
%%DATADIR%%/plugins/dragondrop.sh
%%DATADIR%%/plugins/finder.sh
%%DATADIR%%/plugins/fzfdesel.sh
%%DATADIR%%/plugins/fzfhist.sh
%%DATADIR%%/plugins/fzfnav.sh
%%DATADIR%%/plugins/fzfsel.sh
%%DATADIR%%/plugins/git_status.sh
%%DATADIR%%/plugins/ihelp.sh
%%DATADIR%%/plugins/img_viewer.sh
%%DATADIR%%/plugins/jumper.sh
%%DATADIR%%/plugins/kbgen.c
%%DATADIR%%/plugins/mime_list.sh
%%DATADIR%%/plugins/music_player.sh
%%DATADIR%%/plugins/pdf_viewer.sh
%%DATADIR%%/plugins/rgfind.sh
%%DATADIR%%/plugins/update.sh
%%DATADIR%%/plugins/vid_viewer.sh
%%DATADIR%%/plugins/wallpaper_setter.sh
share/icons/hicolor/scalable/apps/clifm.svg
share/locale/es/LC_MESSAGES/clifm.mo
share/man/man1/clifm.1.gz
share/zsh/site-functions/_clifm