From 48898610db96723a96ef0e68a57e8c690e581985 Mon Sep 17 00:00:00 2001 From: Jindrich Novy Date: Wed, 29 Feb 2012 14:30:42 +0100 Subject: [PATCH] Simplify package naming - do not prepend scl_* prefix to package names - unify package naming to -package-version - add scl --list functionality to list available SCLs --- .gitignore | 2 +- macros.scl | 9 ++++----- scl-utils.spec | 7 ++++++- scl.c | 36 ++++++++++++++++++++++++++++++++++++ sources | 2 +- 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index a57447d..b0389af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /scl /scl.o -/scl-utils-20120209.tar.gz +/scl-utils-20120229.tar.gz diff --git a/macros.scl b/macros.scl index cd160c3..953fbc9 100644 --- a/macros.scl +++ b/macros.scl @@ -5,10 +5,9 @@ %scl_package() %{expand:%{!?_root_prefix: %global pkg_name %1 -%global scl_short_prefix scl -%global scl_name %{scl_short_prefix}_%{scl} -%global scl_runtime %{scl_name}-runtime -%global scl_prefix %{scl_name}_ +%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 @@ -41,7 +40,7 @@ %global _mandir %{_datadir}/man %global _docdir %{_datadir}/doc %global _defaultdocdir %{_docdir} -%global scl_pkg_name %{scl_short_prefix}_%{scl}_%{pkg_name} +%global scl_pkg_name %{scl}-%{pkg_name} BuildRequires: scl-utils-build }} diff --git a/scl-utils.spec b/scl-utils.spec index 5fe4d4f..58b9ccb 100644 --- a/scl-utils.spec +++ b/scl-utils.spec @@ -1,6 +1,6 @@ Summary: Utilities for alternative packaging Name: scl-utils -Version: 20120209 +Version: 20120229 Release: 1%{?dist} License: GPLv2+ Group: Applications/File @@ -47,6 +47,11 @@ rm -rf %buildroot %{_sysconfdir}/rpm/macros.scl %changelog +* Wed Feb 29 2012 Jindrich Novy 20120229-1 +- do not prepend scl_* prefix to package names +- unify package naming to -package-version +- add scl --list functionality to list available SCLs + * Thu Feb 09 2012 Jindrich Novy 20120209-1 - fix minor bugs (#788194) - clear temp files diff --git a/scl.c b/scl.c index 5ab3d3f..a28f06e 100644 --- a/scl.c +++ b/scl.c @@ -50,6 +50,37 @@ static void write_script( int tfd, char *s ) { } } +static void list_collections() { + struct stat sb; + struct dirent **nl; + int n, i; + const char prefix[] = "/etc/scl/prefixes/"; + + if (stat(prefix, &sb) == -1) { + perror("stat"); + 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; @@ -57,6 +88,11 @@ int main(int argc, char **argv) { 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; diff --git a/sources b/sources index b9684c9..b3f4ac0 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -d52975ee97b0be67ffb8c014b68f9012 scl-utils-20120209.tar.gz +56205bacbc93096c482f8027e15c9b7f scl-utils-20120229.tar.gz