- filesystem ownership by meta package
- add man page - fix memory leak when parsing commands from stdin - use more descriptive error message if /etc/prefixes is missing
This commit is contained in:
parent
48898610db
commit
e0ac1b4213
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
/scl
|
||||
/scl.o
|
||||
/scl-utils-20120229.tar.gz
|
||||
/scl.1
|
||||
/scl-utils-20120413.tar.gz
|
||||
|
4
Makefile
4
Makefile
@ -3,7 +3,7 @@ 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
|
||||
OTHERFILES=Makefile scl_enabled macros.scl scl.1
|
||||
SOURCES=$(CFILES) $(OTHERFILES)
|
||||
OBJECTS=scl.o
|
||||
|
||||
@ -36,7 +36,9 @@ install: $(NAME)
|
||||
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
|
||||
|
306
macros.scl
306
macros.scl
@ -47,13 +47,103 @@ BuildRequires: scl-utils-build
|
||||
%scl_require() %{_scl_prefix}/%1/enable
|
||||
|
||||
%scl_files %{expand:
|
||||
%{_scl_root}
|
||||
%dir %attr(555,root,root) %{_scl_root}
|
||||
%{_scl_scripts}
|
||||
%{_scl_scripts}/enable
|
||||
%{_root_sysconfdir}/scl/prefixes/%scl
|
||||
%{_scl_root}/bin
|
||||
%attr(555,root,root) %{_scl_root}/boot
|
||||
%{_scl_root}/dev
|
||||
%dir %{_scl_root}/etc
|
||||
%{_scl_root}/etc/X11
|
||||
%{_scl_root}/etc/xdg
|
||||
%{_scl_root}/etc/opt
|
||||
%{_scl_root}/etc/pm
|
||||
%{_scl_root}/etc/xinetd.d
|
||||
%{_scl_root}/etc/skel
|
||||
%{_scl_root}/etc/sysconfig
|
||||
%{_scl_root}/etc/pki
|
||||
%{_scl_root}/home
|
||||
%{_scl_root}/lib
|
||||
%ifarch x86_64 ppc ppc64 sparc sparc64 s390 s390x
|
||||
%{_scl_root}/%{_lib}
|
||||
%endif
|
||||
%{_scl_root}/media
|
||||
%dir %{_scl_root}/mnt
|
||||
%dir %{_scl_root}/opt
|
||||
%attr(555,root,root) %{_scl_root}/proc
|
||||
%attr(550,root,root) %{_scl_root}/root
|
||||
%{_scl_root}/run
|
||||
%{_scl_root}/sbin
|
||||
%{_scl_root}/srv
|
||||
%{_scl_root}/sys
|
||||
%attr(1777,root,root) %{_scl_root}/tmp
|
||||
%dir %{_scl_root}/usr
|
||||
%attr(555,root,root) %{_scl_root}/usr/bin
|
||||
%{_scl_root}/usr/etc
|
||||
%{_scl_root}/usr/games
|
||||
%{_scl_root}/usr/include
|
||||
%attr(555,root,root) %{_scl_root}/usr/lib
|
||||
%ifarch x86_64 ppc ppc64 sparc sparc64 s390 s390x
|
||||
%attr(555,root,root) %{_scl_root}/usr/%{_lib}
|
||||
%endif
|
||||
%{_scl_root}/usr/libexec
|
||||
%{_scl_root}/usr/local
|
||||
%attr(555,root,root) %{_scl_root}/usr/sbin
|
||||
%dir %{_scl_root}/usr/share
|
||||
%{_scl_root}/usr/share/aclocal
|
||||
%{_scl_root}/usr/share/applications
|
||||
%{_scl_root}/usr/share/augeas
|
||||
%{_scl_root}/usr/share/backgrounds
|
||||
%{_scl_root}/usr/share/desktop-directories
|
||||
%{_scl_root}/usr/share/dict
|
||||
%{_scl_root}/usr/share/doc
|
||||
%attr(555,root,root) %dir %{_scl_root}/usr/share/empty
|
||||
%{_scl_root}/usr/share/games
|
||||
%{_scl_root}/usr/share/ghostscript
|
||||
%{_scl_root}/usr/share/gnome
|
||||
%{_scl_root}/usr/share/icons
|
||||
%{_scl_root}/usr/share/idl
|
||||
%{_scl_root}/usr/share/info
|
||||
%dir %{_scl_root}/usr/share/locale
|
||||
%dir %{_scl_root}/usr/share/man
|
||||
%{_scl_root}/usr/share/mime-info
|
||||
%{_scl_root}/usr/share/misc
|
||||
%{_scl_root}/usr/share/omf
|
||||
%{_scl_root}/usr/share/pixmaps
|
||||
%{_scl_root}/usr/share/sounds
|
||||
%{_scl_root}/usr/share/themes
|
||||
%{_scl_root}/usr/share/xsessions
|
||||
%{_scl_root}/usr/share/X11
|
||||
%{_scl_root}/usr/src
|
||||
%{_scl_root}/usr/tmp
|
||||
%dir %{_scl_root}/var
|
||||
%{_scl_root}/var/adm
|
||||
%{_scl_root}/var/cache
|
||||
%{_scl_root}/var/db
|
||||
%{_scl_root}/var/empty
|
||||
%{_scl_root}/var/games
|
||||
%{_scl_root}/var/gopher
|
||||
%{_scl_root}/var/lib
|
||||
%{_scl_root}/var/local
|
||||
%ghost %dir %attr(755,root,root) %{_scl_root}/var/lock
|
||||
%ghost %{_scl_root}/var/lock/subsys
|
||||
%{_scl_root}/var/log
|
||||
%{_scl_root}/var/mail
|
||||
%{_scl_root}/var/nis
|
||||
%{_scl_root}/var/opt
|
||||
%{_scl_root}/var/preserve
|
||||
%ghost %attr(755,root,root) %{_scl_root}/var/run
|
||||
%dir %{_scl_root}/var/spool
|
||||
%attr(755,root,root) %{_scl_root}/var/spool/lpd
|
||||
%attr(775,root,mail) %{_scl_root}/var/spool/mail
|
||||
%attr(755,uucp,uucp) %{_scl_root}/var/spool/uucp
|
||||
%attr(1777,root,root) %{_scl_root}/var/tmp
|
||||
%{_scl_root}/var/yp
|
||||
}
|
||||
|
||||
%scl_install %{expand:
|
||||
# scl specific stuff
|
||||
mkdir -p %{buildroot}%{_root_sysconfdir}/{rpm,scl/prefixes}
|
||||
echo -n '%' > %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl}-config
|
||||
cat >> %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl}-config << EOF
|
||||
@ -62,4 +152,218 @@ EOF
|
||||
cat >> %{buildroot}%{_root_sysconfdir}/scl/prefixes/%{scl} << EOF
|
||||
%_scl_prefix
|
||||
EOF
|
||||
# filesystem
|
||||
cat >> %{buildroot}/lang-exceptions << EOF
|
||||
af_ZA
|
||||
am_ET
|
||||
ast_ES
|
||||
az_IR
|
||||
bg_BG
|
||||
bn_IN
|
||||
ca@valencia
|
||||
ca_ES
|
||||
ca_ES@valencian
|
||||
cs_CZ
|
||||
de_AT
|
||||
de_CH
|
||||
de_DE
|
||||
default
|
||||
el_GR
|
||||
en_AU
|
||||
en_CA
|
||||
en_GB
|
||||
en_US
|
||||
en_NZ
|
||||
es_AR
|
||||
es_CL
|
||||
es_CO
|
||||
es_CR
|
||||
es_DO
|
||||
es_EC
|
||||
es_ES
|
||||
es_GT
|
||||
es_HN
|
||||
es_MX
|
||||
es_NI
|
||||
es_PA
|
||||
es_PE
|
||||
es_PR
|
||||
es_SV
|
||||
es_UY
|
||||
es_VE
|
||||
et_EE
|
||||
eu_ES
|
||||
fa_IR
|
||||
fi_FI
|
||||
fr_BE
|
||||
fr_CA
|
||||
fr_CH
|
||||
fr_FR
|
||||
gl_ES
|
||||
he_IL
|
||||
hr_HR
|
||||
hu_HU
|
||||
it_CH
|
||||
it_IT
|
||||
ja_JP
|
||||
ko_KR
|
||||
ks@devanagari
|
||||
lv_LV
|
||||
ms_MY
|
||||
my_MM
|
||||
nb_NO
|
||||
nds_DE
|
||||
nl_BE
|
||||
nl_NL
|
||||
pl_PL
|
||||
pt_BR
|
||||
pt_PT
|
||||
ru_RU
|
||||
sl_SI
|
||||
sq_AL
|
||||
sr_RS
|
||||
sv_SE
|
||||
uk_UA
|
||||
ur_PK
|
||||
zh_CN
|
||||
zh_CN.GB2312
|
||||
zh_HK
|
||||
zh_TW
|
||||
zh_TW.Big5
|
||||
en@boldquot
|
||||
en@quot
|
||||
nds@NFE
|
||||
sr@ije
|
||||
sr@ijekavian
|
||||
sr@ijekavianlatin
|
||||
sr@latin
|
||||
sr@Latn
|
||||
uz@cyrillic
|
||||
uz@Latn
|
||||
be@latin
|
||||
en@shaw
|
||||
brx
|
||||
brx_IN
|
||||
EOF
|
||||
cat >> %{buildroot}/iso_639.sed << EOF
|
||||
1,/<iso_639_entries/b
|
||||
# on each new iso-code process the current one
|
||||
\\!\\(<iso_639_entry\\|</iso_639_entries>\\)!{
|
||||
x
|
||||
s/^$//
|
||||
# we are on the first iso-code--nothing to process here
|
||||
t
|
||||
# process and write to output
|
||||
s/\\s\\+/ /g
|
||||
s/<iso_639_entry//
|
||||
s!/\\s*>!!
|
||||
# use '%' as a separator of parsed and unparsed input
|
||||
s/\\(.*\\)iso_639_2T_code="\\([^"]\\+\\)"\\(.*\\)/\\2 % \\1 \\3/
|
||||
s/\\([^%]\\+\\)%\\(.*\\)iso_639_2B_code="\\([^"]\\+\\)"\\(.*\\)/\\1\\t\\3 % \\2 \\4/
|
||||
# clear subst. memory for the next t
|
||||
t clear
|
||||
:clear
|
||||
s/\\([^%]\\+\\)%\\(.*\\)iso_639_1_code="\\([^"]\\+\\)"\\(.*\\)/\\1\\t\\3 % \\2 \\4/
|
||||
t name
|
||||
# no 639-1 code--write xx
|
||||
s/%/\\tXX %/
|
||||
:name
|
||||
s/\\([^%]\\+\\)%\\(.*\\)name="\\([^"]\\+\\)"\\(.*\\)/\\1\\t\\3/
|
||||
s/ \\t/\\t/g
|
||||
p
|
||||
b
|
||||
:noout
|
||||
}
|
||||
H
|
||||
EOF
|
||||
cat >> %{buildroot}/iso_3166.sed << EOF
|
||||
1,/<iso_3166_entries/b
|
||||
# on each new iso-code process the current one
|
||||
\\!\\(<iso_3166_entry\\|</iso_3166_entries>\\)!{
|
||||
x
|
||||
s/^$//
|
||||
# we are on the first iso-code--nothing to process here
|
||||
t
|
||||
# process and write to output
|
||||
s/\\s\\+/ /g
|
||||
s/<iso_3166_entry//
|
||||
s!/\\s*>!!
|
||||
# use '%' as a separator of parsed and unparsed input
|
||||
s/\\(.*\\)alpha_2_code="\\([^"]\\+\\)"\\(.*\\)/\\2 % \\1 \\3/
|
||||
s/\\([^%]\\+\\)%\\(.*\\)alpha_3_code="\\([^"]\\+\\)"\\(.*\\)/\\1% \\2 \\4/
|
||||
# clear subst. memory for the next t
|
||||
t clear
|
||||
:clear
|
||||
s/\\([^%]\\+\\)%\\(.*\\)numeric_code="\\([^"]\\+\\)"\\(.*\\)/\\1% \\2 \\4/
|
||||
t name
|
||||
# no 3166 code--write xx
|
||||
s/%/\\tXX %/
|
||||
:name
|
||||
s/\\([^%]\\+\\)%\\(.*\\)name="\\([^"]\\+\\)"\\(.*\\)/\\1\\t\\3/
|
||||
s/ \\t/\\t/g
|
||||
p
|
||||
b
|
||||
:noout
|
||||
}
|
||||
H
|
||||
EOF
|
||||
mkdir -p %{buildroot}%{_scl_root}
|
||||
cd %{buildroot}%{_scl_root}
|
||||
mkdir -p boot dev \\
|
||||
etc/{X11/{applnk,fontpath.d},xdg/autostart,opt,pm/{config.d,power.d,sleep.d},xinetd.d,skel,sysconfig,pki} \\
|
||||
home media mnt opt proc root run/lock srv sys tmp \\
|
||||
usr/{bin,etc,games,include,%{_lib}/{games,sse2,tls,X11,pm-utils/{module.d,power.d,sleep.d}},lib/{games,locale,modules,sse2},libexec,local/{bin,etc,games,lib,%{_lib},sbin,src,share/{applications,man/man{1,2,3,4,5,6,7,8,9,n,1x,2x,3x,4x,5x,6x,7x,8x,9x},info},libexec,include,},sbin,share/{aclocal,applications,augeas/lenses,backgrounds,desktop-directories,dict,doc,empty,games,ghostscript/conf.d,gnome,icons,idl,info,man/man{1,2,3,4,5,6,7,8,9,n,1x,2x,3x,4x,5x,6x,7x,8x,9x,0p,1p,3p},mime-info,misc,omf,pixmaps,sounds,themes,xsessions,X11},src,src/kernels,src/debug} \\
|
||||
var/{adm,empty,gopher,lib/{games,misc,rpm-state},local,lock/subsys,log,nis,preserve,run,spool/{mail,lpd,uucp},tmp,db,cache,opt,games,yp}
|
||||
ln -snf ../var/tmp usr/tmp
|
||||
ln -snf spool/mail var/mail
|
||||
ln -snf usr/bin bin
|
||||
ln -snf usr/sbin sbin
|
||||
ln -snf usr/lib lib
|
||||
ln -snf usr/%{_lib} %{_lib}
|
||||
sed -n -f %{buildroot}/iso_639.sed /usr/share/xml/iso-codes/iso_639.xml >%{buildroot}/iso_639.tab
|
||||
sed -n -f %{buildroot}/iso_3166.sed /usr/share/xml/iso-codes/iso_3166.xml >%{buildroot}/iso_3166.tab
|
||||
grep -v "^$" %{buildroot}/iso_639.tab | grep -v "^#" | while read a b c d ; do
|
||||
[[ "$d" =~ "^Reserved" ]] && continue
|
||||
[[ "$d" =~ "^No linguistic" ]] && continue
|
||||
locale=$c
|
||||
if [ "$locale" = "XX" ]; then
|
||||
locale=$b
|
||||
fi
|
||||
echo "%lang(${locale}) %{_scl_root}/usr/share/locale/${locale}" >> $RPM_BUILD_DIR/filelist
|
||||
echo "%lang(${locale}) %ghost %config(missingok) %{_scl_root}/usr/share/man/${locale}" >>$RPM_BUILD_DIR/filelist
|
||||
done
|
||||
cat %{buildroot}/lang-exceptions | grep -v "^#" | grep -v "^$" | while read loc ; do
|
||||
locale=$loc
|
||||
locality=
|
||||
special=
|
||||
[[ "$locale" =~ "@" ]] && locale=${locale%%%%@*}
|
||||
[[ "$locale" =~ "_" ]] && locality=${locale##*_}
|
||||
[[ "$locality" =~ "." ]] && locality=${locality%%%%.*}
|
||||
[[ "$loc" =~ "_" ]] || [[ "$loc" =~ "@" ]] || special=$loc
|
||||
# If the locality is not official, skip it
|
||||
if [ -n "$locality" ]; then
|
||||
grep -q "^$locality" %{buildroot}/iso_3166.tab || continue
|
||||
fi
|
||||
# If the locale is not official and not special, skip it
|
||||
if [ -z "$special" ]; then
|
||||
egrep -q "[[:space:]]${locale%%_*}[[:space:]]" \\
|
||||
%{buildroot}/iso_639.tab || continue
|
||||
fi
|
||||
echo "%lang(${locale}) %{_scl_root}/usr/share/locale/${loc}" >> $RPM_BUILD_DIR/filelist
|
||||
echo "%lang(${locale}) %ghost %config(missingok) %{_scl_root}/usr/share/man/${loc}" >> $RPM_BUILD_DIR/filelist
|
||||
done
|
||||
rm -f %{buildroot}/iso_639.tab
|
||||
rm -f %{buildroot}/iso_639.sed
|
||||
rm -f %{buildroot}/iso_3166.tab
|
||||
rm -f %{buildroot}/iso_3166.sed
|
||||
rm -f %{buildroot}/lang-exceptions
|
||||
cat $RPM_BUILD_DIR/filelist | grep "locale" | while read a b ; do
|
||||
mkdir -p -m 755 %{buildroot}/$b/LC_MESSAGES
|
||||
done
|
||||
cat $RPM_BUILD_DIR/filelist | grep "/share/man" | while read a b c d; do
|
||||
mkdir -p -m 755 %{buildroot}/$d/man{1,2,3,4,5,6,7,8,9,n,1x,2x,3x,4x,5x,6x,7x,8x,9x,0p,1p,3p}
|
||||
done
|
||||
for i in man{1,2,3,4,5,6,7,8,9,n,1x,2x,3x,4x,5x,6x,7x,8x,9x,0p,1p,3p}; do
|
||||
echo "%{_scl_root}/usr/share/man/$i" >>$RPM_BUILD_DIR/filelist
|
||||
done
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
Summary: Utilities for alternative packaging
|
||||
Name: scl-utils
|
||||
Version: 20120229
|
||||
Version: 20120413
|
||||
Release: 1%{?dist}
|
||||
License: GPLv2+
|
||||
Group: Applications/File
|
||||
@ -30,6 +30,7 @@ rm -rf %buildroot
|
||||
mkdir -p %buildroot%{_sysconfdir}/rpm
|
||||
mkdir -p %buildroot%{_sysconfdir}/scl/prefixes
|
||||
mkdir -p %buildroot/opt/rh
|
||||
install -d -m 755 %buildroot%{_mandir}/man1
|
||||
make install DESTDIR=%buildroot
|
||||
|
||||
%clean
|
||||
@ -41,12 +42,19 @@ rm -rf %buildroot
|
||||
%dir %{_sysconfdir}/scl/prefixes
|
||||
%{_bindir}/scl
|
||||
%{_bindir}/scl_enabled
|
||||
%{_mandir}/man1/*
|
||||
|
||||
%files build
|
||||
%defattr(-,root,root,-)
|
||||
%{_sysconfdir}/rpm/macros.scl
|
||||
|
||||
%changelog
|
||||
* Fri Apr 13 2012 Jindrich Novy <jnovy@redhat.com> 20120413-1
|
||||
- filesystem ownership by meta package
|
||||
- add man page
|
||||
- fix memory leak when parsing commands from stdin
|
||||
- use more descriptive error message if /etc/prefixes is missing
|
||||
|
||||
* Wed Feb 29 2012 Jindrich Novy <jnovy@redhat.com> 20120229-1
|
||||
- do not prepend scl_* prefix to package names
|
||||
- unify package naming to <SCL>-package-version
|
||||
|
47
scl.1
Normal file
47
scl.1
Normal file
@ -0,0 +1,47 @@
|
||||
.TH "scl" "1"
|
||||
.SH "NAME"
|
||||
scl \- Setup and run software from Software Collection environment
|
||||
.SH "SYNOPSIS"
|
||||
.PP
|
||||
\fBscl\fP \fI<action>\fR [\fI<collection1> <collection2> ...\fR] \fI<command>\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<action>\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<command>\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<command>\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 <jnovy@redhat.com>.
|
3
scl.c
3
scl.c
@ -57,7 +57,7 @@ static void list_collections() {
|
||||
const char prefix[] = "/etc/scl/prefixes/";
|
||||
|
||||
if (stat(prefix, &sb) == -1) {
|
||||
perror("stat");
|
||||
fprintf(stderr, "%s does not exist\n", prefix);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@ -201,6 +201,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
check_asprintf(&bash_cmd, "/bin/bash %s", tmp);
|
||||
i = system(bash_cmd);
|
||||
if (stdin_read) free(cmd);
|
||||
free(bash_cmd);
|
||||
unlink(tmp);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user