How to ignore directories in OpenGrok index? - opengrok

I am trying to setup OpenGrok to search through a few GB of code, mostly Java and Python projects. I use opengrok-0.12.1/bin/OpenGrok index $SRC_ROOT to build the index. I can see it indexing Java's "target" and Python's ".tox" directories which I don't need.
I searched online and found the same question in many forums, and the answer being to use -i. I have tried to use this option with both the OpenGrok wrapper script as well as opengrok.jar, but all I get is the help message (because the command line options were apparently wrong).
Could you give me an example command to build indices that ignore certain directories?

The solution is to use the -i flag. The best way to do this is to create a .conf file. For example, I have the following file defined as opengrok.conf:
OPENGROK_APP_SERVER=Tomcat
OPENGROK_TOMCAT_BASE=/usr/local/Cellar/tomcat/8.0.21/libexec
OPENGROK_SCAN_DEPTH=4
OPENGROK_VERBOSE=yes
OPENGROK_PROGRESS=yes
IGNORE_PATTERNS="-i f:foo.txt -i *.bar -i d:target -i d:.tox"
And run the indexing using:
OPENGROK_CONFIGURATION=opengrok.conf ./OpenGrok index $SRC_ROOT
It ignores indexing the file foo.txt, all files that match the pattern *.bar, and all files in directories named target or .tox.
Edit credits: mrenaud, pcas

Note that https://github.com/oracle/opengrok/pull/1841 renamed IGNORE_PATTERNS to OPENGROK_IGNORE_PATTERNS (in Oct 2017).

https://github.com/oracle/opengrok/wiki/How-to-setup-OpenGrok
java -jar opengrok-1.3.16/lib/opengrok.jar --help
-i, --ignore pattern
Ignore matching files (prefixed with 'f:' or no prefix) or directories
(prefixed with 'd:'). Pattern supports wildcards (example: -i '*.so'
-i d:'test*'). Option may be repeated.
with the new opengrok-tools, it looks like
opengrok-indexer \
--java_opts=-Djava.util.logging.config.file=$(OPENGROK_BASE)/etc/logging.properties \
--jar $(OPENGROK_DIST)/lib/opengrok.jar -- \
--ctags /usr/local/bin/ctags \
--source $(PWD) \
--dataRoot $(OPENGROK_BASE)/data \
--progress \
--history \
--assignTags \
--writeConfig $(OPENGROK_BASE)/etc/configuration.xml \
--analyzer .sc:ScalaAnalyzer \
--ignore 'd:zold' \
--ignore 'd:opengrok' \
--ignore 'd:tmp' \
--ignore 'd:.venv' \
--ignore 'd:.ipynb_checkpoints' \
--ignore 'd:.metals' \
# END

Related

QEMU-KVM automatically set filterref parameter

