From 97011b78990c356bc906183d3c50118b73c79668 Mon Sep 17 00:00:00 2001 From: Jindrich Novy Date: Tue, 31 Jul 2012 08:59:20 +0200 Subject: [PATCH] update to 20120731 - add functionality that allows to list all packages in a collection - add dependency generators --- .gitignore | 5 +- Makefile | 44 ----------- macros.scl | 49 ------------ scl-utils.spec | 10 ++- scl.1 | 47 ----------- scl.c | 209 ------------------------------------------------- scl_enabled | 15 ---- sources | 2 +- 8 files changed, 10 insertions(+), 371 deletions(-) delete mode 100644 Makefile delete mode 100644 macros.scl delete mode 100644 scl.1 delete mode 100644 scl.c delete mode 100755 scl_enabled diff --git a/.gitignore b/.gitignore index 5735897..85ec7a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1 @@ -/scl -/scl.o -/scl.1 -/scl-utils-20120613.tar.gz +/scl-utils-20120731.tar.gz diff --git a/Makefile b/Makefile deleted file mode 100644 index 57b139a..0000000 --- a/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -NAME=scl-utils -VERSION=`date +%Y%m%d` -WARNINGS?=-Wall -Wshadow -Wcast-align -Winline -Wextra -Wmissing-noreturn -CFLAGS?=-O2 -CFILES=scl.c -OTHERFILES=Makefile scl_enabled macros.scl scl.1 -SOURCES=$(CFILES) $(OTHERFILES) -OBJECTS=scl.o - -BINDIR=/usr/bin -MANDIR=/usr/share/man -CNFDIR=/etc - -all: $(NAME) - -$(NAME): $(SOURCES) $(OBJECTS) $(OTHERFILES) - $(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(WARNINGS) -o scl - -clean: - rm -f *.o scl - -distclean: clean - rm -f *~ - -dist: $(NAME) - LANG=C - rm -rf $(NAME)-$(VERSION) - mkdir $(NAME)-$(VERSION) - cp $(SOURCES) $(NAME)-$(VERSION) - tar fcz $(NAME)-$(VERSION).tar.gz $(NAME)-$(VERSION) - rm -rf $(NAME)-$(VERSION) - -install: $(NAME) - mkdir -p $(DESTDIR)/$(BINDIR) - mkdir -p $(DESTDIR)/$(CNFDIR)/rpm - cp macros.scl $(DESTDIR)/$(CNFDIR)/rpm - cp scl $(DESTDIR)/$(BINDIR) - cp scl_enabled $(DESTDIR)/$(BINDIR) - cp scl.1 $(DESTDIR)/$(MANDIR)/man1 - -uninstall: - rm -f $(BINDIR)/scl $(BINDIR)/scl_enabled - rm -f $(CNFDIR)/rpm/macros.scl - rm -f $(MANDIR)/man1/scl.1 diff --git a/macros.scl b/macros.scl deleted file mode 100644 index 8dbe93a..0000000 --- a/macros.scl +++ /dev/null @@ -1,49 +0,0 @@ -# scl-utils RPM macros -# -# Copyright (C) 2012 Red Hat, Inc. -# Written by Jindrich Novy . - -%scl_package() %{expand:%{!?_root_prefix: -%global pkg_name %1 -%global scl_name %{scl} -%global scl_prefix %{scl}- -%global scl_runtime %{scl}-runtime -%{!?_scl_prefix: %global _scl_prefix /opt/rh} -%global _scl_scripts %{_scl_prefix}/%{scl} -%global _scl_root %{_scl_prefix}/%{scl}/root -%global _root_prefix %{_prefix} -%global _root_exec_prefix %{_root_prefix} -%global _root_bindir %{_exec_prefix}/bin -%global _root_sbindir %{_exec_prefix}/sbin -%global _root_libexecdir %{_exec_prefix}/libexec -%global _root_datadir %{_prefix}/share -%global _root_sysconfdir %{_sysconfdir} -%global _root_sharedstatedir %{_prefix}/com -%global _root_localstatedir %{_localstatedir} -%global _root_libdir %{_exec_prefix}/%{_lib} -%global _root_includedir %{_prefix}/include -%global _root_infodir %{_datadir}/info -%global _root_mandir %{_datadir}/man -%global _root_initddir %{_sysconfdir}/rc.d/init.d -%global _prefix %{_scl_root}/usr -%global _exec_prefix %{_prefix} -%global _bindir %{_exec_prefix}/bin -%global _sbindir %{_exec_prefix}/sbin -%global _libexecdir %{_exec_prefix}/libexec -%global _datadir %{_prefix}/share -%global _sysconfdir %{_scl_root}/etc -%global _sharedstatedir %{_prefix}/com -%global _localstatedir %{_scl_root}/var -%global _libdir %{_exec_prefix}/%{_lib} -%global _includedir %{_prefix}/include -%global _infodir %{_datadir}/info -%global _mandir %{_datadir}/man -%global _docdir %{_datadir}/doc -%global _defaultdocdir %{_docdir} -%global scl_pkg_name %{scl}-%{pkg_name} -BuildRequires: scl-utils-build -}} - -%scl_require() %{_scl_prefix}/%1/enable, %1 -%scl_require_package() %1-%2 - diff --git a/scl-utils.spec b/scl-utils.spec index 47f9950..fff93b2 100644 --- a/scl-utils.spec +++ b/scl-utils.spec @@ -1,7 +1,7 @@ Summary: Utilities for alternative packaging Name: scl-utils -Version: 20120613 -Release: 2%{?dist} +Version: 20120731 +Release: 1%{?dist} License: GPLv2+ Group: Applications/File URL: http://jnovy.fedorapeople.org/scl-utils/ @@ -50,8 +50,14 @@ rm -rf %buildroot %files build %defattr(-,root,root,-) %{_sysconfdir}/rpm/macros.scl +%{_rpmconfigdir}/scldeps.sh +%{_rpmconfigdir}/fileattrs/scl.attr %changelog +* Thu Jul 31 2012 Jindrich Novy 20120730-1 +- add functionality that allows to list all packages in a collection +- add dependency generators + * Sat Jul 21 2012 Fedora Release Engineering - 20120613-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild diff --git a/scl.1 b/scl.1 deleted file mode 100644 index e8f0311..0000000 --- a/scl.1 +++ /dev/null @@ -1,47 +0,0 @@ -.TH "scl" "1" -.SH "NAME" -scl \- Setup and run software from Software Collection environment -.SH "SYNOPSIS" -.PP -\fBscl\fP \fI\fR [\fI ...\fR] \fI\fR -.PP -\fBscl\fP {\fB-l|--list\fP} -.SH "DESCRIPTION" -.PP -This manual page documents \fBscl\fP, a -program which is an utility for running software packaged as a Software Collection. -.PP -\fBscl\fP utility allows to execute an application which is not located in the filesystem -root hierarchy but is present in an alternative location. This application can still use -and benefit from software installed in the root filesystem. In order to let an application -be visible to the system one has to use \fBscl\fP utility as an interface. -.PP -\fI\fR is a script name to execute in a bash environment before the application -itself takes in executed. Currently only \fBenable\fP scriptlet is mandatory which is needed -to update search paths, etc. -.PP -One can enable more Software Collections if needed and therefore one can use multiple -collections which are enabled by the left-right order as present on \fBscl\fP command-line. -.PP -\fI\fR is an arbitrary command or set of commands to execute within the Software -Collection environment enabled. Control is returned back to the caller with the original -environment as soon as the command finishes. It \fI\fR is '-' (dash) then it is -read from the standard input. -.SH "OPTIONS" -.PP -.IP "\fB-l, --list\fP" 10 -Lists all installed Software Collections on the system -.SH "EXAMPLES" -.TP -scl enable example 'less --version' -runs command 'less --version' in the environment with collection 'example' enabled -.TP -scl enable foo bar bash -runs bash instance with foo and bar Software Collections enabled -.TP -cat my_command | scl enable baz - -run set of commands listed in my_command file in the environment with baz Software Collection -enabled -.SH "AUTHOR" -.PP -\fBscl\fP was written by Jindrich Novy . diff --git a/scl.c b/scl.c deleted file mode 100644 index f771e93..0000000 --- a/scl.c +++ /dev/null @@ -1,209 +0,0 @@ -/* Copyright (C) 2011 Red Hat, Inc. - - Written by Jindrich Novy . - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; see the file COPYING. If not, - write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static void check_asprintf( char **strp, const char *fmt, ... ) { - va_list args; - - va_start(args, fmt); - - if (vasprintf(strp, fmt, args) == -1 || !*strp) { - fprintf(stderr, "Allocation failed.\n"); - exit(EXIT_FAILURE); - } - - va_end(args); -} - -static void write_script( int tfd, char *s ) { - if (write(tfd, s, strlen(s)) == -1) { - fprintf(stderr, "Error writing to temporary file\n"); - exit(EXIT_FAILURE); - } -} - -static void list_collections() { - struct stat sb; - struct dirent **nl; - int n, i; - const char prefix[] = "/etc/scl/prefixes/"; - - if (stat(prefix, &sb) == -1) { - fprintf(stderr, "%s does not exist\n", prefix); - exit(EXIT_FAILURE); - } - - if (!S_ISDIR(sb.st_mode)) { - fprintf(stderr, "%s is not a directory\n", prefix); - exit(EXIT_FAILURE); - } - - - if ((n = scandir(prefix, &nl, 0, alphasort)) < 0) { - perror("scandir"); - exit(EXIT_FAILURE); - } - - for (i=0; id_name != '.') { - printf("%s\n", nl[i]->d_name); - } - } - - free(nl); -} - -int main(int argc, char **argv) { - struct stat st; - char *path, *enablepath; - char tmp[] = "/var/tmp/sclXXXXXX"; - char *cmd = NULL, *bash_cmd, *echo, *enabled; - int i, tfd, ffd, stdin_read = 0; - - if (argc == 2 && (!strcmp(argv[1],"--list") || !strcmp(argv[1],"-l"))) { - list_collections(); - return 0; - } - - if (!strcmp(argv[argc-1], "-")) { /* reading command from stdin */ - size_t r; - - if (argc < 4) { - fprintf(stderr, "Need at least 3 arguments.\nRun %s without arguments to get help.\n", argv[0]); - exit(EXIT_FAILURE); - } - - cmd = malloc(BUFSIZ); - - if (!cmd) { - fprintf(stderr, "Can't allocate memory.\n"); - exit(EXIT_FAILURE); - } - - for (r=0; (r += fread(cmd+r, 1, BUFSIZ, stdin));) { - if (feof(stdin)) break; - cmd = realloc(cmd, r+BUFSIZ); - if (!cmd) { - fprintf(stderr, "Can't reallocate memory.\n"); - exit(EXIT_FAILURE); - } - } - if (!r) { - fprintf(stderr, "Error reading command from stdin.\n"); - exit(EXIT_FAILURE); - } - stdin_read = 1; - } - - if (!stdin_read) { - if (argc < 4) { - fprintf(stderr, "Usage: %s [, ...] \n" - "If is '-' then the command will be read from standard input.\n", argv[0]); - exit(EXIT_FAILURE); - } - cmd = strdup(argv[argc-1]); - } - - tfd = mkstemp(tmp); - - check_asprintf(&enabled, "scl_enabled %s\nif [ $? != 0 ]; then\n" - " eval \"SCLS=( ${x_scls[*]} )\"\n" - " SCLS+=(%s)\n" - " export X_SCLS=$(printf '%%q ' \"${SCLS[@]}\")\nfi\n", argv[2], argv[2]); - write_script(tfd, enabled); - free(enabled); - - for (i=2; i