diff options
author | Mike Frysinger <vapier@gentoo.org> | 2005-05-21 03:31:04 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2005-05-21 03:31:04 +0000 |
commit | 88ad0014b94cd628a16fda0fb8ae3f5b67e4eedc (patch) | |
tree | 232e36d73dde6214c879fae30a9a0473d0a568b3 /sys-apps/eject | |
parent | stabilize (diff) | |
download | gentoo-2-88ad0014b94cd628a16fda0fb8ae3f5b67e4eedc.tar.gz gentoo-2-88ad0014b94cd628a16fda0fb8ae3f5b67e4eedc.tar.bz2 gentoo-2-88ad0014b94cd628a16fda0fb8ae3f5b67e4eedc.zip |
Add toggle support by Patrik Kullman #62612 and a bunch of patches from Debian #91977.
(Portage version: 2.0.51.22-r1)
Diffstat (limited to 'sys-apps/eject')
-rw-r--r-- | sys-apps/eject/ChangeLog | 16 | ||||
-rw-r--r-- | sys-apps/eject/eject-2.0.13-r2.ebuild | 44 | ||||
-rw-r--r-- | sys-apps/eject/files/digest-eject-2.0.13-r2 | 1 | ||||
-rw-r--r-- | sys-apps/eject/files/eject-2.0.13-close-check.patch | 75 | ||||
-rw-r--r-- | sys-apps/eject/files/eject-2.0.13-finddev.patch | 52 | ||||
-rw-r--r-- | sys-apps/eject/files/eject-2.0.13-fstab-error.patch | 32 | ||||
-rw-r--r-- | sys-apps/eject/files/eject-2.0.13-no-umount.patch | 95 | ||||
-rw-r--r-- | sys-apps/eject/files/eject-2.0.13-prefix-defaultdevice-with-dev.patch | 22 | ||||
-rw-r--r-- | sys-apps/eject/files/eject-2.0.13-toggle.patch | 101 | ||||
-rw-r--r-- | sys-apps/eject/files/eject-2.0.13-xmalloc.patch | 28 | ||||
-rw-r--r-- | sys-apps/eject/files/eject-2.0.13-xregcomp.patch | 28 |
11 files changed, 486 insertions, 8 deletions
diff --git a/sys-apps/eject/ChangeLog b/sys-apps/eject/ChangeLog index 4009c2325034..f438a1def6f6 100644 --- a/sys-apps/eject/ChangeLog +++ b/sys-apps/eject/ChangeLog @@ -1,6 +1,18 @@ # ChangeLog for sys-apps/eject -# Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-apps/eject/ChangeLog,v 1.29 2005/02/13 05:12:21 vapier Exp $ +# Copyright 1999-2005 Gentoo Foundation; Distributed under the GPL v2 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/eject/ChangeLog,v 1.30 2005/05/21 03:31:03 vapier Exp $ + +*eject-2.0.13-r2 (21 May 2005) + + 21 May 2005; Mike Frysinger <vapier@gentoo.org> + +files/eject-2.0.13-close-check.patch, files/eject-2.0.13-finddev.patch, + +files/eject-2.0.13-fstab-error.patch, + +files/eject-2.0.13-no-umount.patch, + +files/eject-2.0.13-prefix-defaultdevice-with-dev.patch, + +files/eject-2.0.13-toggle.patch, +files/eject-2.0.13-xmalloc.patch, + +files/eject-2.0.13-xregcomp.patch, +eject-2.0.13-r2.ebuild: + Add toggle support by Patrik Kullman #62612 and a bunch of patches from + Debian #91977. *eject-2.0.13-r1 (13 Feb 2005) diff --git a/sys-apps/eject/eject-2.0.13-r2.ebuild b/sys-apps/eject/eject-2.0.13-r2.ebuild new file mode 100644 index 000000000000..ce4900933848 --- /dev/null +++ b/sys-apps/eject/eject-2.0.13-r2.ebuild @@ -0,0 +1,44 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/eject/eject-2.0.13-r2.ebuild,v 1.1 2005/05/21 03:31:03 vapier Exp $ + +inherit eutils + +DESCRIPTION="A command to eject a disc from the CD-ROM drive" +HOMEPAGE="http://eject.sourceforge.net/" +SRC_URI="http://www.ibiblio.org/pub/Linux/utils/disk-management/${P}.tar.gz + http://www.pobox.com/~tranter/${P}.tar.gz" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sh ~sparc ~x86" +IUSE="nls" + +DEPEND="" + +src_unpack() { + unpack ${A} + cd "${S}" + epatch "${FILESDIR}"/${P}-kernel25-support.patch + epatch "${FILESDIR}"/${P}-autoclose.patch + epatch "${FILESDIR}"/${P}-finddev.patch + epatch "${FILESDIR}"/${P}-header.patch + epatch "${FILESDIR}"/${P}-use-mountpoints.patch + epatch "${FILESDIR}"/${P}-close-check.patch + epatch "${FILESDIR}"/${P}-prefix-defaultdevice-with-dev.patch + epatch "${FILESDIR}"/${P}-xmalloc.patch + epatch "${FILESDIR}"/${P}-xregcomp.patch + epatch "${FILESDIR}"/${P}-no-umount.patch + epatch "${FILESDIR}"/${P}-toggle.patch + epatch "${FILESDIR}"/${P}-fstab-error.patch + + sed -i '/^AM_CFLAGS/s:-O3::' Makefile.in + if ! use nls ; then + sed -i "s:SUBDIRS = po::" Makefile.in || die "sed nls failed" + fi +} + +src_install() { + make DESTDIR="${D}" install || die "make install failed" + dodoc ChangeLog README PORTING TODO AUTHORS NEWS PROBLEMS +} diff --git a/sys-apps/eject/files/digest-eject-2.0.13-r2 b/sys-apps/eject/files/digest-eject-2.0.13-r2 new file mode 100644 index 000000000000..3c64dc062a37 --- /dev/null +++ b/sys-apps/eject/files/digest-eject-2.0.13-r2 @@ -0,0 +1 @@ +MD5 b796ad77beb4e7bdd08d6149701ab778 eject-2.0.13.tar.gz 59504 diff --git a/sys-apps/eject/files/eject-2.0.13-close-check.patch b/sys-apps/eject/files/eject-2.0.13-close-check.patch new file mode 100644 index 000000000000..0a952e05404a --- /dev/null +++ b/sys-apps/eject/files/eject-2.0.13-close-check.patch @@ -0,0 +1,75 @@ +Add pointless sanity checks. + +http://bugs.gentoo.org/91977 + +--- eject.c ++++ eject.c +@@ -69,6 +69,16 @@ + #include <scsi/sg.h> + #include <scsi/scsi_ioctl.h> + ++#define CLOSE(fd) if (close(fd)==-1) { \ ++ perror(programName); \ ++ exit(1); \ ++} ++ ++#define FCLOSE(fd) if (fclose(fd)==-1) { \ ++ perror(programName); \ ++ exit(1); \ ++} ++ + /* Global Variables */ + const char *version = VERSION; /* program version */ + int a_option = 0; /* command flags and arguments */ +@@ -627,7 +637,7 @@ + GetMajorMinor(s1, &mtabmaj, &mtabmin); + if (((strcmp(s1, name) == 0) || (strcmp(s2, name) == 0)) || + ((maj != -1) && (maj == mtabmaj) && (min == mtabmin))) { +- fclose(fp); ++ FCLOSE(fp); + *deviceName = strdup(s1); + *mountName = strdup(s2); + return 1; +@@ -636,7 +646,7 @@ + } + *deviceName = 0; + *mountName = 0; +- fclose(fp); ++ FCLOSE(fp); + return 0; + } + +@@ -663,13 +673,13 @@ + while (fgets(line, sizeof(line), fp) != 0) { + rc = sscanf(line, "%1023s %1023s", s1, s2); + if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) { +- fclose(fp); ++ FCLOSE(fp); + *deviceName = strdup(s1); + *mountName = strdup(s2); + return 1; + } + } +- fclose(fp); ++ FCLOSE(fp); + return 0; + } + +@@ -708,7 +718,7 @@ + } + } + } +- fclose(fp); ++ FCLOSE(fp); + } + + +@@ -1018,7 +1028,7 @@ + } + + /* cleanup */ +- close(fd); ++ CLOSE(fd); + free(device); + free(deviceName); + free(fullName); diff --git a/sys-apps/eject/files/eject-2.0.13-finddev.patch b/sys-apps/eject/files/eject-2.0.13-finddev.patch index 8b12504907fa..8006b1c84bd6 100644 --- a/sys-apps/eject/files/eject-2.0.13-finddev.patch +++ b/sys-apps/eject/files/eject-2.0.13-finddev.patch @@ -1,8 +1,48 @@ -Ripped from Fedora +Ripped from Fedora, updates from Ubuntu ---- eject-2.0.13/eject.c.orig 2004-09-07 12:10:58.382649630 +0200 -+++ eject-2.0.13/eject.c 2004-09-07 12:10:43.930067903 +0200 -@@ -326,6 +326,11 @@ +http://bugs.gentoo.org/91977 + +--- eject.1 ++++ eject.1 +@@ -34,8 +34,8 @@ + + The device corresponding to <name> is ejected. The name can be a + device file or mount point, either a full path or with the leading +-"/dev" or "/mnt" omitted. If no name is specified, the default name +-"cdrom" is used. ++"/dev", "/media" or "/mnt" omitted. If no name is specified, the ++default name "cdrom" is used. + + There are four different methods of ejecting, depending on whether the + device is a CD-ROM, SCSI device, removable floppy, or tape. By default +@@ -257,11 +257,11 @@ + the name ends in a trailing slash, it is removed (this is to support + filenames generated using shell file name completion). If the name + starts with '.' or '/', it tries to open it as a device file or mount +-point. If that fails, it tries prepending '/dev/', '/mnt/', '/dev/cdroms', +-\&'/dev/rdsk/', '/dev/dsk/', and finally './' to the name, until a +-device file or mount point is found that can be opened. The program +-checks /etc/mtab for mounted devices. If that fails, it also checks +-/etc/fstab for mount points of currently unmounted devices. ++point. If that fails, it tries prepending '/dev/', '/media/', '/mnt/', ++'/dev/cdroms', '/dev/rdsk/', '/dev/dsk/', and finally './' to the name, ++until a device file or mount point is found that can be opened. The ++program checks /etc/mtab for mounted devices. If that fails, it also ++checks /etc/fstab for mount points of currently unmounted devices. + + Creating symbolic links such as /dev/cdrom or /dev/zip is recommended + so that +--- eject.c ++++ eject.c +@@ -294,6 +294,7 @@ + * + * foo (if foo starts with '.' or '/') + * /dev/foo ++ * /media/foo + * /mnt/foo + * /dev/cdroms/foo + * /dev/cdroms/foo0 +@@ -321,6 +322,11 @@ if (FileExists(buf)) return buf; @@ -11,6 +51,6 @@ Ripped from Fedora + if (FileExists(buf)) + return buf; + - /* for devfs under Linux */ - strcpy(buf, "/dev/cdroms/"); + strcpy(buf, "/mnt/"); strcat(buf, name); + if (FileExists(buf)) diff --git a/sys-apps/eject/files/eject-2.0.13-fstab-error.patch b/sys-apps/eject/files/eject-2.0.13-fstab-error.patch new file mode 100644 index 000000000000..d1fcca649d5e --- /dev/null +++ b/sys-apps/eject/files/eject-2.0.13-fstab-error.patch @@ -0,0 +1,32 @@ +Don't abort if we can't access /etc/fstab + +http://bugs.gentoo.org/91977 + +--- eject.c ++++ eject.c +@@ -656,8 +656,13 @@ + + fp = fopen("/etc/fstab", "r"); + if (fp == NULL) { +- fprintf(stderr, _("%s: unable to open /etc/fstab: %s\n"), programName, strerror(errno)); +- exit(1); ++ /* ++ * /etc/fstab may be unreadable in some situations due to passwords in the ++ * file. ++ */ ++ if (v_option) ++ printf( _("%s: unable to open /etc/fstab: %s\n"), programName, strerror(errno)); ++ return -1; + } + + while (fgets(line, sizeof(line), fp) != 0) { +@@ -890,7 +895,8 @@ + /* if not currently mounted, see if it is a possible mount point */ + if (!mounted) { + mountable = MountableDevice(fullName, &mountName, &deviceName); +- if (v_option) { ++ /* if return value -1 then fstab could not be read */ ++ if (v_option && (mountable >= 0)) { + if (mountable) + printf(_("%s: `%s' can be mounted at `%s'\n"), programName, deviceName, mountName); + else diff --git a/sys-apps/eject/files/eject-2.0.13-no-umount.patch b/sys-apps/eject/files/eject-2.0.13-no-umount.patch new file mode 100644 index 000000000000..fac0e60cb965 --- /dev/null +++ b/sys-apps/eject/files/eject-2.0.13-no-umount.patch @@ -0,0 +1,95 @@ +Add a no unmount option to eject. + +http://bugs.gentoo.org/91977 + +--- eject.1 ++++ eject.1 +@@ -123,6 +123,13 @@ + also passes the -n option to umount(1). + + .TP 0.5i ++.B \-m ++This option allows eject to work with device drivers which automatically ++mount removable media and therefore must be always mount()ed. ++The option tells eject to not try to unmount the given device, ++even if it is mounted according to /etc/mtab or /proc/mounts. ++ ++.TP 0.5i + .B -V + This option causes + .B eject +--- eject.c ++++ eject.c +@@ -84,6 +84,7 @@ + int v_option = 0; + int x_option = 0; + int p_option = 0; ++int m_option = 0; + int a_arg = 0; + int c_arg = 0; + int x_arg = 0; +@@ -128,7 +129,9 @@ + " -s\t-- eject SCSI device\n" + " -f\t-- eject floppy\n" + " -q\t-- eject tape\n" +-" -p\t-- use /proc/mounts instead of /etc/mtab\n") ++" -p\t-- use /proc/mounts instead of /etc/mtab\n" ++" -m\t-- do not unmount device even if it is mounted\n" ++) + , version); + #ifdef GETOPTLONG + fprintf(stderr,_( +@@ -137,7 +140,7 @@ + " -a --auto -c --changerslot -t --trayclose -x --cdspeed\n" + " -r --cdrom -s --scsi -f --floppy\n" + " -q --tape -n --noop -V --version\n" +-" -p --proc\n")); ++" -p --proc -m --no-unmount\n")); + #endif /* GETOPTLONG */ + fprintf(stderr,_( + "Parameter <name> can be a device file or a mount point.\n" +@@ -151,7 +154,7 @@ + /* Handle command line options. */ + static void parse_args(int argc, char **argv, char **device) + { +- const char *flags = "a:c:x:dfhnqrstvVp"; ++ const char *flags = "a:c:x:dfhnqrstvVpm"; + #ifdef GETOPTLONG + static struct option long_options[] = + { +@@ -169,6 +172,7 @@ + {"tape", no_argument, NULL, 'q'}, + {"version", no_argument, NULL, 'V'}, + {"proc", no_argument, NULL, 'p'}, ++ {"no-unmount", no_argument, NULL, 'm'}, + {0, 0, 0, 0} + }; + int option_index; +@@ -231,6 +235,9 @@ + usage(); + exit(0); + break; ++ case 'm': ++ m_option = 1; ++ break; + case 'n': + n_option = 1; + break; +@@ -933,7 +940,7 @@ + if (!c_option) HandleXOption(deviceName); + + /* unmount device if mounted */ +- if (mounted) { ++ if ((m_option != 1) && mounted) { + if (v_option) + printf(_("%s: unmounting `%s'\n"), programName, deviceName); + Unmount(deviceName); +@@ -942,7 +949,7 @@ + /* if it is a multipartition device, unmount any other partitions on + the device */ + pattern = MultiplePartitions(deviceName); +- if (pattern != 0) ++ if ((m_option != 1) && (pattern != 0)) + UnmountDevices(pattern); + + /* handle -c option */ diff --git a/sys-apps/eject/files/eject-2.0.13-prefix-defaultdevice-with-dev.patch b/sys-apps/eject/files/eject-2.0.13-prefix-defaultdevice-with-dev.patch new file mode 100644 index 000000000000..0875bd69d25a --- /dev/null +++ b/sys-apps/eject/files/eject-2.0.13-prefix-defaultdevice-with-dev.patch @@ -0,0 +1,22 @@ +make sure DEFAULTDEVICE starts with "/dev/" +http://bugs.gentoo.org/91977 + +--- volname.c ++++ volname.c +@@ -39,6 +39,7 @@ + #include <sys/types.h> + #include <sys/stat.h> + #include <fcntl.h> ++#include <stdlib.h> + + int main(int argc, char *argv[]) + { +@@ -52,7 +53,7 @@ + if (argc == 2) { + device = argv[1]; + } else if (argc == 1) { +- device = DEFAULTDEVICE; ++ device = "/dev/" DEFAULTDEVICE; + } else { + fprintf(stderr, _("usage: volname [<device-file>]\n")); + exit(1); diff --git a/sys-apps/eject/files/eject-2.0.13-toggle.patch b/sys-apps/eject/files/eject-2.0.13-toggle.patch new file mode 100644 index 000000000000..d095fad57e5c --- /dev/null +++ b/sys-apps/eject/files/eject-2.0.13-toggle.patch @@ -0,0 +1,101 @@ +Add support for toggling the cdrom. + +Patch by Patrik Kullman. + +http://bugs.gentoo.org/62612 + +Note: this requires the no-umount.patch be applied first +or the 4th and 5th hunks will fail. + +--- eject.c ++++ eject.c +@@ -51,6 +51,7 @@ + #endif /* GETOPTLONG */ + #include <errno.h> + #include <regex.h> ++#include <sys/time.h> + #include <sys/types.h> + #include <sys/stat.h> + #include <sys/ioctl.h> +@@ -79,6 +80,7 @@ + int r_option = 0; + int s_option = 0; + int t_option = 0; ++int T_option = 0; + int v_option = 0; + int x_option = 0; + int p_option = 0; +@@ -118,11 +120,13 @@ + " eject [-vn] -a on|off|1|0 [<name>] -- turn auto-eject feature on or off\n" + " eject [-vn] -c <slot> [<name>] -- switch discs on a CD-ROM changer\n" + " eject [-vn] -t [<name>] -- close tray\n" ++" eject [-vn] -T [<name>] -- toggle tray status (EXPERIMENTAL)\n" + " eject [-vn] -x <speed> [<name>] -- set CD-ROM max speed\n" + "Options:\n" + " -v\t-- enable verbose output\n" + " -n\t-- don't eject, just show device found\n" + " -r\t-- eject CD-ROM\n" ++" -T\t-- toggle tray status (EXPERIMENTAL)" + " -s\t-- eject SCSI device\n" + " -f\t-- eject floppy\n" + " -q\t-- eject tape\n" +@@ -135,7 +139,7 @@ + " -a --auto -c --changerslot -t --trayclose -x --cdspeed\n" + " -r --cdrom -s --scsi -f --floppy\n" + " -q --tape -n --noop -V --version\n" +-" -p --proc -m --no-unmount\n")); ++" -p --proc -m --no-unmount -T --toggletray\n")); + #endif /* GETOPTLONG */ + fprintf(stderr,_( + "Parameter <name> can be a device file or a mount point.\n" +@@ -149,7 +153,7 @@ + /* Handle command line options. */ + static void parse_args(int argc, char **argv, char **device) + { +- const char *flags = "a:c:x:dfhnqrstvVpm"; ++ const char *flags = "a:c:x:dfhnqrstTvVpm"; + #ifdef GETOPTLONG + static struct option long_options[] = + { +@@ -159,6 +163,7 @@ + {"auto", required_argument, NULL, 'a'}, + {"changerslot", required_argument, NULL, 'c'}, + {"trayclose", no_argument, NULL, 't'}, ++ {"toggletray", no_argument, NULL, 'T'}, + {"cdspeed", required_argument, NULL, 'x'}, + {"noop", no_argument, NULL, 'n'}, + {"cdrom", no_argument, NULL, 'r'}, +@@ -247,6 +252,9 @@ + case 't': + t_option = 1; + break; ++ case 'T': ++ T_option = 1; ++ break; + case 'v': + v_option = 1; + break; +@@ -909,6 +917,23 @@ + exit(0); + } + ++ /* handle -T option */ ++ if (T_option) { ++ if (v_option) ++ printf(_("%s: trying to eject\n"), programName); ++ fd = OpenDevice(deviceName); ++ struct timeval tv, tv2; ++ gettimeofday(&tv, NULL); ++ EjectCdrom(fd); ++ gettimeofday(&tv2, NULL); ++ if ((tv2.tv_sec - tv.tv_sec) < 1) { ++ if (v_option) ++ printf(_("%s: tray seems open, trying to close\n"), programName); ++ CloseTray(fd); ++ HandleXOption(deviceName); ++ exit(0); ++ } ++ } + /* handle -t option */ + if (t_option) { + if (v_option) diff --git a/sys-apps/eject/files/eject-2.0.13-xmalloc.patch b/sys-apps/eject/files/eject-2.0.13-xmalloc.patch new file mode 100644 index 000000000000..f609da19d05f --- /dev/null +++ b/sys-apps/eject/files/eject-2.0.13-xmalloc.patch @@ -0,0 +1,28 @@ +Make sure the malloc's work. + +http://bugs.gentoo.org/91977 + +--- eject.c ++++ eject.c +@@ -304,2 +304,11 @@ + ++void *xmalloc(size_t size) ++{ ++ void *ret = malloc(size); ++ if (!ret) { ++ fprintf(stderr, _("%s: could not allocate memory\n"), programName); ++ exit(1); ++ } ++ return ret; ++} + +@@ -324,3 +333,3 @@ + +- buf = (char *) malloc(strlen(name)+14); /* to allow for "/dev/cdroms/ + "0" + null */ ++ buf = (char *) xmalloc(strlen(name)+14); /* to allow for "/dev/cdroms/ + "0" + null */ + +@@ -794,3 +803,3 @@ + if (status == 0) { +- result = (char *) malloc(strlen(name) + 25); ++ result = (char *) xmalloc(strlen(name) + 25); + strcpy(result, name); diff --git a/sys-apps/eject/files/eject-2.0.13-xregcomp.patch b/sys-apps/eject/files/eject-2.0.13-xregcomp.patch new file mode 100644 index 000000000000..f9116dfce662 --- /dev/null +++ b/sys-apps/eject/files/eject-2.0.13-xregcomp.patch @@ -0,0 +1,28 @@ +Make sure the regcomp's work. + +http://bugs.gentoo.org/91977 + +--- eject.c ++++ eject.c +@@ -706,2 +706,11 @@ + ++int xregcomp(regex_t *preg, const char *regex, int cflags) ++{ ++ if (regcomp(preg, regex, cflags) != 0) { ++ fprintf(stderr, _("%s: regcomp failed: %s\n"), programName, strerror(errno)); ++ exit(1); ++ } ++ return 0; ++} ++ + +@@ -720,3 +729,3 @@ + +- regcomp(&preg, pattern, REG_EXTENDED); ++ xregcomp(&preg, pattern, REG_EXTENDED); + +@@ -799,3 +808,3 @@ + strcat(pattern, "[a-z]([0-9]?[0-9])?$"); +- regcomp(&preg, pattern, REG_EXTENDED|REG_NOSUB); ++ xregcomp(&preg, pattern, REG_EXTENDED|REG_NOSUB); + status = regexec(&preg, name, 1, 0, 0); |