added passing variables to the script

This commit is contained in:
Dimitris Zlatanidis 2015-02-03 06:20:01 +02:00
parent e596692146
commit 601c3c41bd
3 changed files with 42 additions and 6 deletions

View file

@ -2,6 +2,7 @@ Version 2.2.1
2-2-2015
[Feature] - Added support multipackages.
- Added passing variables to the script.
[Updated] - Fix [key error] when you enter wrong name repository as default.
- Rename BUILD variable to BUILD_PATH in configuration file slpkg.conf.

View file

@ -267,6 +267,7 @@ Command Line Tool Usage
Slpkg Examples
--------------
If you use slpkg for the first time will have to create
and update the package list. This command must be executed to update the
package lists:
@ -441,6 +442,20 @@ Installing packages from the repositories (supporting multi packages):
Would you like to continue [Y/n]?
Build packages and passing variables to the script:
.. code-block:: bash
First export variable(s) like:
$ export SLPKG_FFMPEG_ASS=yes SLPKG_FFMPEG_X264=yes
And then run as you know:
$ slpkg -s sbo ffmpeg
Tracking all dependencies of packages,
and also displays installed packages:
@ -465,6 +480,7 @@ and also displays installed packages:
|
+--5 libunique
Check if your packages is up to date:
.. code-block:: bash
@ -653,6 +669,7 @@ Auto tool to build package:
Total build time for package termcolor : 1 Sec
Upgrade, install packages like Slackware command '# upgradepkg --install-new':
.. code-block:: bash
@ -684,6 +701,7 @@ Install mass-packages:
$ slpkg -i *.t?z
Find installed packages:
.. code-block:: bash
@ -754,6 +772,7 @@ Display the contents of the packages:
No such package lua: Cant find
Remove packages:
.. code-block:: bash
@ -791,6 +810,7 @@ Remove packages:
| Package: termcolor removed
+==============================================================================
Remove packages with all dependencies:
(presupposes facility with the option 'slpkg -s <repository> <package>)
@ -828,7 +848,6 @@ Remove packages with all dependencies:
+==============================================================================
Build and install packages that have added to the queue:
.. code-block:: bash
@ -863,6 +882,7 @@ Build and install packages that have added to the queue:
$ slpkg -q --build-install (build and install)
Add packages in blacklist file manually from
/etc/slpkg/blacklist or with the following options:

View file

@ -76,22 +76,25 @@ class BuildPackage(object):
# change permissions
subprocess.call("chmod +x {0}.SlackBuild".format(self.prgnam),
shell=True)
pass_var = self.pass_variable()
if _m.sbo_build_log == "on":
if os.path.isfile(self.build_logs + self.log_file):
os.remove(self.build_logs + self.log_file)
# start log write
log_head(self.build_logs, self.log_file, self.start_log_time)
subprocess.Popen("./{0}.SlackBuild 2>&1 | tee -a {1}{2}".format(
self.prgnam, self.build_logs, self.log_file), shell=True,
stdout=sys.stdout).communicate()
subprocess.Popen("{0} ./{1}.SlackBuild 2>&1 | tee -a "
"{2}{3}".format(' '.join(pass_var),
self.prgnam, self.build_logs,
self.log_file), shell=True,
stdout=sys.stdout).communicate()
sum_time = build_time(self.start_time)
# write end in log file
log_end(self.build_logs, self.log_file, sum_time)
print("Total build time for package {0} : {1}\n".format(
self.prgnam, sum_time))
else:
subprocess.call("./{0}.SlackBuild".format(self.prgnam,
shell=True))
subprocess.call("{0} ./{1}.SlackBuild".format(
' '.join(pass_var), self.prgnam, shell=True))
os.chdir(self.path)
except (OSError, IOError):
Msg().pkg_not_found("\n", self.prgnam, "Wrong file", "\n")
@ -99,6 +102,18 @@ class BuildPackage(object):
print("") # new line at exit
sys.exit(0)
def pass_variable(self):
'''
Grep slpkg bash variable
'''
pass_var = []
bash_var = subprocess.check_output("set | grep 'SLPKG'", shell=True)
for var in bash_var.split():
if (var.startswith('SLPKG') and
var.split('_')[-2].lower() == self.prgnam.lower()):
pass_var.append(var[len('SLPKG') + len(self.prgnam) + 2:])
return pass_var
def log_head(path, log_file, log_time):
'''