Vpk.exe: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(→Commands: Updated with latest commands and formats) |
||
Line 5: | Line 5: | ||
VPKs can be created with the [[command line]] tool <code>vpk.exe</code>. | VPKs can be created with the [[command line]] tool <code>vpk.exe</code>. | ||
=Commands= | |||
; <code><dirname></code> | ===Usage:=== | ||
: Creates a | ::<code>vpk [options] <command> <command arguments ...></code> | ||
; <code> | ::<code>vpk [options] <directory></code> | ||
::<code>vpk [options] <vpkfile></code> | |||
==Create VPK/Add Files== | |||
; <code>vpk <dirname></code> | |||
: Creates a pack file named <dirname>.vpk. Must be an existing location. The VPK will appear next to the directory. {{tip|Drag a folder onto the tool in Explorer to trigger this command.}} | |||
; <code>vpk a <vpkfile> <filename1> <filename2> ...</code> | |||
: Add file(s). | : Add file(s). | ||
; <code>a <vpkfile> @<filename></code> | ; <code>a <vpkfile> @<filename></code> | ||
: Adds the files referenced in a "response file" (''not'' response rules). Note the <code>@</code> symbol. | : Adds the files referenced in a "response file" (''not'' response rules). Note the <code>@</code> symbol. | ||
; <code>k vpkfile < | ; <code>k vpkfile <keyvalues_filename></code> | ||
: Add files references in a [[keyvalues]] file. {{bug|They will appear inside the VPK with their full path (<code>C:\etc\</code>) intact - is there a way to avoid this?}} | : Add files references in a [[keyvalues]] control file. {{bug|They will appear inside the VPK with their full path (<code>C:\etc\</code>) intact - is there a way to avoid this?}} | ||
; <code>l <vpkfile></code> | ; <code>vpk <directory></code> | ||
; <code>L <vpkfile></code> | : Create VPK from directory structure. {{note|This is invoked when a directory is dragged onto the VPK tool.}} | ||
: List contents of VPK. | ==Extract Files== | ||
; <code>vpk x <vpkfile> <filename1> <filename2> ...</code> | |||
: Extract file(s). | |||
; <code>vpk <vpkfile></code> | |||
: Extract all files from VPK. {{note|This is invoked when a .VPK file is dragged onto the VPK tool.}} | |||
==Display VPK Info== | |||
; <code>vpk l <vpkfile></code> | |||
: List contents of VPK. | |||
; <code>vpk L <vpkfile></code> | |||
: List ''Detailed'' contents of VPK. | |||
==VPK Integrity/Security== | |||
; <code>vpk checksig <vpkfile></code> | |||
: Verify signature of specified VPK file. Requires -k to specify key file to use. | |||
==Misc== | |||
; <code>vpk generate_keypair <keybasename></code> | |||
: Generate public/private key file. Output files will be named ''<keybasemame>.publickey.vdf'' and ''<keybasemame>.privatekey.vdf'' {{note|Remember: your private key should be kept private.}} | |||
==Options== | |||
; {{tip|Please note the case of these options. A capital letter is different than a lowercase letter.}} | |||
; <code>-v</code> | ; <code>-v</code> | ||
: Verbose output. | : Verbose output. | ||
; <code>-M</code> | ; <code>-M</code> | ||
: Produce a multi-chunk VPK. | : Produce a multi-chunk VPK. {{note|Required if creating a VPK with key values.}} | ||
:* Each chunk is a file limited to around 200MB. | :* Each chunk is a file limited to around 200MB. | ||
:* To reduce patch sizes, chunks are never overwritten. New/modified files are instead written to a brand new chunk every time you run the tool. {{note|Multi-chunk generations only works when creating a VPK from a response file.}}{{tip|To inspect a multi-chunk VPK open the '_dir' file.}} | :* To reduce patch sizes, chunks are never overwritten. New/modified files are instead written to a brand new chunk every time you run the tool. {{note|Multi-chunk generations only works when creating a VPK from a response file.}}{{tip|To inspect a multi-chunk VPK open the '_dir' file.}} | ||
; <code>-P</code> | |||
: Use SteamPipe-friendly incremental build algorithm. Use with 'k' command. For optimal incremental build performance, the control file used for the previous build should exist and be named the same as theinput control file, with '.bak' appended, and each file entryshould have an 'md5' value. The 'md5' field need not be theactual MD5 of the file contents, it is just a unique identifierthat will be compared to determine if the file contents has changedbetween builds. | |||
; <code>-c <size></code> | |||
: Use specified chunk size (in MB). Default is 200. | |||
; <code>-a</code> | |||
: Align files within chunk on n-byte boundary. Default is 1. | |||
; <code>-K</code> | |||
: With commands 'a' or 'k': Sign VPK with specified ''private'' key. | |||
; <code>-k</code> | |||
:* With commands 'a' or 'k': Public key that will be distributed and used by third parties to verify signatures. | |||
:* With command 'checksig': Check signature using specified key file. | |||
=== Response file === | === Response file === |
Revision as of 21:56, 25 April 2013
VPK ("Valve Pak") files are uncompressed archives used to package game content. Valve's post-GCF games store materials, models, particles, and choreography scenes in VPK files. VPK is also used to distribute mods via the the addoninstaller
tool that ships with some games.
Creation
VPKs can be created with the command line tool vpk.exe
.
Commands
Usage:
vpk [options] <command> <command arguments ...>
vpk [options] <directory>
vpk [options] <vpkfile>
Create VPK/Add Files
vpk <dirname>
- Creates a pack file named <dirname>.vpk. Must be an existing location. The VPK will appear next to the directory.
Tip:Drag a folder onto the tool in Explorer to trigger this command.
vpk a <vpkfile> <filename1> <filename2> ...
- Add file(s).
a <vpkfile> @<filename>
- Adds the files referenced in a "response file" (not response rules). Note the
@
symbol. k vpkfile <keyvalues_filename>
- Add files references in a keyvalues control file.
Bug:They will appear inside the VPK with their full path (
C:\etc\
) intact - is there a way to avoid this? [todo tested in ?] vpk <directory>
- Create VPK from directory structure.
Note:This is invoked when a directory is dragged onto the VPK tool.
Extract Files
vpk x <vpkfile> <filename1> <filename2> ...
- Extract file(s).
vpk <vpkfile>
- Extract all files from VPK.
Note:This is invoked when a .VPK file is dragged onto the VPK tool.
Display VPK Info
vpk l <vpkfile>
- List contents of VPK.
vpk L <vpkfile>
- List Detailed contents of VPK.
VPK Integrity/Security
vpk checksig <vpkfile>
- Verify signature of specified VPK file. Requires -k to specify key file to use.
Misc
vpk generate_keypair <keybasename>
- Generate public/private key file. Output files will be named <keybasemame>.publickey.vdf and <keybasemame>.privatekey.vdf
Note:Remember: your private key should be kept private.
Options
Tip:Please note the case of these options. A capital letter is different than a lowercase letter.
-v
- Verbose output.
-M
- Produce a multi-chunk VPK.
Note:Required if creating a VPK with key values.
- Each chunk is a file limited to around 200MB.
- To reduce patch sizes, chunks are never overwritten. New/modified files are instead written to a brand new chunk every time you run the tool.
Note:Multi-chunk generations only works when creating a VPK from a response file.
Tip:To inspect a multi-chunk VPK open the '_dir' file.
-P
- Use SteamPipe-friendly incremental build algorithm. Use with 'k' command. For optimal incremental build performance, the control file used for the previous build should exist and be named the same as theinput control file, with '.bak' appended, and each file entryshould have an 'md5' value. The 'md5' field need not be theactual MD5 of the file contents, it is just a unique identifierthat will be compared to determine if the file contents has changedbetween builds.
-c <size>
- Use specified chunk size (in MB). Default is 200.
-a
- Align files within chunk on n-byte boundary. Default is 1.
-K
- With commands 'a' or 'k': Sign VPK with specified private key.
-k
-
- With commands 'a' or 'k': Public key that will be distributed and used by third parties to verify signatures.
- With command 'checksig': Check signature using specified key file.
Response file
A "response file" contains a list of files to be added to a VPK. Paths are relative to the current directory of the vpk
tool.
Below is a Python script which generates a response file and then builds a multi-chunk VPK. Put it in your mod folder. You will need to edit the three variables at the top.
# User settings (don't use the \ character)
target_folders = [ "materials", "models", "particles", "scenes" ]
file_types = [ "vmt", "vtf", "mdl", "phy", "vtx", "vvd", "pcf", "vcd" ]
vpk_path = "C:/Program Files (x86)/Steam/steamapps/common/SourceFilmmaker/game/bin/vpk.exe"
# Script begins
import os,subprocess
from os.path import join
response_path = join(os.getcwd(),"vpk_list.txt")
out = open(response_path,'w')
len_cd = len(os.getcwd()) + 1
for user_folder in target_folders:
for root, dirs, files in os.walk(join(os.getcwd(),user_folder)):
for file in files:
if len(file_types) and file.rsplit(".")[-1] in file_types:
out.write(os.path.join(root[len_cd:].replace("/","\\"),file) + "\n")
out.close()
subprocess.call([vpk_path, "-M", "a", "pak01", "@" + response_path])
Excluded files
Executable and archive files are discarded by the VPK tool:
.zip .reg .rar .msi .exe .dll .com .cmd .bat