I'm sorry if this is a simple question, but I am just starting out with qemu and can't find a easy way to do this.
I am trying to somewhat automate my KVM deployment. I am currently running into the issue that I can't find a way to automatically set parameters for a filterref.
This is what my network option for virt-install currently looks like and that is working fine for now.
--network type=bridge,network=default,bridge=bridge0,model=e1000e,mac=$mac,filterref=clean-traffic
However I can't find anything to set a parameter to define the IP address it's supposed to be locked down to. This is the result that I want in the xml:
<filterref filter='clean-traffic'>
<parameter name='IP' value='XXX.XXX.XXX.XXX'/>
</filterref>
I am looking for a way to automatically add that parameter, preferably directly with virt-install or to an extent were I can just run a script, enter the few variables I want to set. And at this point the VM would already be running and waiting for the setup to be completed, with the filter loaded. Basically I want the parameter to be loaded before the first startup, so that there is no chance of anyone trying to mess with the ip address.
Is this possible?
This is the whole "script" I just copy into the console at the moment.
name=WindowsTest
mac=00:50:56:00:05:C5
size=70
ram=6000
vcpus=6
let cores=vcpus/2
virt-install \
--name=$name \
--ram=$ram \
--cpu=host \
--vcpus=$vcpus,maxvcpus=$vcpus,sockets=1,cores=$cores,threads=2 \
--os-type=windows \
--os-variant=win10 \
--disk path=/var/lib/libvirt/clutchImages/$name.qcow2,size=$size,format=qcow2,bus=virtio \
--cdrom /var/isos/Windows_20H2_English.iso \
--disk /var/isos/virtio-win-0.1.185.iso,device=cdrom \
--network type=bridge,network=default,bridge=bridge0,model=e1000e,mac=$mac,filterref=clean-traffic \
--graphics spice,listen=157.90.2.208 \
--graphics vnc
virsh version output:
virsh version
Compiled against library: libvirt 6.0.0
Using library: libvirt 6.0.0
Using API: QEMU 6.0.0
Running hypervisor: QEMU 4.2.0
I am on CentOS Linux release 8.3.2011.
Make arbitrary edits to virt-install's xml output
According to the man page you can make direct edits to the XML using XPath
syntax.
e.g.
virt-install \
#...
--network network="${net}",mac="${macaddr},filterref.filter=clean-traffic" \
--xml xpath.create=./devices/interface/filterref/parameter \
--xml xpath.set=./devices/interface/filterref/parameter/#name=IP \
--xml xpath.set=./devices/interface/filterref/parameter/#value=10.0.0.20
#...
virt-install man page excerpt:
man virt-install | grep -m1 -A40 '\-\-xml'
--xml
Syntax: --xml ARGS
Make direct edits to the generated XML using XPath syntax. Take an ex‐
ample like
virt-install --xml ./#foo=bar --xml ./newelement/subelement=1
This will alter the generated XML to contain:
<domain foo='bar' ...>
...
<newelement>
<subelement>1</subelement>
</newelement>
</domain>
The --xml option has 4 sub options:
--xml xpath.set=XPATH[=VALUE]
The default behavior if no explicit suboption is set. Takes the
form XPATH=VALUE unless paired with xpath.value . See below for
how value is interpreted.
--xml xpath.value=VALUE
xpath.set will be interpreted only as the XPath string, and
xpath.value will be used as the value to set. May help sidestep
problems if the string you need to set contains a '=' equals
sign.
If value is empty, it's treated as unsetting that particular
node.
--xml xpath.create=XPATH
Create the node as an empty element. Needed for boolean elements
like <readonly/>
--xml xpath.delete=XPATH
Delete the entire node specified by the xpath, and all its chil‐
dren
XML result
<interface type="network">
<!-- ... -->
<filterref filter="clean-traffic">
<parameter name="IP" value="10.0.0.20"/>
</filterref>
</interface>
virsh version output:
Compiled against library: libvirt 7.7.0
Using library: libvirt 7.7.0
Using API: QEMU 7.7.0
Running hypervisor: QEMU 6.2.0
Quick & dirty
name=WindowsTest
mac=00:50:56:00:05:C5
IP=xxx.yyy.zzz.qqq
size=70
ram=6000
vcpus=6
let cores=vcpus/2
virt-install \
--name=$name \
--ram=$ram \
--cpu=host \
--vcpus=$vcpus,maxvcpus=$vcpus,sockets=1,cores=$cores,threads=2 \
--os-type=windows \
--os-variant=win10 \
--disk path=/var/lib/libvirt/clutchImages/$name.qcow2,size=$size,format=qcow2,bus=virtio \
--cdrom /var/isos/Windows_20H2_English.iso \
--disk /var/isos/virtio-win-0.1.185.iso,device=cdrom \
--network type=bridge,network=default,bridge=bridge0,model=e1000e,mac=$mac,filterref=clean-traffic \
--graphics spice,listen=157.90.2.208 \
--graphics vnc
--print-xml > /tmp/{$name}.xml && \
sed -i "s/<filterref.*/<filterref filter='clean-traffic'>\n <parameter name='IP' value='${IP}'\/>\n <\/filterref>/g" /tmp/{$name}.xml && \
virsh create /tmp/{$name}.xml

