How to install yui compressor in CentOs - installation

I know this is going to sound like a noob question, but I'm new to using linux, I was trying to find out how to install yui-compressor in CentOS, but I haven't been able to find it using google.
I have already done this:
wget http://yui.zenfs.com/releases/yuicompressor/yuicompressor-2.4.6.zip
unzip yuicompressor-2.4.6.zip
# mv yuicompressor-2.4.6/build/yuicompressor-2.4.6.jar /usr/share/yui-compressor/yui-compressor.jar
I've also created a file in /usr/bin called yui-compressor that has:
#!/bin/sh
YUI_JAR=/usr/share/yui-compressor/yui-compressor.jar
I dont know what else to do. (I don't even know if its already installed).
Can someone please help me with the following:
If its installed, please tell me.
If not. Tell me what else do I need to do.
Thank you.

At the most basic level, you will want to update your /usr/bin/yui-compressor script to look something like this:
#!/bin/sh
YUI_JAR=/usr/share/yui-compressor/yui-compressor.jar
java -jar $YUI_JAR "$*"
Ensure that you have a Java runtime installed.

As Jordan mentioned, make sure you have Java installed. Try java -version to see if the JDK info shows up. If not try, which java -- on CentOS it should be in /usr/bin/java if are using the RPM installed version.
If it doesn't show up, use: yum install java-1.6.0-openjdk which should install the JDK and any other required java libs (do this with sudo or as root user). Just make sure you don't already have another JDK installed or you could run into problems later (try rpm -qa | grep java to see what's installed via RPM).
Then you should be able to call the yuicompressor directly with a statement like:
/usr/bin/java -jar /usr/share/yui-compressor/yui-compressor.jar --help
If you get the help output, you probably are ok. You can then use it on a file with a statement like:
/usr/bin/java -jar /usr/share/yui-compressor/yui-compressor.jar /path/to/source/file >> /path/to/exportfile.js
(obviously change the filename paths.) There are a number of options you can use, but that should get you started. I'm using this on CentOS with a build script that loops through various files and creates optimized bundled files and it works well.
You may also want to check out the build script and instructions at: http://html5boilerplate.com/ which uses yui-compressor and is the method I would eventually like to go with.

Related

transcrypt issue - cannot run the sample program

Followed the instructions in transcrypt "getting started" docs, I entered the examples 'hello.html' and 'hello.py' in a separate directory.
Entering from the command line: "transcrypt -b -m hello.py" resuleds in the error message: "'transcrypt' is not recognized as an internal or external command,
operable program or batch file."
I'm using python3.6, with transcrypt installed in: C:\program files\python36\lib\site-packages\transcrypt
Any help to activate the sample hello.html would be appreciated.
Could you try python -m transcrypt -b -m hello.py
and tell me what the console output is?
Also: are you on Windows, Linux or OsX?
Answer: Windows 10
[EDIT 1]
Looks like Transcrypt was installed under a different Python distro. Would be good to know what's going on, so please keep us informed. I also have several Python installs on my Windows 10 computer and it can be confusing indeed.
[EDIT 2]
Another possibility is manual installation (although it isn't elegant...). From the docs
http://www.transcrypt.org/docs/html/installation_use.html#installation-troubleshooting-checklist
Alternatively, for manual installation under Windows or Linux, follow
the steps below:
Download the Transcrypt zip and unpack it anywhere you like
Add ../Transcrypt-/transcrypt to your system path
To enable minification, additionally the Java Runtime Environment 6 or later has to be installed
Note If you install Transcrypt manually, Trancrypt is started by typing run_transcrypt rather than transcrypt. This allows a pip
installed Transcrypt and a manually installed Transcrypt to be used
side by side selectively
BTW Thanks for the suggestion on Github. We'll look into it and try to improve the docs on this point. It seems to be quite difficult to really draw up a bullet proof installation procedure for each platform.
You might also find it easier to use python3's built in virtual env, so that you install Transcrypt and other python modules only into one project folder at a time. It's much easier to use than it at first sounds.
Here's how you might do that on Windows 10.
mkdir mynewproject
cd mynewproject
py -3 -m venv myvirtualenv # installs venv files into myvirtualenv
myvirtualenv\Scripts\activate # activates the virtual env
The py -3 command uses the python windows launcher to use the latest version of python 3. The launcher is defined in Pep 397 and the docs are here.
Once the virtual environment is activated, the prompt will change to show that. After which any 'pip install' commands will install packages into 'myvirtualenv', instead of the system wide location. If you want to deactivate it, just type 'deactivate' or close the shell window. You can also just use 'python' to refer to python3 from within the virtual env. This has saved many people from madness.
In case this helps for other newbies. A few problems I encountered when setting up transcrypt.
Path issues: I had multiple versions of python, in different folders: \python26, \python27, and \Program Files\python36.
This caused all sorts of grief, despite setting the environmental path to include the python36 distro. I fixed this issue by renaming the other versions \python26x and \python27x. This left those distros intact if ever I needed to use them, but stopped the system from finding them. Thus, it only found python36
My earlier suggestion of py -3 didn't really solve the multiple distro issue completely after all.
After doing that, I reinstalled transcrypt and it seemed OK (sort of: read on)
Second issue was trying to run the sample hello.py. I tried "transcrypt -b hello.py" and got a "'transcrypt' is not recognized.." message.
But this worked: python -m transcrypt -b -m hello.py
That worked because the system had finally found the correct version of python, due to the above fix.
Similarly, trying to run the sample hello.py as recommended in the docs caused a problem. run_transcrypt -b hello.py
The reason for this was that run_transcrypt resolved to "python $(dirname $0)/main.py $*"
But, because I had python v3.6 installed in c:\Program Files, the batch file run_transcrypt caused this output:
c:\transcrypt>python C:\Program Files\Python36\Lib\site-packages\transcrypt__main__.py -b hello.py
python: can't open file 'C:\Program': [Errno 2] No such file or directory
Consequently, I had to place Program Files in quotes and run it this way:
"C:\Program Files"\Python36\Lib\site-packages\transcrypt__main__.py -b hello.py
or else, as above: python -m transcrypt -b -m hello.py
I think, with respect, the docs should raise a warning flag here for users who have python installed in \Program Files, rather than, for example, in c:\python[x]
Third issue Changing hello.py to "play around" with the code -
I found the files in transcrypt\demos\ to be read-only. To fix this:
1: I opened the command prompt as administrator
2: I ran the attrib command to change the file attributes:
"c:\Program Files\Python36\Lib\site-packages\transcrypt\demos\hello>attrib -r -s -a hello.py"
(Without doing this as administrator you get an access-denied message)
The whole exercise caused a few hours of toing and froing, but it seems that things are better now.

plutil: command not found

Ultimate Goal:
I'm trying to convert a binary plist file to an xml format so that I can put it in an array and grab values from it. What I'm finding via web search on this is that the command for Linux comes from libplist.
Problem: I ran "yum install libplist" and it told me libplist is already installed and latest version. I've read that if I enter the following command:
plutil -i /mypath/file.plist > /mypath/file.xml.plist
That this will help accomplish my ultimate goal. However, when I do this only a blank file called file.xml.plist is created. Further, with this command and any other command involving plutil, I get a "bash: plutil: command not found. . ." error. Is libplist seemingly not installed (even though it says it is) or why would I repeatedly get this error? Thanks for your help.
You can use yum to look for a package knowing the binary you want. For instance, if I want to install the package that provides plutil, I simply run this command:
$> yum provides plutil
Unfortunately, the result is No matches found... But you say you read that the libplist package provides this tool. Maybe it was renamed ? Let's use repoquery for this (if you don't have it, yum provides repoquery tells you that you need to install yum-utils).
$> repoquery --list libplist
/usr/bin/plistutil
/usr/lib/libplist++.so.3
/usr/lib/libplist++.so.3.0.0
/usr/lib/libplist.so.3
/usr/lib/libplist.so.3.0.0
/usr/share/doc/libplist
/usr/share/doc/libplist/AUTHORS
/usr/share/doc/libplist/COPYING.LESSER
/usr/share/doc/libplist/README
And what I see is that a program called plistutil was installed with this package !
I've never used plutil, so I can't tell you for sure plistutil is the program you want (but it probably is). What I wanted to do instead with this post is to show how you can use yum to install the packages you need !
I ran across this thread while Googling for the same thing myself. After looking at a few solutions for my own company (Screenplay) I decided to fork and iterate on a open-source, cross-platform, drop-in replacement for plutil:
https://github.com/screenplaydev/plutil
It's forked from Facebook's xcbuild (a tool developed by them to build xcode projects on Linux), but stripped down to just provide plist-editting functionality. That way you won't need to maintain separate code-paths for Mac and Linux environments.
Hope that's helpful!

Why does executing debug in 0.13.7 fail with "Could not find agent library jdwp:transport on the library path"?

After update from 0.13.6 to 0.13.7 I cannot debug with SBT.
It is installed using Homebrew. I tried to reinstall it, brew doctor shows nothing.
I did not change/reinstall Java between SBT update.
lgr$ sbt -v -jvm-debug 5005 "project webapp" run
[process_args] java_version = '1.8.0_25'
# Executing command line:
java
-Xms1024m
-Xmx1024m
-XX:ReservedCodeCacheSize=128m
-XX:MaxMetaspaceSize=256m
-agentlib:jdwp:transport=dt_socket,server=y,suspend=n,address=5005
-jar
/usr/local/Cellar/sbt/0.13.7/libexec/sbt-launch.jar
"project webapp"
run
Error occurred during initialization of VM
Could not find agent library jdwp:transport on the library path, with error: dlopen(libjdwp:transport.dylib, 1): image not found
I am unsure whether SBT is missing some library, or brew formula didn't install properly.
I will be helpful for any idea how to fix it.
Reinstalled Java, didn't help.
Workaround I downloaded SBT 0.13.6 and it works without problem, so I start to consider this as a sbt bug. Can anyone help to clarify if it is?
To piggyback on Eugene's answer above, since the fix is in a bash script, it is pretty easy to apply the fix from https://github.com/sbt/sbt-launcher-package/pull/85/files manually. Just edit bin/sbt-launch-lib.bash to have this:
addJava "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$1"
Instead of this:
addJava "-agentlib:jdwp:transport=dt_socket,server=y,suspend=n,address=$1"
(Mind the : not = between jdwp and transport).
It is installed using Homebrew.
Homebrew install is sanctioned by sbt project as a recommended way to install on Mac, but we (I'm one of the sbt devs) currently don't control it. We do however have the official package sbt/sbt-launcher-package, and last I checked Homebrew is also using it.
Looking at git blame of the relevant part of the script, it seems like the debug option was "fixed" in sbt/sbt-launcher-package#83:
In sbt-launch-lib.bash, -Xdebug option is used for debugging. We should use -agentlib option for Java 5+.
Maybe your issue should be tracked as a bug in sbt/sbt-launcher-package.
The problem was fixed in the 0.13.8 version.
At my case the bash fix didn't help but running from bash as:
export SBT_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
sbt
helped. It is from here.

How to use different java versions for different programs?

This may be common in web but may be I am not getting what to search exactly. Actually I am having different versions of java on my ubuntu server having java 1.5 as default. One of my program need java 1.6 and even if I perform following in the shell script executing that program
export JAVA_HOME=/path/to/jdk6
I dont get any success.What I learnt is I could see current java version using
java -version
This only get change when I changes the alternative using:
sudo update-alternatives --config java
Please tell me how can I change it in the shell script which in turn calls the java program requiring java6 having java 5 as default only.
Thanks!!!
You need to update the PATH as well:
JAVA_HOME=/path/to/jdk6
export JAVA_HOME
PATH=${JAVA_HOME}/bin:${PATH}
export PATH

How to setup W3C Unicorn validator for local URIs?

I frequently need to check not-yet-public websites so cannot use a public online validator. I tried to install W3C’s Unicorn on my OSX (10.7) machine using MacPorts (because I didn’t want to cope with dependencies). Unfortunately the docs for Unicorn installation are mostly missing or outdated, and the mailing list looks dead.
Disclaimer: I don’t know Java.
Here’s what I did:
install Java update to 1.6.0_29 (since Apple’s current one has a memory leak)
install Tomcat and dependencies (ivy is missing in docs and doesn’t get downloaded automatically as it is supposed to):
sudo port install apache-ant apache-ivy tomcat6 mercurial
select Python version for Mercurial; perhaps better use python.org-Python and install Mercurial there, but I’ve only system and MacPort’s Python on this machine:
sudo port select python python27
automatically start Tomcat after reboot:
sudo launchctl load -w /Library/LaunchDaemons/org.macports.tomcat6.plist
add setup to .profile:
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
export CATALINA_HOME=/opt/local/share/java/tomcat6
check output of java -version (my Java version in "A" or "Current" was broken; java -version just hang)
fix Java binary path; if there's no $JAVA_HOME/bin:
cd $JAVA_HOME; sudo ln -s Commands bin
restart
check if tomcat runs on http://localhost:8080 (ok)
get and compile unicorn:
cd ~/workspace
hg clone https://dvcs.w3.org/hg/unicorn
cd unicorn
ant retrieve compress-css compress-js war cli
install unicorn in tomcat:
sudo cp dist/unicorn.war $CATALINA_HOME/webapps/
sudo cp WebContent/resources/tomcat_policy/* $CATALINA_HOME/conf/
yes it works, but only for public addresses; we need to change
one setting in unicorn.properties: ACCEPT_LOCAL_ADDRESSES = true
validator paths in observers.properties from http://validator.w3.org/.../*.wadl to file:///.../*.wadl
I can change *.properties in $CATALINA_HOME/webapps/unicorn/WEB-INF/classes or (better) in ~/workspace/unicorn/WebContent/WEB_INF/conf. But changes to the latter never make it into the .war, don’t know why. (Maybe they’re pacifist?) If *.properties.default are renamed to *.properties, they’re missing in the distribution, if I don’t rename them, changes are ignored. I found a hint to include that conf-path in $CLASSPATH, but that didn’t help either.
So I copy the adapted configs into the installed webapp, and Unicorn seems to run - but validation results in a white page (status code = 200, but content length = 0).
In tomcat’s error log I find only (don’t know if that’s important):
INFO: validateJarFile(/opt/local/share/java/tomcat6/webapps/unicorn/WEB-INF/lib/servlet-api-2.5.jar) - jar not loaded.
See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
CLI
Inbetween I tried if the command line interface is usable. java -jar unicorn.jar shows some usage hints, but validation of anything fails with
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at org.w3c.unicorn.UnicornClient.main(UnicornClient.java:113)
Finally
What can I do?

Resources