####For future me.####

copy latest refpolicy in refpolicy directory.
$ cd
$ git clone http://oss.tresys.com/git/refpolicy.git
$ cd refpolicy
$ git submodule init
$ git submodule update
$ rm -rf segatex-version/{refpolicy,policy}
$ mkdir segatex-version/{refpolicy,policy}
$ cp -ar refpolicy/* segatex-version/refpolicy

just run this command 
$ cd segatex-version
$ ./comment_optional_policy.sh

it will comment optional policy and make files anew in segatex-version/refpolicy/policy/modules/files.

now you copy segatex-version/refpolicy/policy/modules/files to segatex-version/policy/

Next, you do this.

1
make all.if and all.spt file by catting all .if and .spt files.
You may do this in policy directory where all .if and .spt files reside.
do this
for example, if you downloaded segatex in your home directory,

$ cat ~/segatex-version/policy/*.if > ~/segatex-version/all.if
$ cat ~/segatex-version/refpolicy/policy/support/*.spt > ~/segatex-version/all.spt

hen you install segatex anew.
this means refpolicy files are successfully replaced in the /usr/share/segatex, so, you should first install your latest version. 

2
first break all the .if files in /usr/share/segatex/raw_if_files by breakif.sh
$su
#cd /usr/share/segatex/raw_if_files
#./breakif.sh 

3

cd /usr/share/segatex/raw_if_files
# sqlite3 sqlrefpolicy.db
# sqlite> .show
# sqlite> create table layer_if_file_interface_name_target_domain_object_class_permissions (no integer primary key,layer varchar(30),if_file varchar(100),interface_name varchar(200),target_domain varchar(200),object_class varchar(200),permissions varchar(2000));
# sqlite> .table
# sqlite> .exit
#
# 4
#
#  cp path/segatex-version/admin/sqlrefpolicy_prepare*.sh /usr/share/segatex/raw_if_files
#
#  5
#
#  chcon system_u:object_r:bin_t:s0 /usr/share/segatex/raw_if_files/sqlrefpolicy_prepare*
#
#  excecute scripts.
#  (if it work not, may need editing some on last file.)
after excecuting 7 sh files, you will get sqlrefpolicy.db in /usr/share/segatex/raw_if_files.
#
#######################explanation######################################################
you should run 7prepare scripts before you go on breaking .te and .if files.
##you need to change context of scripts, do #chcon system_u:object_r:bin_t:s0 /usr/share/segatex/raw_if_files/sqlrefpolicy_prepare*
after excecuting 7 sh files, you will get sqlrefpolicy.db.
########################################################################################

then you should copy sqlrefpolicy.db to segatex-version directory and make .tar file one more time.

release new segatex version.

you can now break .te or .if files successfully.