GCS gcloud too much passphrase

I'm trying to script my VM creation and setup process.
Currently the script asks for my ssh passphrase multiple times.
Is there a way to enter the passphrase once at the beginning of the script and be done?
here's the first script:
gcloud -q compute instances create $VM_NAME \
--zone=$ZONE \
--machine-type=n1-standard-1 \
--image-project=ml-images \
--image-family=tf-1-14 \
--scopes=cloud-platform \
--boot-disk-size=24GB \
&& \
echo vm created \
&& \
gcloud -q compute scp --recurse \
~/altered-source/ $VM_NAME:~ \
--zone=$ZONE \
&& \
gcloud -q compute scp --recurse \
~/vm-scripts/ $VM_NAME:~ \
--zone=$ZONE \
&& \
echo files transfered \
&& \
gcloud -q compute ssh $VM_NAME \
--zone=$ZONE
Please provide some details of how you're attempting this.
By default, if you using gcloud, an ssh keypair will be generated automatically for you and stored in the metadata service so that you can ssh seamlessly, e.g.
gcloud compute instances create ${INSTANCE} ...
gcloud compute ssh ${INSTANCE} ... --command=....
Possible a better method to recreate the instance(s) programmatically, is to developer a startup script and then pass this to the instance during creation:
https://cloud.google.com/sdk/gcloud/reference/compute/instances/create#startup-script
Yo!
Definitively, use a Storage Bucket for that intra-transfer thing; you'll see you'll have better control and faster responses all the way.
If you really require to use a "third leg" perhaps using your local machine could work, you just need to install the SDK and use gcloud commands, it wont ask you for keys once you exchanged them between local and remote VMs, the caveat? you rely on your ISP Up/Down speeds, the good thing you know what, and how long is taking a file to upload.
Now, once again I suggest as other here already did, use a cloud bucket, that way you only need to refer your file as gs:///file and forget about the rest.
In any case here is some info about transferring files to instances.
Have an awesome day!
-JP

Suppress Specific IP Warnings in Modelsim

A Vivado IP is generating an inordinate amount of Modelsim warnings which are making it difficult to assess the simulation for warnings I actually care about.
I see from the Modelsim command documentation that in order to suppress a warning I need to include the parameter -suppress and then the warning numbers. My current implementation is as follows...
vsim -voptargs=+acc \
-L work \
-L xil_defaultlib \
-L secureip \
-L simprims_ver \
-L unifast_ver \
-L unimacro_ver \
-L unisims_ver \
-L xpm \
-L fifo_generator_v13_1_1 \
-L blk_mem_gen_v8_3_3 \
work.blr_tb xil_defaultlib.glbl -l sv_sim.log -suppress 3015,3017,3722
This code snippet works but I am afraid that this will suppress warnings that are created by problems with my own rtl. Is there a way of suppressing specific warnings of an IP?
For reference the warnings are all from the Vivado MIG IP and look something like this...
# ** Warning: (vsim-3017) ../../ip/xc7k160t2ffg676-2/mig_ddr3_64bit_32G/mig_ddr3_64bit_32G/user_design/rtl/phy/mig_7series_v4_0_ddr_mc_phy_wrapper.v(1260): [TFMPC] - Too few port connections. Expected 9, found 8.
# Time: 0 fs Iteration: 0 Instance: /blr_tb/blr_sbk_top_i/ddr3_balor_i/u_mig_ddr3_64bit_32G/u_mig_ddr3_64bit_32G_mig/u_memc_ui_top_std/mem_intfc0/ddr_phy_top0/u_ddr_mc_phy_wrapper/gen_dqs_iobuf_HP/gen_dqs_iobuf[0]/gen_dqs_diff/u_iobuf_dqs File: C:/Xilinx/Vivado/2016.2/data/verilog/src/unisims/IOBUFDS_DIFF_OUT_DCIEN.v
The MIG is compiled with the following command...
vlog -work xil_defaultlib -incr \
"$SBK_IP_DIR/mig_ddr3_64bit_32G/mig_ddr3_64bit_32G/user_design/rtl/mig_ddr3_64bit_32G.v" \
"$SBK_IP_DIR/mig_ddr3_64bit_32G/mig_ddr3_64bit_32G/user_design/rtl/mig_ddr3_64bit_32G_mig_sim.v" \
"$SBK_IP_DIR/mig_ddr3_64bit_32G/mig_ddr3_64bit_32G/user_design/rtl/clocking/*.v" \
"$SBK_IP_DIR/mig_ddr3_64bit_32G/mig_ddr3_64bit_32G/user_design/rtl/controller/*.v" \
"$SBK_IP_DIR/mig_ddr3_64bit_32G/mig_ddr3_64bit_32G/user_design/rtl/ecc/*.v" \
"$SBK_IP_DIR/mig_ddr3_64bit_32G/mig_ddr3_64bit_32G/user_design/rtl/ip_top/*.v" \
"$SBK_IP_DIR/mig_ddr3_64bit_32G/mig_ddr3_64bit_32G/user_design/rtl/phy/*.v" \
"$SBK_IP_DIR/mig_ddr3_64bit_32G/mig_ddr3_64bit_32G/user_design/rtl/ui/*.v"

svnnotify html color diff

I'm using svnnotify to send notification email upon commits. I have the following script on my repo's hooks/post-commit:
#!/bin/sh
REPOS="$1"
REV="$2"
for address in $(/bin/cat /var/svn/teachbyapp/hooks/addressee.list)
do
/usr/local/bin/svnnotify \
-r $REV \
-C \
-d \
--diff-encoding utf8 \
-H HTML::ColorDiff \
-p $REPOS \
-t "$address" \
--from svn#factory.e-levelcom.com
done
It works but all I get is balck and white diff (no colors at all).
Added lines are underlined whereas removed lines have strike-through format. Nothing else, no color at all.
How can I get actually colored diff? Something like this
Ok I found it.
Thanks to this work
Also needed to append --css-inline option to svnnotify command in my script

TopoJson makefile ignoring external properties file

I am trying to make a topojson file with csv data embedded using a makefile. I am using Mike Bostock's us-atlas as a guide.
topo/us-counties-10m-ungrouped.json: shp/us/counties.shp
mkdir -p $(dir $#)
topojson \
-o us_counties.json \
--no-pre-quantization \
--post-quantization=1e6 \
--external-properties=output.csv \
--id-property=FIPS \
--properties="County=County" \
--properties="PerChildrenPos=+PerChildrenPos" \
--simplify=7e-7 \
-- $<
It creates the topojson I need but completely ignores the output.csv file.
Here is a glimpse at what it returns.
{"type":"Polygon","id":"53051","properties":{"code":"53051"},"arcs":[[-22,79,80,-75,81]]}
Here's what I need it to return.
{"type":"Polygon","id":"53051","properties":{"code":"53051", "County":"Los Angeles", "PerChildrenPos": 10},"arcs":[[-22,79,80,-75,81]]}
Any ideas why it might be ignoring the csv file, I've tested moving it around to see if perhaps it was unaccessible or something?
Thanks in advance.
According to the documentation here: https://github.com/mbostock/topojson/wiki/Command-Line-Reference#external-properties
(If your CSV file uses a different column name for the feature identifier, you can specify multiple id properties, such as --id-property=+FIPS,+id.)
It seems that you need to change your --id-property=FIPS \ to something that corresponds to your CSV column names.
Also for --properties="County=County" \
I think it should be --properties County=+County \
Same for --properties="PerChildrenPos=+PerChildrenPos" \
Should be --properties PerChildrenPos=+PerChildrenPos \
For --external-properties=output.csv \
it should be --external-properties output.csv \
Basically the parameters do not need to be prefixed by an = sign.